Skip to content
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

Ignore more frames on backtrace unwinding. #40264

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use private mangled __rust_begin_short_backtrace_*
  • Loading branch information
Yamakaky committed Mar 23, 2017
commit 8a75b2056f61287e50280edfaf29f769ab343b67
5 changes: 2 additions & 3 deletions src/libstd/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn lang_start(main: fn(), argc: isize, argv: *const *const u8) -> isize {

// Let's run some code!
let res = panic::catch_unwind(|| {
__rust_begin_backtrace_binary(main)
__rust_begin_short_backtrace_binary(main)
});
sys_common::cleanup();
res.is_err()
Expand All @@ -68,8 +68,7 @@ fn lang_start(main: fn(), argc: isize, argv: *const *const u8) -> isize {
}

/// Fixed frame used to clean the backtrace with `RUST_BACKTRACE=1`.
#[no_mangle]
#[inline(never)]
pub fn __rust_begin_backtrace_binary(f: fn()) {
fn __rust_begin_short_backtrace_binary(f: fn()) {
f()
}
10 changes: 2 additions & 8 deletions src/libstd/sys_common/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,6 @@ fn filter_frames(frames: &[Frame],
"mingw_set_invalid_parameter_handler",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and drop above should be removed

];

// All the frames after these symbols will be removed.
// See `rt.rs` and `libtest` for their generation.
static BAD_PREFIXES_BOTTOM: &'static [&'static str] = &[
"__rust_begin_backtrace_binary",
"__rust_begin_backtrace_test",
];

let is_good_frame = |frame: Frame, bad_prefixes: &[&str]| {
resolve_symname(frame, |symname| {
if let Some(mangled_symbol_name) = symname {
Expand All @@ -154,7 +147,8 @@ fn filter_frames(frames: &[Frame],
let mut is_marker = false;
let _ = resolve_symname(*frame, |symname| {
if let Some(mangled_symbol_name) = symname {
if BAD_PREFIXES_BOTTOM.iter().any(|s| mangled_symbol_name.contains(s)) {
// Use grep to find the concerned functions
if mangled_symbol_name.contains("__rust_begin_short_backtrace_") {
is_marker = true;
}
}
Expand Down
10 changes: 4 additions & 6 deletions src/libtest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1365,24 +1365,22 @@ pub fn run_test(opts: &TestOpts,
}
DynTestFn(f) =>
run_test_inner(desc, monitor_ch, opts.nocapture,
Box::new(move |()| __rust_begin_backtrace_test_boxfn(f))),
Box::new(move |()| __rust_begin_short_backtrace_test_boxfn(f))),
StaticTestFn(f) =>
run_test_inner(desc, monitor_ch, opts.nocapture,
Box::new(move |()| __rust_begin_backtrace_test(f))),
Box::new(move |()| __rust_begin_short_backtrace_test(f))),
}
}

/// Fixed frame used to clean the backtrace with `RUST_BACKTRACE=1`.
#[no_mangle]
#[inline(never)]
pub fn __rust_begin_backtrace_test_boxfn(f: Box<FnBox<()>>) {
fn __rust_begin_short_backtrace_test_boxfn(f: Box<FnBox<()>>) {
f.call_box(())
}

/// Fixed frame used to clean the backtrace with `RUST_BACKTRACE=1`.
#[no_mangle]
#[inline(never)]
pub fn __rust_begin_backtrace_test(f: fn()) {
fn __rust_begin_short_backtrace_test(f: fn()) {
f()
}

Expand Down