Skip to content

Commit f151812

Browse files
committed
[Rust] Enter more session scoped tracing spans for debug info and binary view callbacks
1 parent 93aa1a8 commit f151812

File tree

2 files changed

+31
-33
lines changed

2 files changed

+31
-33
lines changed

rust/src/custom_binary_view.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,10 @@ where
4848
where
4949
T: CustomBinaryViewType,
5050
{
51-
ffi_wrap!("BinaryViewTypeBase::is_valid_for", unsafe {
52-
let view_type = &*(ctxt as *mut T);
53-
let data = BinaryView::ref_from_raw(BNNewViewReference(data));
54-
55-
view_type.is_valid_for(&data)
56-
})
51+
let view_type = unsafe { &*(ctxt as *mut T) };
52+
let data = unsafe { BinaryView::ref_from_raw(BNNewViewReference(data)) };
53+
let _span = ffi_span!("BinaryViewTypeBase::is_valid_for", data);
54+
view_type.is_valid_for(&data)
5755
}
5856

5957
extern "C" fn cb_deprecated<T>(ctxt: *mut c_void) -> bool
@@ -89,6 +87,7 @@ where
8987
actual_parent: &data,
9088
};
9189

90+
let _span = ffi_span!("BinaryViewTypeBase::create", data);
9291
match view_type.create_custom_view(&data, builder) {
9392
Ok(bv) => {
9493
// force a leak of the Ref; failure to do this would result
@@ -114,6 +113,7 @@ where
114113
actual_parent: &data,
115114
};
116115

116+
let _span = ffi_span!("BinaryViewTypeBase::parse", data);
117117
match view_type.parse_custom_view(&data, builder) {
118118
Ok(bv) => {
119119
// force a leak of the Ref; failure to do this would result
@@ -134,6 +134,7 @@ where
134134
let view_type = &*(ctxt as *mut T);
135135
let data = BinaryView::ref_from_raw(BNNewViewReference(data));
136136

137+
let _span = ffi_span!("BinaryViewTypeBase::load_settings", data);
137138
match view_type.load_settings_for_data(&data) {
138139
Some(settings) => Ref::into_raw(settings).handle,
139140
None => ptr::null_mut() as *mut _,

rust/src/debuginfo.rs

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,10 @@ impl DebugInfoParser {
216216
where
217217
C: CustomDebugInfoParser,
218218
{
219-
ffi_wrap!("CustomDebugInfoParser::is_valid", unsafe {
220-
let cmd = &*(ctxt as *const C);
221-
let view = BinaryView::ref_from_raw(view);
222-
223-
cmd.is_valid(&view)
224-
})
219+
let cmd = unsafe { &*(ctxt as *const C) };
220+
let view = unsafe { BinaryView::ref_from_raw(view) };
221+
let _span = ffi_span!("CustomDebugInfoParser::is_valid", view);
222+
cmd.is_valid(&view)
225223
}
226224

227225
extern "C" fn cb_parse_info<C>(
@@ -235,28 +233,27 @@ impl DebugInfoParser {
235233
where
236234
C: CustomDebugInfoParser,
237235
{
238-
ffi_wrap!("CustomDebugInfoParser::parse_info", unsafe {
239-
let cmd = &*(ctxt as *const C);
240-
let view = BinaryView::ref_from_raw(view);
241-
let debug_file = BinaryView::ref_from_raw(debug_file);
242-
let mut debug_info = DebugInfo::ref_from_raw(debug_info);
243-
244-
cmd.parse_info(
245-
&mut debug_info,
246-
&view,
247-
&debug_file,
248-
Box::new(move |cur: usize, max: usize| match progress {
249-
Some(func) => {
250-
if func(progress_ctxt, cur, max) {
251-
Ok(())
252-
} else {
253-
Err(())
254-
}
236+
let cmd = unsafe { &*(ctxt as *const C) };
237+
let view = unsafe { BinaryView::ref_from_raw(view) };
238+
let debug_file = unsafe { BinaryView::ref_from_raw(debug_file) };
239+
let mut debug_info = unsafe { DebugInfo::ref_from_raw(debug_info) };
240+
241+
let _span = ffi_span!("CustomDebugInfoParser::parse_info", view);
242+
cmd.parse_info(
243+
&mut debug_info,
244+
&view,
245+
&debug_file,
246+
Box::new(move |cur: usize, max: usize| match progress {
247+
Some(func) => unsafe {
248+
if func(progress_ctxt, cur, max) {
249+
Ok(())
250+
} else {
251+
Err(())
255252
}
256-
_ => Ok(()),
257-
}),
258-
)
259-
})
253+
},
254+
_ => Ok(()),
255+
}),
256+
)
260257
}
261258

262259
let name = name.to_cstr();

0 commit comments

Comments
 (0)