diff options
| author | Mason Reed <mason@vector35.com> | 2025-12-18 17:14:06 -0500 |
|---|---|---|
| committer | Mason Reed <35282038+emesare@users.noreply.github.com> | 2026-01-11 10:36:01 -0800 |
| commit | 6f75ca031aa7e8f7e1c706d1880b202137b1996f (patch) | |
| tree | 1fe8e778f98e4390a1075fc402047e23f2128934 | |
| parent | 168a3fd34824adc9c6a606cd144219701f15cccf (diff) | |
[Rust] Enter more session scoped tracing spans for debug info and binary view callbacks
67 files changed, 252 insertions, 196 deletions
@@ -135,6 +135,7 @@ dependencies = [ "binaryninja", "binaryninjacore-sys", "msp430-asm", + "tracing", ] [[package]] @@ -145,9 +146,16 @@ dependencies = [ "binaryninjacore-sys", "rayon", "riscv-dis", + "tracing", ] [[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] name = "autocfg" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -189,6 +197,7 @@ dependencies = [ "tempfile", "thiserror 2.0.12", "tracing", + "tracing-indicatif", "tracing-subscriber", ] @@ -713,6 +722,7 @@ dependencies = [ "binaryninjacore-sys", "gimli", "object 0.32.2", + "tracing", ] [[package]] @@ -728,6 +738,7 @@ dependencies = [ "iset", "object 0.36.7", "regex", + "tracing", ] [[package]] @@ -743,6 +754,7 @@ dependencies = [ "iset", "object 0.36.7", "regex", + "tracing", ] [[package]] @@ -789,29 +801,6 @@ dependencies = [ ] [[package]] -name = "env_filter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bf3c259d255ca70051b30e2e95b5446cdb8949ac4cd22c0d7fd634d89f568e2" -dependencies = [ - "log", - "regex", -] - -[[package]] -name = "env_logger" -version = "0.11.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f" -dependencies = [ - "anstream", - "anstyle", - "env_filter", - "jiff", - "log", -] - -[[package]] name = "equivalent" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -839,7 +828,7 @@ version = "0.1.0" dependencies = [ "binaryninja", "binaryninjacore-sys", - "log", + "tracing", "uuid", ] @@ -1107,6 +1096,7 @@ dependencies = [ "binaryninja", "binaryninjacore-sys", "idb-rs", + "tracing", ] [[package]] @@ -1148,6 +1138,7 @@ dependencies = [ "portable-atomic", "unicode-width", "unit-prefix", + "vt100", "web-time", ] @@ -1209,30 +1200,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] -name = "jiff" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be1f93b8b1eb69c77f24bbb0afdf66f54b632ee39af40ca21c4365a1d7347e49" -dependencies = [ - "jiff-static", - "log", - "portable-atomic", - "portable-atomic-util", - "serde", -] - -[[package]] -name = "jiff-static" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03343451ff899767262ec32146f6d559dd759fdadf42ff0e227c7c48f72594b4" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] name = "jobserver" version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1375,6 +1342,7 @@ dependencies = [ "binaryninja", "binaryninjacore-sys", "minidump", + "tracing", ] [[package]] @@ -1437,6 +1405,15 @@ dependencies = [ ] [[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] name = "num-conv" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1649,6 +1626,7 @@ dependencies = [ "itertools 0.14.0", "pdb", "regex", + "tracing", ] [[package]] @@ -1661,6 +1639,7 @@ dependencies = [ "itertools 0.14.0", "pdb", "regex", + "tracing", ] [[package]] @@ -1735,15 +1714,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" [[package]] -name = "portable-atomic-util" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" -dependencies = [ - "portable-atomic", -] - -[[package]] name = "powerfmt" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2290,6 +2260,7 @@ dependencies = [ "insta", "serde_json", "svd-parser", + "tracing", ] [[package]] @@ -2301,6 +2272,7 @@ dependencies = [ "insta", "serde_json", "svd-parser", + "tracing", ] [[package]] @@ -2485,6 +2457,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a04e24fab5c89c6a36eb8558c9656f30d81de51dfa4d3b45f26b21d61fa0a6c" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-indicatif" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04d4e11e0e27acef25a47f27e9435355fecdc488867fa2bc90e75b0700d2823d" +dependencies = [ + "indicatif", + "tracing", + "tracing-core", + "tracing-subscriber", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", ] [[package]] @@ -2493,11 +2489,13 @@ version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" dependencies = [ + "nu-ansi-term", "parking_lot", "sharded-slab", "smallvec", "thread_local", "tracing-core", + "tracing-log", ] [[package]] @@ -2548,12 +2546,39 @@ dependencies = [ ] [[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[package]] name = "version_check" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] +name = "vt100" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "054ff75fb8fa83e609e685106df4faeffdf3a735d3c74ebce97ec557d5d36fd9" +dependencies = [ + "itoa", + "unicode-width", + "vte", +] + +[[package]] +name = "vte" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5924018406ce0063cd67f8e008104968b74b563ee1b85dde3ed1f7cb87d3dbd" +dependencies = [ + "arrayvec", + "memchr", +] + +[[package]] name = "walkdir" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2595,9 +2620,9 @@ dependencies = [ "binaryninjacore-sys", "clap", "ctrlc", - "env_logger", - "indicatif", - "log", + "tracing", + "tracing-indicatif", + "tracing-subscriber", "warp_ninja", ] @@ -2625,6 +2650,7 @@ dependencies = [ "serde_qs", "tempdir", "thiserror 2.0.12", + "tracing", "uuid", "walkdir", "warp 1.0.1", @@ -2654,6 +2680,7 @@ dependencies = [ "serde_qs", "tempdir", "thiserror 2.0.12", + "tracing", "uuid", "walkdir", "warp 1.0.0", @@ -3035,6 +3062,7 @@ dependencies = [ "dashmap", "once_cell", "thiserror 2.0.12", + "tracing", ] [[package]] @@ -3045,9 +3073,9 @@ dependencies = [ "binaryninjacore-sys", "bstr", "dashmap", - "log", "once_cell", "thiserror 2.0.12", + "tracing", ] [[package]] diff --git a/arch/msp430/Cargo.toml b/arch/msp430/Cargo.toml index 3e0d34fe..d5bcc31e 100644 --- a/arch/msp430/Cargo.toml +++ b/arch/msp430/Cargo.toml @@ -9,6 +9,7 @@ license = "Apache-2.0" binaryninja.workspace = true binaryninjacore-sys.workspace = true msp430-asm = "^0.2" +tracing = "0.1" [lib] crate-type = ["cdylib"] diff --git a/arch/msp430/src/architecture.rs b/arch/msp430/src/architecture.rs index 996d3c4a..244c6b07 100644 --- a/arch/msp430/src/architecture.rs +++ b/arch/msp430/src/architecture.rs @@ -8,7 +8,7 @@ use binaryninja::{ UnusedIntrinsic, UnusedRegisterStack, }, disassembly::{InstructionTextToken, InstructionTextTokenKind}, - tracing, Endianness, + Endianness, }; use msp430_asm::{ diff --git a/arch/msp430/src/lift.rs b/arch/msp430/src/lift.rs index 480b150b..0630b18b 100644 --- a/arch/msp430/src/lift.rs +++ b/arch/msp430/src/lift.rs @@ -2,7 +2,7 @@ use crate::architecture::offset_to_absolute; use crate::flag::{Flag, FlagWrite}; use crate::register::Register; -use binaryninja::{architecture::FlagCondition, low_level_il::lifting::LowLevelILLabel, tracing}; +use binaryninja::{architecture::FlagCondition, low_level_il::lifting::LowLevelILLabel}; use msp430_asm::emulate::Emulated; use msp430_asm::instruction::Instruction; diff --git a/arch/riscv/Cargo.toml b/arch/riscv/Cargo.toml index e247b301..d5ab661e 100644 --- a/arch/riscv/Cargo.toml +++ b/arch/riscv/Cargo.toml @@ -10,6 +10,7 @@ binaryninja.workspace = true binaryninjacore-sys.workspace = true riscv-dis = { path = "disasm" } rayon = { version = "1.0", optional = true } +tracing = "0.1" [features] default = [] diff --git a/arch/riscv/src/lib.rs b/arch/riscv/src/lib.rs index 1ebe7fb4..1f822524 100644 --- a/arch/riscv/src/lib.rs +++ b/arch/riscv/src/lib.rs @@ -26,7 +26,6 @@ use binaryninja::{ RelocationType, }, symbol::{Symbol, SymbolType}, - tracing, types::{NameAndType, Type}, }; use std::borrow::Cow; diff --git a/plugins/dwarf/dwarf_export/Cargo.toml b/plugins/dwarf/dwarf_export/Cargo.toml index 81c8a017..74cd774e 100644 --- a/plugins/dwarf/dwarf_export/Cargo.toml +++ b/plugins/dwarf/dwarf_export/Cargo.toml @@ -12,3 +12,4 @@ binaryninja.workspace = true binaryninjacore-sys.workspace = true gimli = "^0.31" object = { version = "0.32.1", features = ["write"] } +tracing = "0.1"
\ No newline at end of file diff --git a/plugins/dwarf/dwarf_export/src/lib.rs b/plugins/dwarf/dwarf_export/src/lib.rs index bc7d3c27..284ca34b 100644 --- a/plugins/dwarf/dwarf_export/src/lib.rs +++ b/plugins/dwarf/dwarf_export/src/lib.rs @@ -7,7 +7,6 @@ use binaryninja::{ confidence::Conf, rc::Ref, symbol::SymbolType, - tracing, types::{MemberAccess, StructureType, Type, TypeClass}, }; use gimli::{ diff --git a/plugins/dwarf/dwarf_import/Cargo.toml b/plugins/dwarf/dwarf_import/Cargo.toml index f71d4cf4..d01c60b1 100644 --- a/plugins/dwarf/dwarf_import/Cargo.toml +++ b/plugins/dwarf/dwarf_import/Cargo.toml @@ -20,3 +20,4 @@ cpp_demangle = "0.4.3" regex = "1" indexmap = "2.5.0" object = "0.36" +tracing = "0.1" diff --git a/plugins/dwarf/dwarf_import/demo/Cargo.toml b/plugins/dwarf/dwarf_import/demo/Cargo.toml index 3a5ad601..d4418edd 100644 --- a/plugins/dwarf/dwarf_import/demo/Cargo.toml +++ b/plugins/dwarf/dwarf_import/demo/Cargo.toml @@ -21,3 +21,4 @@ cpp_demangle = "0.4.3" regex = "1" indexmap = "2.5.0" object = "0.36" +tracing = "0.1"
\ No newline at end of file diff --git a/plugins/dwarf/dwarf_import/src/die_handlers.rs b/plugins/dwarf/dwarf_import/src/die_handlers.rs index b4b526a0..cf81b698 100644 --- a/plugins/dwarf/dwarf_import/src/die_handlers.rs +++ b/plugins/dwarf/dwarf_import/src/die_handlers.rs @@ -18,7 +18,6 @@ use crate::{helpers::*, ReaderType}; use binaryninja::{ rc::*, - tracing, types::{EnumerationBuilder, FunctionParameter, ReferenceType, Type, TypeBuilder}, }; diff --git a/plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs b/plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs index 397e07a3..fbf7e7df 100644 --- a/plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs +++ b/plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs @@ -25,7 +25,6 @@ use binaryninja::{ rc::*, symbol::SymbolType, template_simplifier::simplify_str_to_fqn, - tracing, types::{FunctionParameter, Type}, variable::NamedVariableWithType, }; diff --git a/plugins/dwarf/dwarf_import/src/functions.rs b/plugins/dwarf/dwarf_import/src/functions.rs index 709cea62..6755f847 100644 --- a/plugins/dwarf/dwarf_import/src/functions.rs +++ b/plugins/dwarf/dwarf_import/src/functions.rs @@ -19,7 +19,6 @@ use crate::types::get_type; use crate::{helpers::*, ReaderType}; use binaryninja::template_simplifier::simplify_str_to_str; -use binaryninja::tracing; use cpp_demangle::DemangleOptions; use gimli::{constants, AttributeValue, DebuggingInformationEntry, Dwarf, Operation, Unit}; use regex::Regex; diff --git a/plugins/dwarf/dwarf_import/src/helpers.rs b/plugins/dwarf/dwarf_import/src/helpers.rs index d2654d98..c7855b25 100644 --- a/plugins/dwarf/dwarf_import/src/helpers.rs +++ b/plugins/dwarf/dwarf_import/src/helpers.rs @@ -18,12 +18,12 @@ use std::{str::FromStr, sync::mpsc}; use crate::{DebugInfoBuilderContext, ReaderType}; use binaryninja::binary_view::BinaryViewBase; +use binaryninja::Endianness; use binaryninja::{ binary_view::{BinaryView, BinaryViewExt}, download::{DownloadInstanceInputOutputCallbacks, DownloadProvider}, settings::Settings, }; -use binaryninja::{tracing, Endianness}; use gimli::Dwarf; use gimli::{ constants, Attribute, AttributeValue, diff --git a/plugins/dwarf/dwarf_import/src/lib.rs b/plugins/dwarf/dwarf_import/src/lib.rs index e227a459..1ed3ce19 100644 --- a/plugins/dwarf/dwarf_import/src/lib.rs +++ b/plugins/dwarf/dwarf_import/src/lib.rs @@ -34,7 +34,6 @@ use binaryninja::{ debuginfo::{CustomDebugInfoParser, DebugInfo, DebugInfoParser}, settings::Settings, template_simplifier::simplify_str_to_str, - tracing, }; use dwarfreader::create_section_reader_object; diff --git a/plugins/dwarf/dwarf_import/src/types.rs b/plugins/dwarf/dwarf_import/src/types.rs index 45ccf74e..cb8880ec 100644 --- a/plugins/dwarf/dwarf_import/src/types.rs +++ b/plugins/dwarf/dwarf_import/src/types.rs @@ -18,7 +18,6 @@ use crate::{die_handlers::*, ReaderType}; use binaryninja::{ rc::*, - tracing, types::{ BaseStructure, MemberAccess, MemberScope, ReferenceType, StructureBuilder, StructureType, Type, TypeClass, diff --git a/plugins/idb_import/Cargo.toml b/plugins/idb_import/Cargo.toml index 4a958106..9ba241d2 100644 --- a/plugins/idb_import/Cargo.toml +++ b/plugins/idb_import/Cargo.toml @@ -13,3 +13,4 @@ anyhow = { version = "1.0.86", features = ["backtrace"] } binaryninja.workspace = true binaryninjacore-sys.workspace = true idb-rs = { git = "https://github.com/Vector35/idb-rs", tag = "0.1.12" } +tracing = "0.1"
\ No newline at end of file diff --git a/plugins/idb_import/src/lib.rs b/plugins/idb_import/src/lib.rs index 3564df11..f285f554 100644 --- a/plugins/idb_import/src/lib.rs +++ b/plugins/idb_import/src/lib.rs @@ -19,7 +19,6 @@ use idb_rs::til::section::TILSection; use idb_rs::til::TypeVariant as TILTypeVariant; use anyhow::{anyhow, Result}; -use binaryninja::tracing; struct IDBDebugInfoParser; impl CustomDebugInfoParser for IDBDebugInfoParser { diff --git a/plugins/pdb-ng/Cargo.toml b/plugins/pdb-ng/Cargo.toml index e77dac5b..08776df2 100644 --- a/plugins/pdb-ng/Cargo.toml +++ b/plugins/pdb-ng/Cargo.toml @@ -14,6 +14,7 @@ binaryninjacore-sys.workspace = true itertools = "0.14" pdb = { git = "https://github.com/Vector35/pdb-rs", rev = "6016177" } regex = "1" +tracing = "0.1" [features] demo = []
\ No newline at end of file diff --git a/plugins/pdb-ng/demo/Cargo.toml b/plugins/pdb-ng/demo/Cargo.toml index bde9b28c..590cacca 100644 --- a/plugins/pdb-ng/demo/Cargo.toml +++ b/plugins/pdb-ng/demo/Cargo.toml @@ -15,6 +15,7 @@ binaryninjacore-sys.workspace = true itertools = "0.14" pdb = { git = "https://github.com/Vector35/pdb-rs", rev = "6016177" } regex = "1" +tracing = "0.1" [features] demo = [] diff --git a/plugins/pdb-ng/src/lib.rs b/plugins/pdb-ng/src/lib.rs index 5bbbb53e..86ae1cdd 100644 --- a/plugins/pdb-ng/src/lib.rs +++ b/plugins/pdb-ng/src/lib.rs @@ -28,7 +28,6 @@ use binaryninja::debuginfo::{CustomDebugInfoParser, DebugInfo, DebugInfoParser}; use binaryninja::download::{DownloadInstanceInputOutputCallbacks, DownloadProvider}; use binaryninja::interaction::{MessageBoxButtonResult, MessageBoxButtonSet}; use binaryninja::settings::{QueryOptions, Settings}; -use binaryninja::tracing::{debug, error, info}; use binaryninja::{interaction, user_directory}; use parser::PDBParserInstance; @@ -162,7 +161,7 @@ fn parse_sym_srv(symbol_path: &str, default_store: String) -> Result<impl Iterat fn read_from_sym_store(bv: &BinaryView, path: &str) -> Result<(bool, Vec<u8>)> { if !path.contains("://") { // Local file - info!("Read local file: {}", path); + tracing::info!("Read local file: {}", path); let conts = fs::read(path)?; return Ok((false, conts)); } @@ -182,7 +181,7 @@ fn read_from_sym_store(bv: &BinaryView, path: &str) -> Result<(bool, Vec<u8>)> { } }; - info!("GET: {}", path); + tracing::info!("GET: {}", path); let dp = DownloadProvider::try_default().map_err(|_| anyhow!("No default download provider"))?; @@ -397,9 +396,9 @@ impl PDBParser { if info.age != pdb_info.age { if info.age > pdb_info.age { // Have not seen this case, so I'm not sure if this is fatal - info!("PDB age is older than our binary! Loading it anyway, but there may be missing information."); + tracing::info!("PDB age is older than our binary! Loading it anyway, but there may be missing information."); } else { - info!("PDB age is newer than our binary! Loading it anyway, there probably shouldn't be any issues."); + tracing::info!("PDB age is newer than our binary! Loading it anyway, there probably shouldn't be any issues."); } } @@ -424,7 +423,7 @@ impl PDBParser { match fs::create_dir_all(&cab_path) { Ok(_) => true, Err(e) => { - error!("Could not create PDB cache dir: {}", e); + tracing::error!("Could not create PDB cache dir: {}", e); false } } @@ -433,10 +432,10 @@ impl PDBParser { cab_path.push(&info.file_name); match fs::write(&cab_path, conts) { Ok(_) => { - info!("Downloaded to: {}", cab_path.to_string_lossy()); + tracing::info!("Downloaded to: {}", cab_path.to_string_lossy()); } Err(e) => { - error!("Could not write PDB to cache: {}", e) + tracing::error!("Could not write PDB to cache: {}", e) } } } @@ -461,7 +460,7 @@ impl PDBParser { match fs::create_dir_all(&cab_path) { Ok(_) => true, Err(e) => { - error!("Could not create PDB cache dir: {}", e); + tracing::error!("Could not create PDB cache dir: {}", e); false } } @@ -470,16 +469,19 @@ impl PDBParser { cab_path.push(&info.file_name); match fs::write(&cab_path, conts) { Ok(_) => { - info!("Downloaded to: {}", cab_path.to_string_lossy()); + tracing::info!( + "Downloaded to: {}", + cab_path.to_string_lossy() + ); } Err(e) => { - error!("Could not write PDB to cache: {}", e) + tracing::error!("Could not write PDB to cache: {}", e) } } } } } - Err(e) => error!("Could not get local cache for writing: {}", e), + Err(e) => tracing::error!("Could not get local cache for writing: {}", e), } } } else { @@ -512,11 +514,11 @@ impl PDBParser { let mut inst = match PDBParserInstance::new(debug_info, view, pdb) { Ok(inst) => { - info!("Loaded PDB, parsing..."); + tracing::info!("Loaded PDB, parsing..."); inst } Err(e) => { - error!("Could not open PDB: {}", e); + tracing::error!("Could not open PDB: {}", e); return Err(e); } }; @@ -524,11 +526,11 @@ impl PDBParser { (*progress)(cur, max).map_err(|_| anyhow!("Cancelled")) })) { Ok(()) => { - info!("Parsed pdb"); + tracing::info!("Parsed pdb"); Ok(()) } Err(e) => { - error!("Could not parse PDB: {}", e); + tracing::error!("Could not parse PDB: {}", e); if e.to_string() == "Todo" { Ok(()) } else { @@ -563,7 +565,7 @@ impl CustomDebugInfoParser for PDBParser { Ok(_) => return true, Err(e) if e.to_string() == "Cancelled" => return false, Err(_) => { - error!("Chosen PDB file failed to load"); + tracing::error!("Chosen PDB file failed to load"); return false; } } @@ -587,12 +589,12 @@ impl CustomDebugInfoParser for PDBParser { { Ok(_) => return true, Err(e) if e.to_string() == "Cancelled" => return false, - Err(e) => debug!("Skipping, {}", e.to_string()), + Err(e) => tracing::debug!("Skipping, {}", e.to_string()), } } Ok(None) => {} e => { - error!("Error searching symbol store {}: {:?}", store, e) + tracing::error!("Error searching symbol store {}: {:?}", store, e) } } } @@ -607,10 +609,10 @@ impl CustomDebugInfoParser for PDBParser { { Ok(_) => return true, Err(e) if e.to_string() == "Cancelled" => return false, - Err(e) => debug!("Skipping, {}", e.to_string()), + Err(e) => tracing::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) => tracing::debug!("Could not read pdb: {}", e.to_string()), } } @@ -625,10 +627,10 @@ impl CustomDebugInfoParser for PDBParser { { Ok(_) => return true, Err(e) if e.to_string() == "Cancelled" => return false, - Err(e) => debug!("Skipping, {}", e.to_string()), + Err(e) => tracing::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) => tracing::debug!("Could not read pdb: {}", e.to_string()), } } @@ -651,11 +653,11 @@ impl CustomDebugInfoParser for PDBParser { ) { Ok(_) => return true, Err(e) if e.to_string() == "Cancelled" => return false, - Err(e) => debug!("Skipping, {}", e.to_string()), + Err(e) => tracing::debug!("Skipping, {}", e.to_string()), }, Err(e) if e.to_string() == "Cancelled" => return false, Err(e) => { - debug!("Could not read pdb: {}", e.to_string()) + tracing::debug!("Could not read pdb: {}", e.to_string()) } } } @@ -671,13 +673,14 @@ impl CustomDebugInfoParser for PDBParser { { Ok(_) => return true, Err(e) if e.to_string() == "Cancelled" => return false, - Err(e) => debug!("Skipping, {}", e.to_string()), + Err(e) => tracing::debug!("Skipping, {}", e.to_string()), } } Ok(None) => {} - e => error!( + e => tracing::error!( "Error searching local symbol store {}: {:?}", - local_store_path, e + local_store_path, + e ), } } @@ -693,12 +696,12 @@ impl CustomDebugInfoParser for PDBParser { match self.load_from_file(&conts, debug_info, view, &progress, true, true) { Ok(_) => return true, Err(e) if e.to_string() == "Cancelled" => return false, - Err(e) => debug!("Skipping, {}", e.to_string()), + Err(e) => tracing::debug!("Skipping, {}", e.to_string()), } } Ok(None) => {} e => { - error!("Error searching remote symbol server {}: {:?}", server, e) + tracing::error!("Error searching remote symbol server {}: {:?}", server, e) } } } diff --git a/plugins/pdb-ng/src/parser.rs b/plugins/pdb-ng/src/parser.rs index 708bc34a..82a2bd75 100644 --- a/plugins/pdb-ng/src/parser.rs +++ b/plugins/pdb-ng/src/parser.rs @@ -30,7 +30,6 @@ 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, @@ -172,7 +171,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> { .add_type(&name.to_string(), ty.as_ref(), &[]); // TODO : Components } - info!( + tracing::info!( "PDB found {} types (before resolving NTRs)", self.named_types.len() ); @@ -198,9 +197,9 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> { )?; } - info!("PDB found {} types", self.named_types.len()); - info!("PDB found {} data variables", symbols.len()); - info!("PDB found {} functions", functions.len()); + tracing::info!("PDB found {} types", self.named_types.len()); + tracing::info!("PDB found {} data variables", symbols.len()); + tracing::info!("PDB found {} functions", functions.len()); let allow_void = self.settings.get_bool_with_opts( "pdb.features.allowVoidGlobals", @@ -462,7 +461,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> { if *debug_pdb { let space = "\t".repeat(self.type_stack.len()) + &"\t".repeat(self.symbol_stack.len()); let msg = format!("{}", msg()); - debug!( + tracing::debug!( "{}{}", space, msg.replace("\n", &("\n".to_string() + &space)) diff --git a/plugins/pdb-ng/src/struct_grouper.rs b/plugins/pdb-ng/src/struct_grouper.rs index 8143ff42..378d8c3b 100644 --- a/plugins/pdb-ng/src/struct_grouper.rs +++ b/plugins/pdb-ng/src/struct_grouper.rs @@ -15,7 +15,6 @@ 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 std::cmp::Ordering; use std::env; @@ -358,7 +357,7 @@ pub fn group_structure( apply_groups(members, structure, groups, 0); } Err(e) => { - warn!("{} Could not resolve structure groups: {}", name, e); + tracing::warn!("{} Could not resolve structure groups: {}", name, e); for member in members { match (member.bitfield_position, member.bitfield_size) { (Some(bit_pos), bit_width) => { @@ -1189,6 +1188,6 @@ fn test_bool_modifier() { fn log<F: FnOnce() -> D, D: Display>(msg: F) { // println!("{}", msg()); if env::var("BN_DEBUG_PDB").is_ok() { - debug!("{}", msg()); + tracing::debug!("{}", msg()); } } diff --git a/plugins/pdb-ng/src/type_parser.rs b/plugins/pdb-ng/src/type_parser.rs index e22489a9..2ab2a0cc 100644 --- a/plugins/pdb-ng/src/type_parser.rs +++ b/plugins/pdb-ng/src/type_parser.rs @@ -24,7 +24,6 @@ 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, @@ -556,7 +555,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> { if let Some(_old) = self.named_types.insert(name.clone(), parsed.clone()) { - warn!("Found two types both named `{}`, only one will be used.", name); + tracing::warn!("Found two types both named `{}`, only one will be used.", name); } } } @@ -570,7 +569,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> { } } Err(UnimplementedTypeKind(k)) if k != 0 => { - warn!("Not parsing unimplemented type {}: kind {:x?}", ty, k); + tracing::warn!("Not parsing unimplemented type {}: kind {:x?}", ty, k); } Err(e) => { self.log(|| format!("Could not parse type: {}: {}", ty, e)); @@ -921,7 +920,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> { *base_offset, base_type.width(), )); - warn!( + tracing::warn!( "Class `{}` uses virtual inheritance. Type information may be inaccurate.", self.namespace_stack .last() @@ -933,7 +932,7 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> { } if bases.len() > 1 { - warn!( + tracing::warn!( "Class `{}` has multiple base classes. Type information may be inaccurate.", self.namespace_stack .last() diff --git a/plugins/svd/Cargo.toml b/plugins/svd/Cargo.toml index cd368585..e4cdc5d8 100644 --- a/plugins/svd/Cargo.toml +++ b/plugins/svd/Cargo.toml @@ -12,6 +12,7 @@ binaryninja.workspace = true binaryninjacore-sys.workspace = true svd-parser = { version = "0.14.8", features = ["expand"] } serde_json = "1.0" +tracing = "0.1" [dev-dependencies] insta = { version = "1.42", features = ["yaml"] } diff --git a/plugins/svd/demo/Cargo.toml b/plugins/svd/demo/Cargo.toml index 811f7d08..b7147574 100644 --- a/plugins/svd/demo/Cargo.toml +++ b/plugins/svd/demo/Cargo.toml @@ -13,6 +13,7 @@ binaryninja = { workspace = true, features = ["demo"]} binaryninjacore-sys.workspace = true svd-parser = { version = "0.14.8", features = ["expand"] } serde_json = "1.0" +tracing = "0.1" [dev-dependencies] insta = { version = "1.42", features = ["yaml"] } diff --git a/plugins/svd/src/lib.rs b/plugins/svd/src/lib.rs index 396a9447..6ada01f9 100644 --- a/plugins/svd/src/lib.rs +++ b/plugins/svd/src/lib.rs @@ -6,7 +6,6 @@ use crate::settings::LoadSettings; use binaryninja::binary_view::{BinaryView, BinaryViewBase, BinaryViewExt}; use binaryninja::command::Command; use binaryninja::interaction::{Form, FormInputField}; -use binaryninja::tracing; use binaryninja::workflow::{activity, Activity, AnalysisContext, Workflow}; use std::path::PathBuf; use svd_parser::ValidateLevel; diff --git a/plugins/svd/src/mapper.rs b/plugins/svd/src/mapper.rs index 2c09eb95..8f4abe47 100644 --- a/plugins/svd/src/mapper.rs +++ b/plugins/svd/src/mapper.rs @@ -6,7 +6,6 @@ use binaryninja::rc::Ref; use binaryninja::section::{SectionBuilder, Semantics}; use binaryninja::segment::{SegmentBuilder, SegmentFlags}; use binaryninja::symbol::{SymbolBuilder, SymbolType}; -use binaryninja::tracing; use binaryninja::types::{ BaseStructure, EnumerationBuilder, MemberAccess, MemberScope, NamedTypeReference, NamedTypeReferenceClass, StructureBuilder, StructureMember, Type, TypeBuilder, diff --git a/plugins/warp/Cargo.toml b/plugins/warp/Cargo.toml index 79f7632f..3a623e0a 100644 --- a/plugins/warp/Cargo.toml +++ b/plugins/warp/Cargo.toml @@ -11,6 +11,7 @@ crate-type = ["lib", "cdylib"] demo = [] [dependencies] +tracing = "0.1" binaryninja = { workspace = true, features = ["rayon"] } binaryninjacore-sys.workspace = true warp = { git = "https://github.com/Vector35/warp/", tag = "1.0.1" } diff --git a/plugins/warp/demo/Cargo.toml b/plugins/warp/demo/Cargo.toml index 50664483..662b4131 100644 --- a/plugins/warp/demo/Cargo.toml +++ b/plugins/warp/demo/Cargo.toml @@ -12,6 +12,7 @@ path = "../src/lib.rs" demo = [] [dependencies] +tracing = "0.1" binaryninja = { workspace = true, features = ["rayon", "demo"] } binaryninjacore-sys.workspace = true warp = { git = "https://github.com/Vector35/warp/", tag = "1.0.0" } diff --git a/plugins/warp/src/cache.rs b/plugins/warp/src/cache.rs index 30c7487c..41aab423 100644 --- a/plugins/warp/src/cache.rs +++ b/plugins/warp/src/cache.rs @@ -11,7 +11,7 @@ use binaryninja::binary_view::{BinaryView, BinaryViewExt}; use binaryninja::function::Function as BNFunction; use binaryninja::rc::Guard; use binaryninja::rc::Ref as BNRef; -use binaryninja::{tracing, ObjectDestructor}; +use binaryninja::ObjectDestructor; use std::hash::{DefaultHasher, Hash, Hasher}; pub fn register_cache_destructor() { diff --git a/plugins/warp/src/container/disk.rs b/plugins/warp/src/container/disk.rs index 5e4a5613..6e296ea1 100644 --- a/plugins/warp/src/container/disk.rs +++ b/plugins/warp/src/container/disk.rs @@ -1,7 +1,6 @@ use crate::container::{ Container, ContainerError, ContainerResult, SourceId, SourcePath, SourceTag, }; -use binaryninja::tracing; use std::collections::{HashMap, HashSet}; use std::fmt::{Debug, Display, Formatter}; use std::hash::{Hash, Hasher}; diff --git a/plugins/warp/src/container/network.rs b/plugins/warp/src/container/network.rs index 0908b103..0ba515f9 100644 --- a/plugins/warp/src/container/network.rs +++ b/plugins/warp/src/container/network.rs @@ -3,7 +3,6 @@ use crate::container::{ Container, ContainerError, ContainerResult, ContainerSearchQuery, ContainerSearchResponse, SourceId, SourcePath, SourceTag, }; -use binaryninja::tracing; use directories::ProjectDirs; use std::collections::{HashMap, HashSet}; use std::fmt::{Debug, Display, Formatter}; diff --git a/plugins/warp/src/container/network/client.rs b/plugins/warp/src/container/network/client.rs index d3c94d1a..0b772dcc 100644 --- a/plugins/warp/src/container/network/client.rs +++ b/plugins/warp/src/container/network/client.rs @@ -5,7 +5,6 @@ use crate::container::{ }; use base64::Engine; use binaryninja::download::DownloadProvider; -use binaryninja::tracing; use serde::Deserialize; use serde_json::json; use std::collections::HashMap; diff --git a/plugins/warp/src/convert/types.rs b/plugins/warp/src/convert/types.rs index 227df2ea..8421eb5e 100644 --- a/plugins/warp/src/convert/types.rs +++ b/plugins/warp/src/convert/types.rs @@ -6,7 +6,6 @@ use binaryninja::calling_convention::CoreCallingConvention as BNCallingConventio use binaryninja::confidence::Conf as BNConf; use binaryninja::confidence::MAX_CONFIDENCE; use binaryninja::rc::Ref as BNRef; -use binaryninja::tracing; use binaryninja::types::BaseStructure as BNBaseStructure; use binaryninja::types::EnumerationBuilder as BNEnumerationBuilder; use binaryninja::types::FunctionParameter as BNFunctionParameter; diff --git a/plugins/warp/src/plugin.rs b/plugins/warp/src/plugin.rs index dec62c2f..cb527fff 100644 --- a/plugins/warp/src/plugin.rs +++ b/plugins/warp/src/plugin.rs @@ -12,8 +12,8 @@ use binaryninja::background_task::BackgroundTask; use binaryninja::command::{ register_command, register_command_for_function, register_command_for_project, }; +use binaryninja::is_ui_enabled; use binaryninja::settings::{QueryOptions, Settings}; -use binaryninja::{is_ui_enabled, tracing}; mod commit; mod create; diff --git a/plugins/warp/src/plugin/commit.rs b/plugins/warp/src/plugin/commit.rs index 56a78f9a..d98a356a 100644 --- a/plugins/warp/src/plugin/commit.rs +++ b/plugins/warp/src/plugin/commit.rs @@ -6,7 +6,6 @@ use crate::plugin::create::OpenFileField; use binaryninja::binary_view::BinaryView; use binaryninja::command::Command; use binaryninja::interaction::{Form, FormInputField}; -use binaryninja::tracing; use warp::chunk::ChunkKind; use warp::WarpFile; diff --git a/plugins/warp/src/plugin/create.rs b/plugins/warp/src/plugin/create.rs index 04a3e9b6..0c6a2fd5 100644 --- a/plugins/warp/src/plugin/create.rs +++ b/plugins/warp/src/plugin/create.rs @@ -10,7 +10,6 @@ use binaryninja::command::Command; use binaryninja::interaction::form::{Form, FormInputField}; use binaryninja::interaction::{MessageBoxButtonResult, MessageBoxButtonSet, MessageBoxIcon}; use binaryninja::rc::Ref; -use binaryninja::tracing; use std::path::PathBuf; use std::thread; use warp::chunk::Chunk; diff --git a/plugins/warp/src/plugin/debug.rs b/plugins/warp/src/plugin/debug.rs index 6db491e2..d220d329 100644 --- a/plugins/warp/src/plugin/debug.rs +++ b/plugins/warp/src/plugin/debug.rs @@ -3,7 +3,7 @@ use crate::{build_function, cache}; use binaryninja::binary_view::BinaryView; use binaryninja::command::{Command, FunctionCommand}; use binaryninja::function::Function; -use binaryninja::{tracing, ObjectDestructor}; +use binaryninja::ObjectDestructor; pub struct DebugFunction; diff --git a/plugins/warp/src/plugin/ffi/container.rs b/plugins/warp/src/plugin/ffi/container.rs index 6c2551c1..2376ef10 100644 --- a/plugins/warp/src/plugin/ffi/container.rs +++ b/plugins/warp/src/plugin/ffi/container.rs @@ -10,7 +10,6 @@ use binaryninja::architecture::CoreArchitecture; use binaryninja::binary_view::BinaryView; use binaryninja::rc::Ref; use binaryninja::string::BnString; -use binaryninja::tracing; use binaryninja::types::Type; use binaryninjacore_sys::{BNArchitecture, BNBinaryView, BNType}; use std::ffi::{c_char, CStr}; diff --git a/plugins/warp/src/plugin/file.rs b/plugins/warp/src/plugin/file.rs index 899e3f46..cd5fb626 100644 --- a/plugins/warp/src/plugin/file.rs +++ b/plugins/warp/src/plugin/file.rs @@ -1,7 +1,6 @@ use crate::report::ReportGenerator; use binaryninja::binary_view::{BinaryView, BinaryViewExt}; use binaryninja::command::Command; -use binaryninja::tracing; pub struct ShowFileReport; diff --git a/plugins/warp/src/plugin/function.rs b/plugins/warp/src/plugin/function.rs index 3c0dc06c..36db7d55 100644 --- a/plugins/warp/src/plugin/function.rs +++ b/plugins/warp/src/plugin/function.rs @@ -10,7 +10,6 @@ use binaryninja::binary_view::{BinaryView, BinaryViewExt}; use binaryninja::command::{Command, FunctionCommand}; use binaryninja::function::{Function, FunctionUpdateType}; use binaryninja::rc::Guard; -use binaryninja::tracing; use rayon::iter::ParallelIterator; use std::thread; use warp::signature::function::FunctionGUID; diff --git a/plugins/warp/src/plugin/load.rs b/plugins/warp/src/plugin/load.rs index bd0e4838..2be473d8 100644 --- a/plugins/warp/src/plugin/load.rs +++ b/plugins/warp/src/plugin/load.rs @@ -10,7 +10,6 @@ use binaryninja::interaction::{ MessageBoxIcon, }; use binaryninja::rc::Ref; -use binaryninja::tracing; use std::collections::HashMap; use std::path::PathBuf; use std::sync::atomic::AtomicBool; diff --git a/plugins/warp/src/plugin/project.rs b/plugins/warp/src/plugin/project.rs index 8862c00a..b6081c1f 100644 --- a/plugins/warp/src/plugin/project.rs +++ b/plugins/warp/src/plugin/project.rs @@ -9,7 +9,6 @@ use binaryninja::interaction::{Form, FormInputField}; use binaryninja::project::folder::ProjectFolder; use binaryninja::project::Project; use binaryninja::rc::Ref; -use binaryninja::tracing; use binaryninja::worker_thread::{set_worker_thread_count, worker_thread_count}; use rayon::ThreadPoolBuilder; use regex::Regex; diff --git a/plugins/warp/src/plugin/workflow.rs b/plugins/warp/src/plugin/workflow.rs index a51c7399..1f4ef101 100644 --- a/plugins/warp/src/plugin/workflow.rs +++ b/plugins/warp/src/plugin/workflow.rs @@ -15,7 +15,6 @@ use binaryninja::command::Command; use binaryninja::function::Function as BNFunction; use binaryninja::rc::Ref as BNRef; use binaryninja::settings::{QueryOptions, Settings}; -use binaryninja::tracing; use binaryninja::workflow::{activity, Activity, AnalysisContext, Workflow, WorkflowBuilder}; use dashmap::DashSet; use itertools::Itertools; diff --git a/plugins/warp/src/processor.rs b/plugins/warp/src/processor.rs index 3076ddca..e21a2efd 100644 --- a/plugins/warp/src/processor.rs +++ b/plugins/warp/src/processor.rs @@ -29,7 +29,6 @@ use binaryninja::rc::{Guard, Ref}; use crate::cache::cached_type_references; use crate::convert::platform_to_target; use crate::{build_function, INCLUDE_TAG_ICON, INCLUDE_TAG_NAME}; -use binaryninja::tracing; use warp::chunk::{Chunk, ChunkKind, CompressionType}; use warp::r#type::chunk::TypeChunk; use warp::signature::chunk::SignatureChunk; diff --git a/plugins/workflow_objc/Cargo.toml b/plugins/workflow_objc/Cargo.toml index da8ae2c6..948fc2de 100644 --- a/plugins/workflow_objc/Cargo.toml +++ b/plugins/workflow_objc/Cargo.toml @@ -17,3 +17,4 @@ dashmap = { version = "6.1", features = ["rayon"]} once_cell = "1.20" thiserror = "2.0" bstr = "1.12" +tracing = "0.1"
\ No newline at end of file diff --git a/plugins/workflow_objc/demo/Cargo.toml b/plugins/workflow_objc/demo/Cargo.toml index bb7f41fa..449abee0 100644 --- a/plugins/workflow_objc/demo/Cargo.toml +++ b/plugins/workflow_objc/demo/Cargo.toml @@ -14,8 +14,8 @@ demo = [] [dependencies] binaryninja = { workspace = true, features = ["demo"] } binaryninjacore-sys.workspace = true -log = "0.4" dashmap = { version = "6.1", features = ["rayon"]} once_cell = "1.20" thiserror = "2.0" bstr = "1.12" +tracing = "0.1"
\ No newline at end of file diff --git a/plugins/workflow_objc/src/activities/objc_msg_send_calls.rs b/plugins/workflow_objc/src/activities/objc_msg_send_calls.rs index 86024047..3a772e79 100644 --- a/plugins/workflow_objc/src/activities/objc_msg_send_calls.rs +++ b/plugins/workflow_objc/src/activities/objc_msg_send_calls.rs @@ -7,7 +7,6 @@ use binaryninja::{ instruction::{InstructionHandler as _, LowLevelILInstruction, LowLevelILInstructionKind}, operation::{CallSsa, Operation}, }, - tracing, variable::PossibleValueSet, workflow::AnalysisContext, }; diff --git a/plugins/workflow_objc/src/activities/objc_msg_send_calls/rewrite_to_direct_call.rs b/plugins/workflow_objc/src/activities/objc_msg_send_calls/rewrite_to_direct_call.rs index 56c2aa52..02f41de8 100644 --- a/plugins/workflow_objc/src/activities/objc_msg_send_calls/rewrite_to_direct_call.rs +++ b/plugins/workflow_objc/src/activities/objc_msg_send_calls/rewrite_to_direct_call.rs @@ -4,7 +4,6 @@ use binaryninja::{ function::{LowLevelILFunction, Mutable, NonSSA, SSA}, instruction::{InstructionHandler as _, LowLevelILInstruction, LowLevelILInstructionKind}, }, - tracing, }; use super::MessageSendType; diff --git a/plugins/workflow_objc/src/activities/remove_memory_management.rs b/plugins/workflow_objc/src/activities/remove_memory_management.rs index fdd76650..cd613ee2 100644 --- a/plugins/workflow_objc/src/activities/remove_memory_management.rs +++ b/plugins/workflow_objc/src/activities/remove_memory_management.rs @@ -11,7 +11,6 @@ use binaryninja::{ lifting::LowLevelILLabel, LowLevelILRegisterKind, }, - tracing, variable::PossibleValueSet, workflow::AnalysisContext, }; diff --git a/plugins/workflow_objc/src/activities/super_init.rs b/plugins/workflow_objc/src/activities/super_init.rs index 1cdf8825..68c6d3ee 100644 --- a/plugins/workflow_objc/src/activities/super_init.rs +++ b/plugins/workflow_objc/src/activities/super_init.rs @@ -10,7 +10,6 @@ use binaryninja::{ MediumLevelILFunction, MediumLevelILLiftedInstruction, MediumLevelILLiftedInstructionKind, }, rc::Ref, - tracing, types::Type, variable::{RegisterValueType, SSAVariable}, workflow::AnalysisContext, diff --git a/plugins/workflow_objc/src/lib.rs b/plugins/workflow_objc/src/lib.rs index 5b41b6d0..483751ae 100644 --- a/plugins/workflow_objc/src/lib.rs +++ b/plugins/workflow_objc/src/lib.rs @@ -1,4 +1,4 @@ -use binaryninja::{add_optional_plugin_dependency, settings::Settings, tracing}; +use binaryninja::{add_optional_plugin_dependency, settings::Settings}; mod activities; mod error; diff --git a/plugins/workflow_objc/src/metadata/global_state.rs b/plugins/workflow_objc/src/metadata/global_state.rs index c6682a5f..db29af49 100644 --- a/plugins/workflow_objc/src/metadata/global_state.rs +++ b/plugins/workflow_objc/src/metadata/global_state.rs @@ -5,7 +5,7 @@ use binaryninja::{ metadata::Metadata, rc::Ref, settings::{QueryOptions, Settings}, - tracing, ObjectDestructor, + ObjectDestructor, }; use dashmap::DashMap; use once_cell::sync::Lazy; diff --git a/plugins/workflow_objc/src/workflow.rs b/plugins/workflow_objc/src/workflow.rs index 13e3a71e..fdda1d45 100644 --- a/plugins/workflow_objc/src/workflow.rs +++ b/plugins/workflow_objc/src/workflow.rs @@ -1,4 +1,3 @@ -use binaryninja::tracing; use binaryninja::workflow::{activity, Activity, AnalysisContext, Workflow}; use crate::{activities, error::WorkflowRegistrationError}; diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 2d7aa6a5..17cb2f0d 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -27,13 +27,17 @@ serde_derive = "1.0" serde_json = "1.0" # Used for tracing compatible logs tracing = { version = "0.1", default-features = false, features = ["std"] } -tracing-subscriber = { version = "0.3", default-features = false, features = ["std", "registry", "smallvec", "parking_lot"] } +tracing-subscriber = { version = "0.3", default-features = false, features = ["std", "registry", "parking_lot"] } [dev-dependencies] rstest = "0.24" tempfile = "3.15" serial_test = "3.2" insta = { version = "1.42", features = ["yaml"] } +# Use default features so that examples can register the fmt subscriber. +tracing-subscriber = { version = "0.3", default-features = true } +# Used for progress bar in examples +tracing-indicatif = "0.3" [package.metadata.typos] default.extend-ignore-re = ["Collapsable"] diff --git a/rust/plugin_examples/data_renderer/Cargo.toml b/rust/plugin_examples/data_renderer/Cargo.toml index 7ac32dfd..6c9aa63b 100644 --- a/rust/plugin_examples/data_renderer/Cargo.toml +++ b/rust/plugin_examples/data_renderer/Cargo.toml @@ -10,4 +10,4 @@ crate-type = ["cdylib"] binaryninjacore-sys = { path = "../../binaryninjacore-sys" } binaryninja = { path = "../.." } uuid = "1.18.1" -log = "0.4.27" +tracing = "0.1"
\ No newline at end of file diff --git a/rust/plugin_examples/data_renderer/src/lib.rs b/rust/plugin_examples/data_renderer/src/lib.rs index 97b81f23..e9c6b354 100644 --- a/rust/plugin_examples/data_renderer/src/lib.rs +++ b/rust/plugin_examples/data_renderer/src/lib.rs @@ -101,7 +101,7 @@ impl CustomDataRenderer for UuidDataRenderer { pub unsafe extern "C" fn CorePluginInit() -> bool { // Initialize logging binaryninja::tracing_init!(); - binaryninja::tracing::info!("Core plugin initialized"); + tracing::info!("Core plugin initialized"); // Register data renderer register_data_renderer(UuidDataRenderer {}); diff --git a/rust/src/custom_binary_view.rs b/rust/src/custom_binary_view.rs index 8e070b15..13a124e9 100644 --- a/rust/src/custom_binary_view.rs +++ b/rust/src/custom_binary_view.rs @@ -48,12 +48,10 @@ where where T: CustomBinaryViewType, { - ffi_wrap!("BinaryViewTypeBase::is_valid_for", unsafe { - let view_type = &*(ctxt as *mut T); - let data = BinaryView::ref_from_raw(BNNewViewReference(data)); - - view_type.is_valid_for(&data) - }) + let view_type = unsafe { &*(ctxt as *mut T) }; + let data = unsafe { BinaryView::ref_from_raw(BNNewViewReference(data)) }; + let _span = ffi_span!("BinaryViewTypeBase::is_valid_for", data); + view_type.is_valid_for(&data) } extern "C" fn cb_deprecated<T>(ctxt: *mut c_void) -> bool @@ -89,6 +87,7 @@ where actual_parent: &data, }; + let _span = ffi_span!("BinaryViewTypeBase::create", data); match view_type.create_custom_view(&data, builder) { Ok(bv) => { // force a leak of the Ref; failure to do this would result @@ -114,6 +113,7 @@ where actual_parent: &data, }; + let _span = ffi_span!("BinaryViewTypeBase::parse", data); match view_type.parse_custom_view(&data, builder) { Ok(bv) => { // force a leak of the Ref; failure to do this would result @@ -134,6 +134,7 @@ where let view_type = &*(ctxt as *mut T); let data = BinaryView::ref_from_raw(BNNewViewReference(data)); + let _span = ffi_span!("BinaryViewTypeBase::load_settings", data); match view_type.load_settings_for_data(&data) { Some(settings) => Ref::into_raw(settings).handle, None => ptr::null_mut() as *mut _, diff --git a/rust/src/debuginfo.rs b/rust/src/debuginfo.rs index 5879f40d..f4cee4ff 100644 --- a/rust/src/debuginfo.rs +++ b/rust/src/debuginfo.rs @@ -216,12 +216,10 @@ impl DebugInfoParser { where C: CustomDebugInfoParser, { - ffi_wrap!("CustomDebugInfoParser::is_valid", unsafe { - let cmd = &*(ctxt as *const C); - let view = BinaryView::ref_from_raw(view); - - cmd.is_valid(&view) - }) + let cmd = unsafe { &*(ctxt as *const C) }; + let view = unsafe { BinaryView::ref_from_raw(view) }; + let _span = ffi_span!("CustomDebugInfoParser::is_valid", view); + cmd.is_valid(&view) } extern "C" fn cb_parse_info<C>( @@ -235,28 +233,27 @@ impl DebugInfoParser { where C: CustomDebugInfoParser, { - ffi_wrap!("CustomDebugInfoParser::parse_info", unsafe { - let cmd = &*(ctxt as *const C); - let view = BinaryView::ref_from_raw(view); - let debug_file = BinaryView::ref_from_raw(debug_file); - let mut debug_info = DebugInfo::ref_from_raw(debug_info); + let cmd = unsafe { &*(ctxt as *const C) }; + let view = unsafe { BinaryView::ref_from_raw(view) }; + let debug_file = unsafe { BinaryView::ref_from_raw(debug_file) }; + let mut debug_info = unsafe { DebugInfo::ref_from_raw(debug_info) }; - cmd.parse_info( - &mut debug_info, - &view, - &debug_file, - Box::new(move |cur: usize, max: usize| match progress { - Some(func) => { - if func(progress_ctxt, cur, max) { - Ok(()) - } else { - Err(()) - } + let _span = ffi_span!("CustomDebugInfoParser::parse_info", view); + cmd.parse_info( + &mut debug_info, + &view, + &debug_file, + Box::new(move |cur: usize, max: usize| match progress { + Some(func) => unsafe { + if func(progress_ctxt, cur, max) { + Ok(()) + } else { + Err(()) } - _ => Ok(()), - }), - ) - }) + }, + _ => Ok(()), + }), + ) } let name = name.to_cstr(); diff --git a/rust/src/ffi.rs b/rust/src/ffi.rs index b6124dd4..d1c63216 100644 --- a/rust/src/ffi.rs +++ b/rust/src/ffi.rs @@ -20,7 +20,7 @@ macro_rules! ffi_wrap { use std::process; panic::catch_unwind(|| $b).unwrap_or_else(|_| { - tracing::error!("ffi callback caught panic: {}", $n); + ::tracing::error!("ffi callback caught panic: {}", $n); process::abort() }) }}; @@ -37,10 +37,10 @@ macro_rules! ffi_span { use $crate::binary_view::BinaryViewExt; #[allow(unused_imports)] use $crate::file_metadata::FileMetadata; - tracing::info_span!($name, session_id = $bv.file().session_id().0).entered() + ::tracing::info_span!($name, session_id = $bv.file().session_id().0).entered() }}; ($name:expr) => { - tracing::info_span!($name).entered() + ::tracing::info_span!($name).entered() }; } diff --git a/rust/src/logger.rs b/rust/src/logger.rs index f77cb52c..31696d25 100644 --- a/rust/src/logger.rs +++ b/rust/src/logger.rs @@ -137,6 +137,7 @@ unsafe impl Sync for Logger {} /// This is typically used in headless usage. It can also be used to temporarily log core /// messages to something like a file while some analysis is occurring, once the [`LogGuard`] is /// dropped, the listener will be unregistered. +#[must_use] pub fn register_log_listener<L: LogListener>(listener: L) -> LogGuard<L> { use binaryninjacore_sys::BNRegisterLogListener; diff --git a/rust/src/tracing.rs b/rust/src/tracing.rs index 2afdcd5e..539b697f 100644 --- a/rust/src/tracing.rs +++ b/rust/src/tracing.rs @@ -2,14 +2,11 @@ use crate::file_metadata::SessionId; use crate::logger::{ - bn_log_with_session, BnLogLevel, LogContext, LogListener, LOGGER_DEFAULT_SESSION_ID, + bn_log_with_session, BnLogLevel, LogContext, LogGuard, LogListener, LOGGER_DEFAULT_SESSION_ID, }; use tracing::{Event, Id, Level, Subscriber}; -use tracing_subscriber::prelude::*; - -// Re-export specific things to make it easy for the user -pub use tracing::{debug, error, info, trace, warn}; use tracing_subscriber::layer::Context; +use tracing_subscriber::prelude::*; use tracing_subscriber::registry::LookupSpan; use tracing_subscriber::Layer; @@ -26,7 +23,7 @@ use tracing_subscriber::Layer; /// #[unsafe(no_mangle)] /// pub unsafe extern "C" fn CorePluginInit() -> bool { /// binaryninja::tracing_init!("MyPlugin"); -/// binaryninja::tracing::info!("Core plugin initialized"); +/// tracing::info!("Core plugin initialized"); /// true /// } /// ``` @@ -264,7 +261,7 @@ impl tracing::field::Visit for BnFieldVisitor { /// // Register our tracing subscriber, this will send tracing events to stdout. /// tracing_subscriber::fmt::init(); /// // Register our log listener, this will send logs from the core to our tracing subscriber. -/// let _listener = register_log_listener(TracingLogListener::new(BnLogLevel::DebugLog)); +/// let _listener = TracingLogListener::new(BnLogLevel::DebugLog).register(); /// // Should see logs from the core in regard to initialization show up. /// let _session = Session::new().expect("Failed to create session"); /// bn_log("Test", BnLogLevel::DebugLog, "Hello, world!"); @@ -275,9 +272,29 @@ pub struct TracingLogListener { } impl TracingLogListener { - pub fn new(minimum_level: BnLogLevel) -> Self { + /// Create a [`TracingLogListener`] with the minimum log level set to [`BnLogLevel::InfoLog`]. + pub fn new() -> Self { + Self::default() + } + + pub fn new_with_lvl(minimum_level: BnLogLevel) -> Self { Self { minimum_level } } + + /// Register the [`TracingLogListener`] and send logs to the registered tracing subscriber until + /// the [`LogGuard`] is dropped, make sure to register your tracing subscriber before registering. + #[must_use] + pub fn register(self) -> LogGuard<Self> { + crate::logger::register_log_listener(self) + } +} + +impl Default for TracingLogListener { + fn default() -> Self { + Self { + minimum_level: BnLogLevel::InfoLog, + } + } } impl LogListener for TracingLogListener { @@ -285,16 +302,40 @@ impl LogListener for TracingLogListener { let session = ctx.session_id.map(|s| s.0); match level { BnLogLevel::ErrorLog | BnLogLevel::AlertLog => { - error!(session_id = session, target = %ctx.logger_name, "{}", message) + tracing::error!( + target: "binaryninja", + session_id = session, + logger = %ctx.logger_name, + "{}", + message + ) } BnLogLevel::WarningLog => { - warn!(session_id = session, target = %ctx.logger_name, "{}", message) + tracing::warn!( + target: "binaryninja", + session_id = session, + logger = %ctx.logger_name, + "{}", + message + ) } BnLogLevel::InfoLog => { - info!(session_id = session, target = %ctx.logger_name, "{}", message) + tracing::info!( + target: "binaryninja", + session_id = session, + logger = %ctx.logger_name, + "{}", + message + ) } BnLogLevel::DebugLog => { - debug!(session_id = session, target = %ctx.logger_name, "{}", message) + tracing::debug!( + target: "binaryninja", + session_id = session, + logger = %ctx.logger_name, + "{}", + message + ) } }; } diff --git a/view/minidump/Cargo.toml b/view/minidump/Cargo.toml index fed4a611..a39e9172 100644 --- a/view/minidump/Cargo.toml +++ b/view/minidump/Cargo.toml @@ -10,4 +10,5 @@ crate-type = ["cdylib"] [dependencies] binaryninja.workspace = true binaryninjacore-sys.workspace = true -minidump = "0.23.0"
\ No newline at end of file +minidump = "0.23.0" +tracing = "0.1"
\ No newline at end of file diff --git a/view/minidump/src/command.rs b/view/minidump/src/command.rs index 2f28b8b5..ca7ce4c5 100644 --- a/view/minidump/src/command.rs +++ b/view/minidump/src/command.rs @@ -3,7 +3,6 @@ use std::str; use minidump::{Minidump, MinidumpMemoryInfoList}; use binaryninja::binary_view::{BinaryView, BinaryViewBase, BinaryViewExt}; -use binaryninja::tracing; pub fn print_memory_information(bv: &BinaryView) { tracing::debug!("Printing memory information"); diff --git a/view/minidump/src/lib.rs b/view/minidump/src/lib.rs index 00fed601..1b1f7f19 100644 --- a/view/minidump/src/lib.rs +++ b/view/minidump/src/lib.rs @@ -1,7 +1,6 @@ use binaryninja::binary_view::BinaryView; use binaryninja::command::{register_command, Command}; use binaryninja::custom_binary_view::register_view_type; -use binaryninja::tracing; mod command; mod view; diff --git a/view/minidump/src/view.rs b/view/minidump/src/view.rs index 32fde030..8baf30c2 100644 --- a/view/minidump/src/view.rs +++ b/view/minidump/src/view.rs @@ -15,7 +15,7 @@ use binaryninja::custom_binary_view::{ CustomViewBuilder, }; use binaryninja::platform::Platform; -use binaryninja::{tracing, Endianness}; +use binaryninja::Endianness; type BinaryViewResult<R> = binaryninja::binary_view::Result<R>; |
