summaryrefslogtreecommitdiff
path: root/plugins/workflow_objc/src/activities
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/workflow_objc/src/activities
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/workflow_objc/src/activities')
-rw-r--r--plugins/workflow_objc/src/activities/objc_msg_send_calls.rs3
-rw-r--r--plugins/workflow_objc/src/activities/objc_msg_send_calls/rewrite_to_direct_call.rs3
-rw-r--r--plugins/workflow_objc/src/activities/remove_memory_management.rs3
-rw-r--r--plugins/workflow_objc/src/activities/super_init.rs19
4 files changed, 17 insertions, 11 deletions
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 b39c843c..86024047 100644
--- a/plugins/workflow_objc/src/activities/objc_msg_send_calls.rs
+++ b/plugins/workflow_objc/src/activities/objc_msg_send_calls.rs
@@ -7,6 +7,7 @@ use binaryninja::{
instruction::{InstructionHandler as _, LowLevelILInstruction, LowLevelILInstructionKind},
operation::{CallSsa, Operation},
},
+ tracing,
variable::PossibleValueSet,
workflow::AnalysisContext,
};
@@ -53,7 +54,7 @@ pub fn process(ac: &AnalysisContext) -> Result<(), Error> {
Ok(true) => function_changed = true,
Ok(_) => {}
Err(err) => {
- log::error!(
+ tracing::error!(
"Error processing instruction at {:#x}: {}",
insn.address(),
err
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 0ddf2945..56c2aa52 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,6 +4,7 @@ use binaryninja::{
function::{LowLevelILFunction, Mutable, NonSSA, SSA},
instruction::{InstructionHandler as _, LowLevelILInstruction, LowLevelILInstructionKind},
},
+ tracing,
};
use super::MessageSendType;
@@ -48,7 +49,7 @@ pub fn process_call(
Ok(())
}
_ => {
- log::error!(
+ tracing::error!(
"Unexpected LLIL operation for objc_msgSend call at {:#x}",
insn.address()
);
diff --git a/plugins/workflow_objc/src/activities/remove_memory_management.rs b/plugins/workflow_objc/src/activities/remove_memory_management.rs
index 3990f010..fdd76650 100644
--- a/plugins/workflow_objc/src/activities/remove_memory_management.rs
+++ b/plugins/workflow_objc/src/activities/remove_memory_management.rs
@@ -11,6 +11,7 @@ use binaryninja::{
lifting::LowLevelILLabel,
LowLevelILRegisterKind,
},
+ tracing,
variable::PossibleValueSet,
workflow::AnalysisContext,
};
@@ -176,7 +177,7 @@ pub fn process(ac: &AnalysisContext) -> Result<(), Error> {
Ok(true) => function_changed = true,
Ok(_) => {}
Err(err) => {
- log::error!(
+ tracing::error!(
"Error processing instruction at {:#x}: {}",
insn.address(),
err
diff --git a/plugins/workflow_objc/src/activities/super_init.rs b/plugins/workflow_objc/src/activities/super_init.rs
index cfd3ecdc..1cdf8825 100644
--- a/plugins/workflow_objc/src/activities/super_init.rs
+++ b/plugins/workflow_objc/src/activities/super_init.rs
@@ -10,6 +10,7 @@ use binaryninja::{
MediumLevelILFunction, MediumLevelILLiftedInstruction, MediumLevelILLiftedInstructionKind,
},
rc::Ref,
+ tracing,
types::Type,
variable::{RegisterValueType, SSAVariable},
workflow::AnalysisContext,
@@ -148,7 +149,7 @@ fn return_type_for_super_init(call: &Call, view: &BinaryView) -> Option<Ref<Type
src: super_param_var,
}) = super_param.kind
else {
- log::debug!(
+ tracing::debug!(
"Unhandled super paramater format at {:#0x} {:?}",
super_param.address,
super_param
@@ -163,7 +164,7 @@ fn return_type_for_super_init(call: &Call, view: &BinaryView) -> Option<Ref<Type
.function
.ssa_variable_definition(&super_param_var)
else {
- log::debug!(" could not find definition of variable?");
+ tracing::debug!(" could not find definition of variable?");
return None;
};
@@ -171,7 +172,7 @@ fn return_type_for_super_init(call: &Call, view: &BinaryView) -> Option<Ref<Type
MediumLevelILLiftedInstructionKind::SetVarSsa(LiftedSetVarSsa { src, .. }) => src,
_ => {
// The Swift compiler generates code that conditionally assigns to the receiver field of `objc_super`.
- log::debug!(
+ tracing::debug!(
"Unexpected variable definition kind at {:#0x} {:#x?}",
super_param_def.address,
super_param_def
@@ -184,7 +185,7 @@ fn return_type_for_super_init(call: &Call, view: &BinaryView) -> Option<Ref<Type
MediumLevelILLiftedInstructionKind::AddressOf(Var { src: src_var }) => src_var,
_ => {
// The Swift compiler generates code that initializes the `objc_super` variable in more varied ways.
- log::debug!(
+ tracing::debug!(
" found non-address-of variable definition of `objc_super` variable at {:#0x} {:?}",
super_param_def.address,
super_param_def
@@ -223,7 +224,7 @@ fn return_type_for_super_init(call: &Call, view: &BinaryView) -> Option<Ref<Type
// If there are zero, that likely means the assigned value was not a constant. Handling
// that is above my pay grade.
let &[super_class_ptr] = &super_class_constants[..] else {
- log::debug!(
+ tracing::debug!(
"Unexpected number of assignments to super class found for {:#0x}: {:#0x?}",
src.address,
super_class_constants
@@ -232,7 +233,7 @@ fn return_type_for_super_init(call: &Call, view: &BinaryView) -> Option<Ref<Type
};
let Some(super_class_symbol) = view.symbol_by_address(super_class_ptr) else {
- log::debug!("No symbol found for super class at {super_class_ptr:#0x}");
+ tracing::debug!("No symbol found for super class at {super_class_ptr:#0x}");
return None;
};
@@ -240,12 +241,14 @@ fn return_type_for_super_init(call: &Call, view: &BinaryView) -> Option<Ref<Type
let Some(class_name) =
class_name_from_symbol_name(super_class_symbol_name.to_bytes().as_bstr())
else {
- log::debug!("Unable to extract class name from symbol name: {super_class_symbol_name:?}");
+ tracing::debug!(
+ "Unable to extract class name from symbol name: {super_class_symbol_name:?}"
+ );
return None;
};
let Some(class_type) = view.type_by_name(class_name.to_str_lossy()) else {
- log::debug!("No type found for class named {class_name:?}");
+ tracing::debug!("No type found for class named {class_name:?}");
return None;
};