Skip to content

Add multithreading support for libbacktrace #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 16, 2015
Merged
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
5 changes: 4 additions & 1 deletion src/symbolize/libbacktrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ unsafe fn call(data: *mut c_void, sym: &Symbol) {
// that is calculated the first time this is requested. Remember that
// backtracing all happens serially (one global lock).
//
// An additionally oddity in this function is that we initialize the
// An additional oddity in this function is that we initialize the
// filename via self_exe_name() to pass to libbacktrace. It turns out
// that on Linux libbacktrace seamlessly gets the filename of the
// current executable, but this fails on freebsd. by always providing
Expand Down Expand Up @@ -159,6 +159,8 @@ unsafe fn init_state() -> *mut bt::backtrace_state {
}
None => ptr::null(),
};
// Our libbacktrace may not have multithreading support, so
// set `threaded = 0` and synchronize ourselves.
STATE = bt::backtrace_create_state(filename, 0, error_cb,
ptr::null_mut());
});
Expand All @@ -184,6 +186,7 @@ pub fn resolve(symaddr: *mut c_void, mut cb: &mut FnMut(&Symbol)) {
if state.is_null() {
return
}
let _guard = ::lock::lock();

let ret = bt::backtrace_pcinfo(state, symaddr as uintptr_t,
pcinfo_cb, error_cb,
Expand Down