summaryrefslogtreecommitdiff
path: root/plugins/pdb-ng/src
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-12-17 21:23:46 -0500
committerMason Reed <35282038+emesare@users.noreply.github.com>2026-01-11 10:36:01 -0800
commit168a3fd34824adc9c6a606cd144219701f15cccf (patch)
tree9bbac31ece5ea6ab6627998d995a77f7f7e2f8e6 /plugins/pdb-ng/src
parentca91bc1933976c62d24248f0f7c35af38451ff11 (diff)
[Rust] Replace `log` with `tracing`
- Added more documentation - Replaced global named logger for plugins, fixing the issue when the CU has multiple (e.g. statically linked demo) - Simplified some misc code This is a breaking change, but I believe there is no better time to make it, we cannot continue to use the `log` crate, it is too limited for our needs.
Diffstat (limited to 'plugins/pdb-ng/src')
-rw-r--r--plugins/pdb-ng/src/lib.rs25
-rw-r--r--plugins/pdb-ng/src/parser.rs2
-rw-r--r--plugins/pdb-ng/src/struct_grouper.rs5
-rw-r--r--plugins/pdb-ng/src/type_parser.rs2
4 files changed, 21 insertions, 13 deletions
diff --git a/plugins/pdb-ng/src/lib.rs b/plugins/pdb-ng/src/lib.rs
index d7eb2524..5bbbb53e 100644
--- a/plugins/pdb-ng/src/lib.rs
+++ b/plugins/pdb-ng/src/lib.rs
@@ -21,15 +21,14 @@ use std::sync::mpsc;
use std::{env, fs};
use anyhow::{anyhow, Result};
-use log::{debug, error, info};
use pdb::PDB;
use binaryninja::binary_view::{BinaryView, BinaryViewBase, BinaryViewExt};
use binaryninja::debuginfo::{CustomDebugInfoParser, DebugInfo, DebugInfoParser};
use binaryninja::download::{DownloadInstanceInputOutputCallbacks, DownloadProvider};
use binaryninja::interaction::{MessageBoxButtonResult, MessageBoxButtonSet};
-use binaryninja::logger::Logger;
use binaryninja::settings::{QueryOptions, Settings};
+use binaryninja::tracing::{debug, error, info};
use binaryninja::{interaction, user_directory};
use parser::PDBParserInstance;
@@ -436,7 +435,9 @@ impl PDBParser {
Ok(_) => {
info!("Downloaded to: {}", cab_path.to_string_lossy());
}
- Err(e) => error!("Could not write PDB to cache: {}", e),
+ Err(e) => {
+ error!("Could not write PDB to cache: {}", e)
+ }
}
}
@@ -471,7 +472,9 @@ impl PDBParser {
Ok(_) => {
info!("Downloaded to: {}", cab_path.to_string_lossy());
}
- Err(e) => error!("Could not write PDB to cache: {}", e),
+ Err(e) => {
+ error!("Could not write PDB to cache: {}", e)
+ }
}
}
}
@@ -588,7 +591,9 @@ impl CustomDebugInfoParser for PDBParser {
}
}
Ok(None) => {}
- e => error!("Error searching symbol store {}: {:?}", store, e),
+ e => {
+ error!("Error searching symbol store {}: {:?}", store, e)
+ }
}
}
}
@@ -649,7 +654,9 @@ impl CustomDebugInfoParser for PDBParser {
Err(e) => debug!("Skipping, {}", e.to_string()),
},
Err(e) if e.to_string() == "Cancelled" => return false,
- Err(e) => debug!("Could not read pdb: {}", e.to_string()),
+ Err(e) => {
+ debug!("Could not read pdb: {}", e.to_string())
+ }
}
}
}
@@ -690,7 +697,9 @@ impl CustomDebugInfoParser for PDBParser {
}
}
Ok(None) => {}
- e => error!("Error searching remote symbol server {}: {:?}", server, e),
+ e => {
+ error!("Error searching remote symbol server {}: {:?}", server, e)
+ }
}
}
}
@@ -718,7 +727,7 @@ pub extern "C" fn PDBPluginInit() -> bool {
}
fn init_plugin() -> bool {
- Logger::new("PDB").init();
+ binaryninja::tracing_init!("PDB Import");
DebugInfoParser::register("PDB", PDBParser {});
let settings = Settings::new();
diff --git a/plugins/pdb-ng/src/parser.rs b/plugins/pdb-ng/src/parser.rs
index 96a9554e..708bc34a 100644
--- a/plugins/pdb-ng/src/parser.rs
+++ b/plugins/pdb-ng/src/parser.rs
@@ -18,7 +18,6 @@ use std::fmt::Display;
use std::sync::OnceLock;
use anyhow::{anyhow, Result};
-use log::{debug, info};
use pdb::*;
use crate::symbol_parser::{ParsedDataSymbol, ParsedProcedure, ParsedSymbol};
@@ -31,6 +30,7 @@ use binaryninja::debuginfo::{DebugFunctionInfo, DebugInfo};
use binaryninja::platform::Platform;
use binaryninja::rc::Ref;
use binaryninja::settings::{QueryOptions, Settings};
+use binaryninja::tracing::{debug, info};
use binaryninja::types::{
EnumerationBuilder, NamedTypeReference, NamedTypeReferenceClass, StructureBuilder,
StructureType, Type, TypeClass,
diff --git a/plugins/pdb-ng/src/struct_grouper.rs b/plugins/pdb-ng/src/struct_grouper.rs
index 902cea08..8143ff42 100644
--- a/plugins/pdb-ng/src/struct_grouper.rs
+++ b/plugins/pdb-ng/src/struct_grouper.rs
@@ -12,16 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+use crate::type_parser::ParsedMember;
use anyhow::{anyhow, Result};
use binaryninja::confidence::{Conf, MAX_CONFIDENCE};
+use binaryninja::tracing::{debug, warn};
use binaryninja::types::{MemberAccess, MemberScope, StructureBuilder, StructureType, Type};
-use log::{debug, warn};
use std::cmp::Ordering;
use std::env;
use std::fmt::{Debug, Display, Formatter};
-use crate::type_parser::ParsedMember;
-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
struct MemberSize {
index: usize,
diff --git a/plugins/pdb-ng/src/type_parser.rs b/plugins/pdb-ng/src/type_parser.rs
index 2ea404c2..e22489a9 100644
--- a/plugins/pdb-ng/src/type_parser.rs
+++ b/plugins/pdb-ng/src/type_parser.rs
@@ -24,12 +24,12 @@ use binaryninja::calling_convention::CoreCallingConvention;
use binaryninja::confidence::{Conf, MAX_CONFIDENCE};
use binaryninja::platform::Platform;
use binaryninja::rc::Ref;
+use binaryninja::tracing::warn;
use binaryninja::types::{
BaseStructure, EnumerationBuilder, EnumerationMember, FunctionParameter, MemberAccess,
MemberScope, NamedTypeReference, NamedTypeReferenceClass, StructureBuilder, StructureMember,
StructureType, Type, TypeBuilder, TypeClass,
};
-use log::warn;
use pdb::Error::UnimplementedTypeKind;
use pdb::{
ArgumentList, ArrayType, BaseClassType, BitfieldType, ClassKind, ClassType, EnumerateType,