Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
218 changes: 135 additions & 83 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion arch/msp430/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ license = "Apache-2.0"
[dependencies]
binaryninja.workspace = true
binaryninjacore-sys.workspace = true
log = "0.4"
msp430-asm = "^0.2"
tracing = "0.1"

[lib]
crate-type = ["cdylib"]
5 changes: 2 additions & 3 deletions arch/msp430/src/architecture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use binaryninja::architecture::{
};
use binaryninja::low_level_il::expression::ValueExpr;
use binaryninja::low_level_il::{LowLevelILMutableExpression, LowLevelILMutableFunction};
use log::error;

const MIN_MNEMONIC: usize = 9;

Expand Down Expand Up @@ -321,7 +320,7 @@ impl Architecture for Msp430 {
match id.try_into() {
Ok(flag) => Some(flag),
Err(_) => {
error!("invalid flag id {}", id);
tracing::error!("invalid flag id {}", id);
None
}
}
Expand All @@ -331,7 +330,7 @@ impl Architecture for Msp430 {
match id.try_into() {
Ok(flag_write) => Some(flag_write),
Err(_) => {
error!("invalid flag write id {}", id);
tracing::error!("invalid flag write id {}", id);
None
}
}
Expand Down
9 changes: 2 additions & 7 deletions arch/msp430/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
extern crate binaryninja;
extern crate log;
extern crate msp430_asm;

use binaryninja::{
add_optional_plugin_dependency,
architecture::ArchitectureExt,
calling_convention,
custom_binary_view::{BinaryViewType, BinaryViewTypeExt},
Endianness,
};
use log::LevelFilter;

mod architecture;
mod flag;
mod lift;
mod register;

use architecture::Msp430;
use binaryninja::logger::Logger;

#[no_mangle]
#[allow(non_snake_case)]
pub extern "C" fn CorePluginInit() -> bool {
Logger::new("MSP430").with_level(LevelFilter::Info).init();
binaryninja::tracing_init!("MSP430");

let arch =
binaryninja::architecture::register_architecture("msp430", |custom_handle, handle| {
Msp430::new(handle, custom_handle)
Expand Down
3 changes: 1 addition & 2 deletions arch/msp430/src/lift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use msp430_asm::two_operand::TwoOperand;

use binaryninja::low_level_il::expression::ValueExpr;
use binaryninja::low_level_il::{LowLevelILMutableExpression, LowLevelILMutableFunction};
use log::info;

macro_rules! auto_increment {
($src:expr, $il:ident) => {
Expand Down Expand Up @@ -550,7 +549,7 @@ pub(crate) fn lift_instruction(inst: &Instruction, addr: u64, il: &LowLevelILMut
il.set_reg(size, Register::try_from(*r as u32).unwrap(), il.pop(2))
.append();
} else {
info!("pop: invalid destination operand");
tracing::info!("pop: invalid destination operand");
}
}
Instruction::Ret(_) => {
Expand Down
2 changes: 1 addition & 1 deletion arch/riscv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ license = "Apache-2.0"
binaryninja.workspace = true
binaryninjacore-sys.workspace = true
riscv-dis = { path = "disasm" }
log = "0.4"
rayon = { version = "1.0", optional = true }
tracing = "0.1"

[features]
default = []
Expand Down
12 changes: 5 additions & 7 deletions arch/riscv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@ use binaryninja::{
symbol::{Symbol, SymbolType},
types::{NameAndType, Type},
};
use log::LevelFilter;
use std::borrow::Cow;
use std::fmt;
use std::hash::Hash;
use std::marker::PhantomData;

use binaryninja::architecture::{BranchKind, IntrinsicId, RegisterId};
use binaryninja::confidence::{Conf, MAX_CONFIDENCE, MIN_CONFIDENCE};
use binaryninja::logger::Logger;
use binaryninja::low_level_il::expression::{LowLevelILExpressionKind, ValueExpr};
use binaryninja::low_level_il::instruction::LowLevelILInstructionKind;
use binaryninja::low_level_il::lifting::{
Expand Down Expand Up @@ -228,7 +226,7 @@ impl<'a, D: RiscVDisassembler> LiftableLowLevelILWithSize<'a> for Register<D> {
#[cfg(debug_assertions)]
{
if reg.size() < size {
log::warn!(
tracing::warn!(
"il @ {:x} attempted to lift {} byte register as {} byte expr",
il.current_address(),
reg.size(),
Expand Down Expand Up @@ -2431,23 +2429,23 @@ impl<D: 'static + RiscVDisassembler + Send + Sync> RelocationHandler
}
Self::R_RISCV_TLS_TPREL32 => {
reloc.type_ = RelocationType::UnhandledRelocation;
log::warn!(
tracing::warn!(
"Unhandled relocation type {:?} (R_RISCV_TLS_TPREL32) at {:x?}",
reloc.native_type,
reloc.address
)
}
Self::R_RISCV_TLS_TPREL64 => {
reloc.type_ = RelocationType::UnhandledRelocation;
log::warn!(
tracing::warn!(
"Unhandled relocation type {:?} (R_RISCV_TLS_TPREL64) at {:x?}",
reloc.native_type,
reloc.address
)
}
_ => {
reloc.type_ = RelocationType::UnhandledRelocation;
log::warn!(
tracing::warn!(
"Unknown relocation type {:?} at {:x?}",
reloc.native_type,
reloc.address
Expand Down Expand Up @@ -3014,7 +3012,7 @@ impl FunctionRecognizer for RiscVELFPLTRecognizer {
#[no_mangle]
#[allow(non_snake_case)]
pub extern "C" fn CorePluginInit() -> bool {
Logger::new("RISCV").with_level(LevelFilter::Trace).init();
binaryninja::tracing_init!("RISCV");

use riscv_dis::{RiscVIMACDisassembler, Rv32GRegs, Rv64GRegs};
let arch32 =
Expand Down
2 changes: 1 addition & 1 deletion plugins/dwarf/dwarf_export/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ crate-type = ["cdylib"]
binaryninja.workspace = true
binaryninjacore-sys.workspace = true
gimli = "^0.31"
log = "0.4"
object = { version = "0.32.1", features = ["write"] }
tracing = "0.1"
21 changes: 10 additions & 11 deletions plugins/dwarf/dwarf_export/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
mod edit_distance;

use binaryninja::interaction::form::{Form, FormInputField};
use binaryninja::logger::Logger;
use binaryninja::{
binary_view::{BinaryView, BinaryViewBase, BinaryViewExt},
command::{register_command, Command},
Expand All @@ -17,7 +16,6 @@ use gimli::{
UnitEntryId,
},
};
use log::{error, info, warn, LevelFilter};
use object::{write, Architecture, BinaryFormat, SectionKind};
use std::fs;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -148,7 +146,10 @@ fn export_type(
);
}
None => {
log::warn!("Could not export base struct `{}`", base_struct.ty.name());
tracing::warn!(
"Could not export base struct `{}`",
base_struct.ty.name()
);
}
}
}
Expand Down Expand Up @@ -374,7 +375,7 @@ fn export_type(
Some(typedef_die_uid)
}
} else {
warn!("Could not get target of typedef `{}`", ntr.name());
tracing::warn!("Could not get target of typedef `{}`", ntr.name());
None
}
}
Expand Down Expand Up @@ -703,12 +704,12 @@ fn write_dwarf<T: gimli::Endianity>(

if let Ok(out_data) = out_object.write() {
if let Err(err) = fs::write(file_path, out_data) {
error!("Failed to write DWARF file: {}", err);
tracing::error!("Failed to write DWARF file: {}", err);
} else {
info!("Successfully saved as DWARF to `{:?}`", file_path);
tracing::info!("Successfully saved as DWARF to `{:?}`", file_path);
}
} else {
error!("Failed to write DWARF with requested settings");
tracing::error!("Failed to write DWARF with requested settings");
}

Ok(())
Expand Down Expand Up @@ -785,7 +786,7 @@ fn export_dwarf(bv: &BinaryView) {
};

if let Err(e) = write_dwarf(&save_loc_path, arch, endianness, &mut dwarf) {
error!("Error writing DWARF: {}", e);
tracing::error!("Error writing DWARF: {}", e);
}
}

Expand All @@ -802,9 +803,7 @@ impl Command for MyCommand {

#[no_mangle]
pub extern "C" fn CorePluginInit() -> bool {
Logger::new("DWARF Export")
.with_level(LevelFilter::Debug)
.init();
binaryninja::tracing_init!("DWARF Export");

register_command(
"Export as DWARF",
Expand Down
2 changes: 1 addition & 1 deletion plugins/dwarf/dwarf_import/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ dwarfreader = { path = "../shared/" }
binaryninja.workspace = true
binaryninjacore-sys.workspace = true
gimli = "0.31"
log = "0.4"
iset = "0.2.2"
cpp_demangle = "0.4.3"
regex = "1"
indexmap = "2.5.0"
object = "0.36"
tracing = "0.1"
2 changes: 1 addition & 1 deletion plugins/dwarf/dwarf_import/demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ dwarfreader = { path = "../../shared/" }
binaryninja = { workspace = true, features = ["demo"]}
binaryninjacore-sys.workspace = true
gimli = "0.31"
log = "0.4"
iset = "0.2.2"
cpp_demangle = "0.4.3"
regex = "1"
indexmap = "2.5.0"
object = "0.36"
tracing = "0.1"
30 changes: 15 additions & 15 deletions plugins/dwarf/dwarf_import/src/die_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ pub(crate) fn handle_enum<R: ReaderType>(
let mut tree = match unit.entries_tree(Some(entry.offset())) {
Ok(x) => x,
Err(e) => {
log::error!("Failed to get enum entry tree: {}", e);
tracing::error!("Failed to get enum entry tree: {}", e);
return None;
}
};

let tree_root = match tree.root() {
Ok(x) => x,
Err(e) => {
log::error!("Failed to get enum entry tree root: {}", e);
tracing::error!("Failed to get enum entry tree root: {}", e);
return None;
}
};
Expand All @@ -132,15 +132,15 @@ pub(crate) fn handle_enum<R: ReaderType>(
enumeration_builder.insert(&name, value);
} else {
// Somehow the child entry is not a const value.
log::error!("Unhandled enum member value type for `{}`", name);
tracing::error!("Unhandled enum member value type for `{}`", name);
}
}
Ok(None) => {
// Somehow the child entry does not have a const value.
log::error!("Enum member `{}` has no constant value attribute", name);
tracing::error!("Enum member `{}` has no constant value attribute", name);
}
Err(e) => {
log::error!("Error parsing next attribute entry for `{}`: {}", name, e);
tracing::error!("Error parsing next attribute entry for `{}`: {}", name, e);
return None;
}
}
Expand Down Expand Up @@ -208,7 +208,7 @@ pub(crate) fn handle_pointer<R: ReaderType>(
Some(entry_type_offset) => {
let debug_target_type =
debug_info_builder.get_type(entry_type_offset).or_else(|| {
log::error!(
tracing::error!(
"Failed to get pointer target type at entry offset {}",
entry_type_offset
);
Expand Down Expand Up @@ -255,7 +255,7 @@ pub(crate) fn handle_array<R: ReaderType>(
let parent_type = debug_info_builder
.get_type(entry_type_offset)
.or_else(|| {
log::error!(
tracing::error!(
"Failed to get array member type at entry offset {}",
entry_type_offset
);
Expand All @@ -266,14 +266,14 @@ pub(crate) fn handle_array<R: ReaderType>(
let mut tree = match unit.entries_tree(Some(entry.offset())) {
Ok(x) => x,
Err(e) => {
log::error!("Failed to get array entry tree: {}", e);
tracing::error!("Failed to get array entry tree: {}", e);
return None;
}
};
let tree_root = match tree.root() {
Ok(x) => x,
Err(e) => {
log::error!("Failed to get array entry tree root: {}", e);
tracing::error!("Failed to get array entry tree root: {}", e);
return None;
}
};
Expand Down Expand Up @@ -351,15 +351,15 @@ pub(crate) fn handle_function<R: ReaderType>(
let mut tree = match unit.entries_tree(Some(entry.offset())) {
Ok(x) => x,
Err(e) => {
log::error!("Failed to get function entry tree: {}", e);
tracing::error!("Failed to get function entry tree: {}", e);
return None;
}
};

let tree_root = match tree.root() {
Ok(x) => x,
Err(e) => {
log::error!("Failed to get function entry tree root: {}", e);
tracing::error!("Failed to get function entry tree root: {}", e);
return None;
}
};
Expand All @@ -374,7 +374,7 @@ pub(crate) fn handle_function<R: ReaderType>(
debug_info_builder_context,
debug_info_builder,
) else {
log::error!(
tracing::error!(
"Failed to get function parameter child type in unit {:?} at offset {:x}",
unit.header.offset(),
child.entry().offset().0,
Expand All @@ -384,7 +384,7 @@ pub(crate) fn handle_function<R: ReaderType>(
let name = debug_info_builder_context.get_name(dwarf, unit, child.entry());

let child_debug_type = debug_info_builder.get_type(child_uid).or_else(|| {
log::error!(
tracing::error!(
"Failed to get function parameter type with uid {}",
child_uid
);
Expand Down Expand Up @@ -439,7 +439,7 @@ pub(crate) fn handle_const(
Some(entry_type_offset) => debug_info_builder
.get_type(entry_type_offset)
.or_else(|| {
log::error!(
tracing::error!(
"Failed to get const type with entry offset {}",
entry_type_offset
);
Expand Down Expand Up @@ -469,7 +469,7 @@ pub(crate) fn handle_volatile(
Some(entry_type_offset) => debug_info_builder
.get_type(entry_type_offset)
.or_else(|| {
log::error!(
tracing::error!(
"Failed to get volatile type with entry offset {}",
entry_type_offset
);
Expand Down
Loading
Loading