summaryrefslogtreecommitdiff
path: root/plugins/warp/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/warp/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/warp/src')
-rw-r--r--plugins/warp/src/cache.rs6
-rw-r--r--plugins/warp/src/container/disk.rs3
-rw-r--r--plugins/warp/src/container/network.rs15
-rw-r--r--plugins/warp/src/container/network/client.rs11
-rw-r--r--plugins/warp/src/convert/types.rs5
-rw-r--r--plugins/warp/src/plugin.rs30
-rw-r--r--plugins/warp/src/plugin/commit.rs17
-rw-r--r--plugins/warp/src/plugin/create.rs15
-rw-r--r--plugins/warp/src/plugin/debug.rs8
-rw-r--r--plugins/warp/src/plugin/ffi/container.rs5
-rw-r--r--plugins/warp/src/plugin/file.rs5
-rw-r--r--plugins/warp/src/plugin/function.rs25
-rw-r--r--plugins/warp/src/plugin/load.rs5
-rw-r--r--plugins/warp/src/plugin/project.rs21
-rw-r--r--plugins/warp/src/plugin/workflow.rs27
-rw-r--r--plugins/warp/src/processor.rs38
16 files changed, 125 insertions, 111 deletions
diff --git a/plugins/warp/src/cache.rs b/plugins/warp/src/cache.rs
index 09ad1444..30c7487c 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::ObjectDestructor;
+use binaryninja::{tracing, ObjectDestructor};
use std::hash::{DefaultHasher, Hash, Hasher};
pub fn register_cache_destructor() {
@@ -31,7 +31,7 @@ impl From<&BinaryView> for ViewID {
fn from(value: &BinaryView) -> Self {
let mut hasher = DefaultHasher::new();
hasher.write_u64(value.original_image_base());
- hasher.write_usize(value.file().session_id());
+ hasher.write_usize(value.file().session_id().0);
Self(hasher.finish())
}
}
@@ -79,6 +79,6 @@ pub struct CacheDestructor;
impl ObjectDestructor for CacheDestructor {
fn destruct_view(&self, view: &BinaryView) {
clear_type_ref_cache(view);
- log::debug!("Removed WARP caches for {:?}", view.file().filename());
+ tracing::debug!("Removed WARP caches for {:?}", view.file().filename());
}
}
diff --git a/plugins/warp/src/container/disk.rs b/plugins/warp/src/container/disk.rs
index a0400f9d..5e4a5613 100644
--- a/plugins/warp/src/container/disk.rs
+++ b/plugins/warp/src/container/disk.rs
@@ -1,6 +1,7 @@
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};
@@ -42,7 +43,7 @@ impl DiskContainer {
match (DiskContainerSource::new_from_path(path.clone()), path_ext) {
(Ok(source), _) => Some((source_id, source)),
(Err(err), Some("warp")) => {
- log::error!("Failed to load source '{}' from disk: {}", path, err);
+ tracing::error!("Failed to load source '{}' from disk: {}", path, err);
None
}
// We don't care to show errors loading for non-warp files.
diff --git a/plugins/warp/src/container/network.rs b/plugins/warp/src/container/network.rs
index d0ccd3ea..0908b103 100644
--- a/plugins/warp/src/container/network.rs
+++ b/plugins/warp/src/container/network.rs
@@ -3,6 +3,7 @@ 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};
@@ -102,7 +103,7 @@ impl NetworkContainer {
guids: &[FunctionGUID],
) -> HashMap<SourceId, Vec<FunctionGUID>> {
let Some(target_id) = target.and_then(|t| self.get_target_id(t)) else {
- log::debug!("Cannot query functions source without a target, skipping...");
+ tracing::debug!("Cannot query functions source without a target, skipping...");
return HashMap::new();
};
@@ -122,7 +123,7 @@ impl NetworkContainer {
{
Ok(queried_results) => queried_results,
Err(e) => {
- log::error!("Failed to query functions source: {}", e);
+ tracing::error!("Failed to query functions source: {}", e);
return result;
}
};
@@ -170,12 +171,12 @@ impl NetworkContainer {
{
Ok(file) => file,
Err(e) => {
- log::error!("Failed to query functions: {}", e);
+ tracing::error!("Failed to query functions: {}", e);
return;
}
};
- log::debug!("Got {} chunks from server", file.chunks.len());
+ tracing::debug!("Got {} chunks from server", file.chunks.len());
for chunk in &file.chunks {
match &chunk.kind {
ChunkKind::Signature(sc) => {
@@ -183,12 +184,12 @@ impl NetworkContainer {
// Probe the source before attempting to access it, as it might not exist locally.
self.probe_source(*source);
match self.cache.add_functions(target, source, &functions) {
- Ok(_) => log::debug!(
+ Ok(_) => tracing::debug!(
"Added {} functions into cached source '{}'",
functions.len(),
source
),
- Err(err) => log::error!(
+ Err(err) => tracing::error!(
"Failed to add {} function into cached source '{}': {}",
functions.len(),
source,
@@ -227,7 +228,7 @@ impl NetworkContainer {
let _ = self.cache.insert_source(source_id, SourcePath(source_path));
}
Err(e) => {
- log::error!("Failed to probe source '{}': {}", source_id, e);
+ tracing::error!("Failed to probe source '{}': {}", source_id, e);
}
}
}
diff --git a/plugins/warp/src/container/network/client.rs b/plugins/warp/src/container/network/client.rs
index 9f68180b..d3c94d1a 100644
--- a/plugins/warp/src/container/network/client.rs
+++ b/plugins/warp/src/container/network/client.rs
@@ -5,6 +5,7 @@ use crate::container::{
};
use base64::Engine;
use binaryninja::download::DownloadProvider;
+use binaryninja::tracing;
use serde::Deserialize;
use serde_json::json;
use std::collections::HashMap;
@@ -496,14 +497,14 @@ impl NetworkClient {
let kind = match item.kind.as_str() {
"function" => {
let Some(data) = &item.data else {
- log::warn!(
+ tracing::warn!(
"Function item {} has no data from network, skipping...",
item.id
);
continue;
};
let Some(func) = Function::from_bytes(&data) else {
- log::warn!(
+ tracing::warn!(
"Function item {} has invalid data from network, skipping...",
item.id
);
@@ -514,7 +515,7 @@ impl NetworkClient {
"source" => ContainerSearchItemKind::Source {
path: match item.name {
None => {
- log::warn!("Source item {} has no name", item.id);
+ tracing::warn!("Source item {} has no name", item.id);
continue;
}
Some(name) => SourcePath(format!("{}/{}", self.server_url, name).into()),
@@ -523,14 +524,14 @@ impl NetworkClient {
},
"type" => {
let Some(data) = &item.data else {
- log::warn!(
+ tracing::warn!(
"Type item {} has no data from network, skipping...",
item.id
);
continue;
};
let Some(ty) = Type::from_bytes(&data) else {
- log::warn!(
+ tracing::warn!(
"Type item {} has invalid data from network, skipping...",
item.id
);
diff --git a/plugins/warp/src/convert/types.rs b/plugins/warp/src/convert/types.rs
index f8ead6af..227df2ea 100644
--- a/plugins/warp/src/convert/types.rs
+++ b/plugins/warp/src/convert/types.rs
@@ -6,6 +6,7 @@ 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;
@@ -361,7 +362,7 @@ pub fn to_bn_type<A: BNArchitecture + Copy>(arch: Option<A>, ty: &Type) -> BNRef
))
}
_ => {
- log::error!(
+ tracing::error!(
"Adding base {:?} with invalid ty: {:?}",
ty.name,
member.ty
@@ -470,7 +471,7 @@ pub fn to_bn_type<A: BNArchitecture + Copy>(arch: Option<A>, ty: &Type) -> BNRef
ntr_name,
),
None => {
- log::error!("Referrer with no reference! {:?}", c);
+ tracing::error!("Referrer with no reference! {:?}", c);
NamedTypeReference::new(
NamedTypeReferenceClass::UnknownNamedTypeClass,
"AHHHHHH",
diff --git a/plugins/warp/src/plugin.rs b/plugins/warp/src/plugin.rs
index 9fe6cd3f..dec62c2f 100644
--- a/plugins/warp/src/plugin.rs
+++ b/plugins/warp/src/plugin.rs
@@ -12,10 +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::logger::Logger;
use binaryninja::settings::{QueryOptions, Settings};
-use log::LevelFilter;
+use binaryninja::{is_ui_enabled, tracing};
mod commit;
mod create;
@@ -42,16 +40,16 @@ fn load_bundled_signatures() {
let mut core_disk_container = DiskContainer::new_from_dir(core_signature_dir());
core_disk_container.name = "Bundled".to_string();
core_disk_container.writable = false;
- log::debug!("{:#?}", core_disk_container);
+ tracing::debug!("{:#?}", core_disk_container);
add_cached_container(core_disk_container);
}
if plugin_settings.load_user_files {
let mut user_disk_container = DiskContainer::new_from_dir(user_signature_dir());
user_disk_container.name = "User".to_string();
- log::debug!("{:#?}", user_disk_container);
+ tracing::debug!("{:#?}", user_disk_container);
add_cached_container(user_disk_container);
}
- log::info!("Loading files took {:?}", start.elapsed());
+ tracing::info!("Loading files took {:?}", start.elapsed());
background_task.finish();
}
@@ -62,7 +60,7 @@ fn load_network_container() {
let network_client = NetworkClient::new(url.clone(), api_key.clone());
// Before constructing the container, let's make sure that the server is OK.
if let Err(e) = network_client.status() {
- log::warn!("Server '{}' failed to connect: {}", url, e);
+ tracing::warn!("Server '{}' failed to connect: {}", url, e);
return;
}
@@ -70,7 +68,7 @@ fn load_network_container() {
let mut writable_sources = Vec::new();
match network_client.current_user() {
Ok((id, username)) => {
- log::info!(
+ tracing::info!(
"Server '{}' connected, logged in as user '{}'",
url,
username
@@ -80,19 +78,19 @@ fn load_network_container() {
writable_sources = sources;
}
Err(e) => {
- log::error!("Server '{}' failed to get sources for user: {}", url, e);
+ tracing::error!("Server '{}' failed to get sources for user: {}", url, e);
}
}
}
Err(e) if api_key.is_some() => {
- log::error!(
+ tracing::error!(
"Server '{}' failed to authenticate with provided API key: {}",
url,
e
);
}
Err(_) => {
- log::info!("Server '{}' connected, logged in as guest", url);
+ tracing::info!("Server '{}' connected, logged in as guest", url);
}
}
@@ -100,7 +98,7 @@ fn load_network_container() {
let main_cache_path = NetworkContainer::root_cache_location().join("main");
let network_container =
NetworkContainer::new(network_client, main_cache_path, &writable_sources);
- log::debug!("{:#?}", network_container);
+ tracing::debug!("{:#?}", network_container);
add_cached_container(network_container);
};
@@ -114,17 +112,17 @@ fn load_network_container() {
add_network_container(second_server_url, plugin_settings.second_server_api_key);
}
}
- log::debug!("Initializing warp server took {:?}", start.elapsed());
+ tracing::debug!("Initializing warp server took {:?}", start.elapsed());
background_task.finish();
}
fn plugin_init() -> bool {
- Logger::new("WARP").with_level(LevelFilter::Debug).init();
+ binaryninja::tracing_init!("WARP");
// Create the user signature directory if it does not exist, otherwise we will not be able to write to it.
if !user_signature_dir().exists() {
if let Err(e) = std::fs::create_dir_all(&user_signature_dir()) {
- log::error!("Failed to create user signature directory: {}", e);
+ tracing::error!("Failed to create user signature directory: {}", e);
}
}
@@ -141,7 +139,7 @@ fn plugin_init() -> bool {
HighlightRenderLayer::register();
if workflow::insert_workflow().is_err() {
- log::error!("Failed to register WARP workflow");
+ tracing::error!("Failed to register WARP workflow");
return false;
}
diff --git a/plugins/warp/src/plugin/commit.rs b/plugins/warp/src/plugin/commit.rs
index 2af5fc3e..56a78f9a 100644
--- a/plugins/warp/src/plugin/commit.rs
+++ b/plugins/warp/src/plugin/commit.rs
@@ -6,6 +6,7 @@ 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;
@@ -84,11 +85,11 @@ impl CommitFile {
let open_file_path = OpenFileField::from_form(&form)?;
let source_id = source_field.from_form(&form)?;
- log::info!("Committing file to source: {}", source_id);
+ tracing::info!("Committing file to source: {}", source_id);
let bytes = std::fs::read(open_file_path).ok()?;
let Some(warp_file) = WarpFile::from_bytes(&bytes) else {
- log::error!("Failed to parse warp file!");
+ tracing::error!("Failed to parse warp file!");
return None;
};
@@ -103,7 +104,7 @@ impl CommitFile {
match &chunk.kind {
ChunkKind::Signature(sc) => {
let functions: Vec<_> = sc.functions().collect();
- log::info!(
+ tracing::info!(
"Adding {} functions to source: {}",
functions.len(),
source_id
@@ -113,22 +114,22 @@ impl CommitFile {
&source_id,
&functions,
) {
- log::error!("Failed to add functions to source: {}", e);
+ tracing::error!("Failed to add functions to source: {}", e);
}
}
ChunkKind::Type(sc) => {
let types: Vec<_> = sc.types().collect();
- log::info!("Adding {} types to source: {}", types.len(), source_id);
+ tracing::info!("Adding {} types to source: {}", types.len(), source_id);
if let Err(e) = container.add_computed_types(&source_id, &types) {
- log::error!("Failed to add types to source: {}", e);
+ tracing::error!("Failed to add types to source: {}", e);
}
}
}
}
if let Err(e) = container.commit_source(&source_id) {
- log::error!("Failed to commit source: {}", e);
+ tracing::error!("Failed to commit source: {}", e);
}
- log::info!("Committed file to source: {}", source_id);
+ tracing::info!("Committed file to source: {}", source_id);
return Some(());
}
}
diff --git a/plugins/warp/src/plugin/create.rs b/plugins/warp/src/plugin/create.rs
index d6839ce6..04a3e9b6 100644
--- a/plugins/warp/src/plugin/create.rs
+++ b/plugins/warp/src/plugin/create.rs
@@ -10,6 +10,7 @@ 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;
@@ -131,7 +132,7 @@ impl CreateFromCurrentView {
existing_chunks.extend(existing_file.chunks);
}
MessageBoxButtonResult::CancelButton => {
- log::info!(
+ tracing::info!(
"User cancelled signature file creation, no operations were performed."
);
return None;
@@ -168,7 +169,7 @@ impl CreateFromCurrentView {
MessageBoxButtonSet::OKButtonSet,
MessageBoxIcon::ErrorIcon,
);
- log::error!("Failed to create signature file: {}", err);
+ tracing::error!("Failed to create signature file: {}", err);
return None;
}
@@ -184,7 +185,9 @@ impl CreateFromCurrentView {
// After merging, we should have at least one chunk. If not, merging actually removed data.
if file.chunks.len() < 1 {
- log::error!("Failed to merge chunks! Please report this, it should not happen.");
+ tracing::error!(
+ "Failed to merge chunks! Please report this, it should not happen."
+ );
return None;
}
}
@@ -192,9 +195,9 @@ impl CreateFromCurrentView {
let file_bytes = file.to_bytes();
let file_size = file_bytes.len();
if std::fs::write(&file_path, file_bytes).is_err() {
- log::error!("Failed to write data to signature file!");
+ tracing::error!("Failed to write data to signature file!");
}
- log::info!("Saved signature file to: '{}'", file_path.display());
+ tracing::info!("Saved signature file to: '{}'", file_path.display());
background_task.finish();
// Show a report of the generate signatures, if desired.
@@ -210,7 +213,7 @@ impl CreateFromCurrentView {
// The ReportWidget uses a QTextBrowser, which cannot render large files very well.
if file_size > 10000000 {
- log::warn!("WARP report file is too large to show in the UI. Please see the report file on disk.");
+ tracing::warn!("WARP report file is too large to show in the UI. Please see the report file on disk.");
} else {
match report_kind {
ReportKindField::None => {}
diff --git a/plugins/warp/src/plugin/debug.rs b/plugins/warp/src/plugin/debug.rs
index 399dba50..6db491e2 100644
--- a/plugins/warp/src/plugin/debug.rs
+++ b/plugins/warp/src/plugin/debug.rs
@@ -3,13 +3,13 @@ use crate::{build_function, cache};
use binaryninja::binary_view::BinaryView;
use binaryninja::command::{Command, FunctionCommand};
use binaryninja::function::Function;
-use binaryninja::ObjectDestructor;
+use binaryninja::{tracing, ObjectDestructor};
pub struct DebugFunction;
impl FunctionCommand for DebugFunction {
fn action(&self, _view: &BinaryView, func: &Function) {
- log::info!(
+ tracing::info!(
"{:#?}",
build_function(func, || func.lifted_il().ok(), false)
);
@@ -25,7 +25,7 @@ pub struct DebugCache;
impl Command for DebugCache {
fn action(&self, _view: &BinaryView) {
for_cached_containers(|c| {
- log::info!("Container: {:#?}", c);
+ tracing::info!("Container: {:#?}", c);
});
}
@@ -40,7 +40,7 @@ impl Command for DebugInvalidateCache {
fn action(&self, view: &BinaryView) {
let destructor = cache::CacheDestructor {};
destructor.destruct_view(view);
- log::info!("Invalidated all WARP caches...");
+ tracing::info!("Invalidated all WARP caches...");
}
fn valid(&self, _view: &BinaryView) -> bool {
diff --git a/plugins/warp/src/plugin/ffi/container.rs b/plugins/warp/src/plugin/ffi/container.rs
index 72c85366..6c2551c1 100644
--- a/plugins/warp/src/plugin/ffi/container.rs
+++ b/plugins/warp/src/plugin/ffi/container.rs
@@ -10,6 +10,7 @@ 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};
@@ -219,7 +220,7 @@ pub unsafe extern "C" fn BNWARPContainerFetchFunctions(
let guids = unsafe { std::slice::from_raw_parts(guids, count) };
if let Err(e) = container.fetch_functions(&target, &source_tags, guids) {
- log::error!("Failed to fetch functions: {}", e);
+ tracing::error!("Failed to fetch functions: {}", e);
}
}
@@ -586,7 +587,7 @@ pub unsafe extern "C" fn BNWARPContainerSearch(
let result = match container.search(&query) {
Ok(result) => result,
Err(err) => {
- log::error!("Failed to search container {:?}: {}", query.deref(), err);
+ tracing::error!("Failed to search container {:?}: {}", query.deref(), err);
return std::ptr::null_mut();
}
};
diff --git a/plugins/warp/src/plugin/file.rs b/plugins/warp/src/plugin/file.rs
index ec61bd78..899e3f46 100644
--- a/plugins/warp/src/plugin/file.rs
+++ b/plugins/warp/src/plugin/file.rs
@@ -1,6 +1,7 @@
use crate::report::ReportGenerator;
use binaryninja::binary_view::{BinaryView, BinaryViewExt};
use binaryninja::command::Command;
+use binaryninja::tracing;
pub struct ShowFileReport;
@@ -15,12 +16,12 @@ impl Command for ShowFileReport {
};
let Ok(bytes) = std::fs::read(&path) else {
- log::error!("Failed to read file: {:?}", path);
+ tracing::error!("Failed to read file: {:?}", path);
return;
};
let Some(file) = warp::WarpFile::from_bytes(&bytes) else {
- log::error!("Failed to parse file: {:?}", path);
+ tracing::error!("Failed to parse file: {:?}", path);
return;
};
diff --git a/plugins/warp/src/plugin/function.rs b/plugins/warp/src/plugin/function.rs
index 6202f9d7..3c0dc06c 100644
--- a/plugins/warp/src/plugin/function.rs
+++ b/plugins/warp/src/plugin/function.rs
@@ -10,6 +10,7 @@ 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;
@@ -24,7 +25,7 @@ impl FunctionCommand for IncludeFunction {
let insert_tag_type = get_warp_include_tag_type(view);
match should_add_tag {
true => {
- log::info!(
+ tracing::info!(
"Including selected function '{}' at 0x{:x}",
sym_name_str,
func.start()
@@ -32,7 +33,7 @@ impl FunctionCommand for IncludeFunction {
func.add_tag(&insert_tag_type, "", None, false, None);
}
false => {
- log::info!(
+ tracing::info!(
"Removing included function '{}' at 0x{:x}",
sym_name_str,
func.start()
@@ -58,7 +59,7 @@ impl FunctionCommand for IgnoreFunction {
let ignore_tag_type = get_warp_ignore_tag_type(view);
match should_add_tag {
true => {
- log::info!(
+ tracing::info!(
"Ignoring function for matching '{}' at 0x{:x}",
sym_name_str,
func.start()
@@ -66,7 +67,7 @@ impl FunctionCommand for IgnoreFunction {
func.add_tag(&ignore_tag_type, "", None, false, None);
}
false => {
- log::info!(
+ tracing::info!(
"Including function for matching '{}' at 0x{:x}",
sym_name_str,
func.start()
@@ -87,7 +88,7 @@ impl FunctionCommand for RemoveFunction {
fn action(&self, _view: &BinaryView, func: &Function) {
let sym_name = func.symbol().short_name();
let sym_name_str = sym_name.to_string_lossy();
- log::info!(
+ tracing::info!(
"Removing matched function '{}' at 0x{:x}",
sym_name_str,
func.start()
@@ -107,10 +108,10 @@ pub struct CopyFunctionGUID;
impl FunctionCommand for CopyFunctionGUID {
fn action(&self, _view: &BinaryView, func: &Function) {
let Some(guid) = cached_function_guid(func, || func.lifted_il().ok()) else {
- log::error!("Could not get guid for copied function");
+ tracing::error!("Could not get guid for copied function");
return;
};
- log::info!(
+ tracing::info!(
"Function GUID for {:?}... {}",
func.symbol().short_name(),
guid
@@ -137,11 +138,11 @@ impl Command for FindFunctionFromGUID {
};
let Ok(searched_guid) = guid_str.parse::<FunctionGUID>() else {
- log::error!("Failed to parse function guid... {}", guid_str);
+ tracing::error!("Failed to parse function guid... {}", guid_str);
return;
};
- log::info!("Searching functions for GUID... {}", searched_guid);
+ tracing::info!("Searching functions for GUID... {}", searched_guid);
let funcs = view.functions();
let view = view.to_owned();
thread::spawn(move || {
@@ -159,7 +160,7 @@ impl Command for FindFunctionFromGUID {
.collect();
if matched.is_empty() {
- log::info!("No matches found for GUID... {}", searched_guid);
+ tracing::info!("No matches found for GUID... {}", searched_guid);
} else {
for func in &matched {
// Also navigate the user, as that is probably what they want.
@@ -170,14 +171,14 @@ impl Command for FindFunctionFromGUID {
.navigate_to(&current_view, func.start())
.is_err()
{
- log::error!(
+ tracing::error!(
"Failed to navigate to found function 0x{:0x} in view {}",
func.start(),
current_view
);
}
}
- log::info!("Match found at function... 0x{:0x}", func.start());
+ tracing::info!("Match found at function... 0x{:0x}", func.start());
}
}
diff --git a/plugins/warp/src/plugin/load.rs b/plugins/warp/src/plugin/load.rs
index 0b8d1672..bd0e4838 100644
--- a/plugins/warp/src/plugin/load.rs
+++ b/plugins/warp/src/plugin/load.rs
@@ -10,6 +10,7 @@ use binaryninja::interaction::{
MessageBoxIcon,
};
use binaryninja::rc::Ref;
+use binaryninja::tracing;
use std::collections::HashMap;
use std::path::PathBuf;
use std::sync::atomic::AtomicBool;
@@ -130,7 +131,7 @@ impl LoadSignatureFile {
let file = match LoadSignatureFile::read_file(&view, source_file_path.clone()) {
Ok(file) => file,
Err(e) => {
- log::error!("Failed to read signature file: {}", e);
+ tracing::error!("Failed to read signature file: {}", e);
return;
}
};
@@ -156,7 +157,7 @@ impl LoadSignatureFile {
}
let container_source = DiskContainerSource::new(source_file_path.clone(), file);
- log::info!("Loading container source: '{}'", container_source.path);
+ tracing::info!("Loading container source: '{}'", container_source.path);
let mut map = HashMap::new();
map.insert(source_file_path.to_source_id(), container_source);
let container = DiskContainer::new("Loaded signatures".to_string(), map);
diff --git a/plugins/warp/src/plugin/project.rs b/plugins/warp/src/plugin/project.rs
index 725d164c..8862c00a 100644
--- a/plugins/warp/src/plugin/project.rs
+++ b/plugins/warp/src/plugin/project.rs
@@ -9,6 +9,7 @@ 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;
@@ -157,7 +158,7 @@ impl CreateSignatures {
.create_file(&warp_file.to_bytes(), folder, name, "")
.is_err()
{
- log::error!("Failed to create project file!");
+ tracing::error!("Failed to create project file!");
}
let report = ReportGenerator::new();
@@ -168,7 +169,7 @@ impl CreateSignatures {
.create_file(&generated.into_bytes(), folder, &file_name, "Warp file")
.is_err()
{
- log::error!("Failed to create project file!");
+ tracing::error!("Failed to create project file!");
}
}
};
@@ -177,12 +178,12 @@ impl CreateSignatures {
let callback_project = project.clone();
let save_individual_files_cb = move |path: &Path, file: &WarpFile| {
if file.chunks.is_empty() {
- log::debug!("Skipping empty file: {}", path.display());
+ tracing::debug!("Skipping empty file: {}", path.display());
return;
}
// The path returned will be the one on disk, so we will go and grab the project for it.
let Some(project_file) = callback_project.file_by_path(path) else {
- log::error!("Failed to find project file for path: {}", path.display());
+ tracing::error!("Failed to find project file for path: {}", path.display());
return;
};
let project_file = project_file.to_owned();
@@ -214,8 +215,8 @@ impl CreateSignatures {
processor = processor.with_file_filter(f);
}
Err(err) => {
- log::error!("Failed to parse file filter: {}", err);
- log::error!(
+ tracing::error!("Failed to parse file filter: {}", err);
+ tracing::error!(
"Consider using a substring instead of a glob pattern, e.g. *.exe => exe"
);
return;
@@ -231,7 +232,7 @@ impl CreateSignatures {
.num_threads(processing_thread_count)
.build()
else {
- log::error!("Failed to create processing thread pool!");
+ tracing::error!("Failed to create processing thread pool!");
return;
};
@@ -240,7 +241,7 @@ impl CreateSignatures {
let previous_worker_thread_count = worker_thread_count();
let upgraded_thread_count = previous_worker_thread_count * 3;
if upgraded_thread_count > previous_worker_thread_count {
- log::info!(
+ tracing::info!(
"Setting worker thread count to {} for the duration of processing...",
upgraded_thread_count
);
@@ -253,14 +254,14 @@ impl CreateSignatures {
save_warp_file(&project, None, "generated.warp", &warp_file);
}
Err(e) => {
- log::error!("Failed to process project: {}", e);
+ tracing::error!("Failed to process project: {}", e);
}
});
let processed_file_count = processor
.state()
.files_with_state(ProcessingFileState::Processed);
- log::info!(
+ tracing::info!(
"Processing {} project files took: {:?}",
processed_file_count,
start.elapsed()
diff --git a/plugins/warp/src/plugin/workflow.rs b/plugins/warp/src/plugin/workflow.rs
index e5ce9b76..a51c7399 100644
--- a/plugins/warp/src/plugin/workflow.rs
+++ b/plugins/warp/src/plugin/workflow.rs
@@ -15,6 +15,7 @@ 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;
@@ -39,7 +40,7 @@ impl Command for RunMatcher {
// Alert the user if we have no actual regions (+1 comes from the synthetic section).
let regions = relocatable_regions(&view);
if regions.len() <= 1 && view.memory_map().is_activated() {
- log::warn!(
+ tracing::warn!(
"No relocatable regions found, for best results please define sections for the binary!"
);
}
@@ -90,13 +91,15 @@ impl FunctionSet {
.workflow()
.expect("Function has no workflow");
if function_workflow.contains(GUID_ACTIVITY_NAME) {
- log::error!("No function guids in database, please reanalyze the database.");
+ tracing::error!(
+ "No function guids in database, please reanalyze the database."
+ );
} else {
- log::error!(
- "Activity '{}' is not in workflow '{}', create function guids manually to run matcher...",
- GUID_ACTIVITY_NAME,
- function_workflow.name()
- )
+ tracing::error!(
+ "Activity '{}' is not in workflow '{}', create function guids manually to run matcher...",
+ GUID_ACTIVITY_NAME,
+ function_workflow.name()
+ )
}
}
return None;
@@ -169,7 +172,7 @@ pub fn run_matcher(view: &BinaryView) {
.maximum_possible_functions
.is_some_and(|max| max < matched_functions.len() as u64)
{
- log::warn!(
+ tracing::warn!(
"Skipping {}, too many possible functions: {}",
guid,
matched_functions.len()
@@ -244,10 +247,10 @@ pub fn run_matcher(view: &BinaryView) {
}
if background_task.is_cancelled() {
- log::info!("Matcher was cancelled by user, you may run it again by running the 'Run Matcher' command.");
+ tracing::info!("Matcher was cancelled by user, you may run it again by running the 'Run Matcher' command.");
}
- log::info!(
+ tracing::info!(
"Function matching took {:.3} seconds and matched {} functions after {} rounds",
start.elapsed().as_secs_f64(),
matcher_results.len(),
@@ -290,12 +293,12 @@ pub fn run_fetcher(view: &BinaryView) {
});
if background_task.is_cancelled() {
- log::info!(
+ tracing::info!(
"Fetcher was cancelled by user, you may run it again by running the 'Fetch' command."
);
}
- log::info!("Fetching took {:?}", start.elapsed());
+ tracing::info!("Fetching took {:?}", start.elapsed());
background_task.finish();
}
diff --git a/plugins/warp/src/processor.rs b/plugins/warp/src/processor.rs
index 693f0852..3076ddca 100644
--- a/plugins/warp/src/processor.rs
+++ b/plugins/warp/src/processor.rs
@@ -26,6 +26,10 @@ use binaryninja::project::file::ProjectFile;
use binaryninja::project::Project;
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;
@@ -33,10 +37,6 @@ use warp::signature::function::Function;
use warp::target::Target;
use warp::{WarpFile, WarpFileHeader};
-use crate::cache::cached_type_references;
-use crate::convert::platform_to_target;
-use crate::{build_function, INCLUDE_TAG_ICON, INCLUDE_TAG_NAME};
-
/// Ensure we never exceed these many functions per signature chunk.
///
/// This was added to fix running into the max table limit on certain files.
@@ -538,15 +538,15 @@ impl WarpFileProcessor {
Ok(result) => Some(Ok(result)),
Err(ProcessingError::Cancelled) => Some(Err(ProcessingError::Cancelled)),
Err(ProcessingError::NoPathToProjectFile(path)) => {
- log::debug!("Skipping non-pulled project file: {:?}", path);
+ tracing::debug!("Skipping non-pulled project file: {:?}", path);
None
}
Err(ProcessingError::SkippedFile(path)) => {
- log::debug!("Skipping project file: {:?}", path);
+ tracing::debug!("Skipping project file: {:?}", path);
None
}
Err(e) => {
- log::error!("Project file processing error: {:?}", e);
+ tracing::error!("Project file processing error: {:?}", e);
None
}
})
@@ -615,14 +615,14 @@ impl WarpFileProcessor {
.with_extension("bndb");
if file_cache_path.exists() {
// TODO: Update analysis and wait option
- log::debug!("Analysis database found in cache: {:?}", file_cache_path);
+ tracing::debug!("Analysis database found in cache: {:?}", file_cache_path);
binaryninja::load_with_options(
&file_cache_path,
self.request_analysis,
Some(settings_str),
)
} else {
- log::debug!("No database found in cache: {:?}", file_cache_path);
+ tracing::debug!("No database found in cache: {:?}", file_cache_path);
binaryninja::load_with_options(&path, self.request_analysis, Some(settings_str))
}
}
@@ -645,13 +645,13 @@ impl WarpFileProcessor {
// TODO: We should also update the cache if analysis has changed!
if !view.file().is_database_backed() {
// Update the cache.
- log::debug!("Saving analysis database to {:?}", file_cache_path);
+ tracing::debug!("Saving analysis database to {:?}", file_cache_path);
if !view.file().create_database(&file_cache_path) {
// TODO: We might want to error here...
- log::warn!("Failed to save analysis database to {:?}", file_cache_path);
+ tracing::warn!("Failed to save analysis database to {:?}", file_cache_path);
}
} else {
- log::debug!(
+ tracing::debug!(
"Analysis database unchanged, skipping save to {:?}",
file_cache_path
);
@@ -699,7 +699,7 @@ impl WarpFileProcessor {
// Process all the files.
let unmerged_files: Result<Vec<_>, _> = files
.into_par_iter()
- .inspect(|path| log::debug!("Processing file: {:?}", path))
+ .inspect(|path| tracing::debug!("Processing file: {:?}", path))
.map(|path| {
self.check_cancelled()?;
self.process(path)
@@ -707,12 +707,12 @@ impl WarpFileProcessor {
.filter_map(|res| match res {
Ok(result) => Some(Ok(result)),
Err(ProcessingError::SkippedFile(path)) => {
- log::debug!("Skipping directory file: {:?}", path);
+ tracing::debug!("Skipping directory file: {:?}", path);
None
}
Err(ProcessingError::Cancelled) => Some(Err(ProcessingError::Cancelled)),
Err(e) => {
- log::error!("Directory file processing error: {:?}", e);
+ tracing::error!("Directory file processing error: {:?}", e);
None
}
})
@@ -752,7 +752,7 @@ impl WarpFileProcessor {
std::io::copy(&mut entry, &mut output_file).map_err(ProcessingError::FileRead)?;
entry_files.insert(output_path);
} else {
- log::debug!("Skipping already inserted entry: {}", normalized_name);
+ tracing::debug!("Skipping already inserted entry: {}", normalized_name);
}
}
@@ -765,7 +765,7 @@ impl WarpFileProcessor {
// Process all the entries.
let unmerged_files: Result<Vec<_>, _> = entry_files
.into_par_iter()
- .inspect(|path| log::debug!("Processing entry: {:?}", path))
+ .inspect(|path| tracing::debug!("Processing entry: {:?}", path))
.map(|path| {
self.check_cancelled()?;
self.process_file(path)
@@ -773,12 +773,12 @@ impl WarpFileProcessor {
.filter_map(|res| match res {
Ok(result) => Some(Ok(result)),
Err(ProcessingError::SkippedFile(path)) => {
- log::debug!("Skipping archive file: {:?}", path);
+ tracing::debug!("Skipping archive file: {:?}", path);
None
}
Err(ProcessingError::Cancelled) => Some(Err(ProcessingError::Cancelled)),
Err(e) => {
- log::error!("Archive file processing error: {:?}", e);
+ tracing::error!("Archive file processing error: {:?}", e);
None
}
})