Manually add inlined frames in the interpreter stacktrace.
This commit is contained in:
parent
0919ec3ecc
commit
3a423c3feb
3 changed files with 22 additions and 6 deletions
|
@ -949,7 +949,20 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
// This deliberately does *not* honor `requires_caller_location` since it is used for much
|
||||
// more than just panics.
|
||||
for frame in stack.iter().rev() {
|
||||
let span = frame.current_span();
|
||||
let span = match frame.loc {
|
||||
Left(loc) => {
|
||||
// If the stacktrace passes through MIR-inlined source scopes, add them.
|
||||
let mir::SourceInfo { mut span, scope } = *frame.body.source_info(loc);
|
||||
let mut scope_data = &frame.body.source_scopes[scope];
|
||||
while let Some((instance, call_span)) = scope_data.inlined {
|
||||
frames.push(FrameInfo { span, instance });
|
||||
span = call_span;
|
||||
scope_data = &frame.body.source_scopes[scope_data.parent_scope.unwrap()];
|
||||
}
|
||||
span
|
||||
}
|
||||
Right(span) => span,
|
||||
};
|
||||
frames.push(FrameInfo { span, instance: frame.instance });
|
||||
}
|
||||
trace!("generate stacktrace: {:#?}", frames);
|
||||
|
|
|
@ -12,13 +12,13 @@ impl Drop for Foo {
|
|||
|
||||
#[inline(always)]
|
||||
fn has_cleanup() {
|
||||
//~^ ERROR: panic in a function that cannot unwind
|
||||
let _f = Foo;
|
||||
panic!();
|
||||
}
|
||||
|
||||
extern "C" fn panic_abort() {
|
||||
has_cleanup();
|
||||
//~^ ERROR: panic in a function that cannot unwind
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -6,15 +6,18 @@ error: abnormal termination: panic in a function that cannot unwind
|
|||
--> $DIR/terminate-terminator.rs:LL:CC
|
||||
|
|
||||
LL | / fn has_cleanup() {
|
||||
LL | |
|
||||
LL | | let _f = Foo;
|
||||
LL | | panic!();
|
||||
LL | | }
|
||||
| |_^ panic in a function that cannot unwind
|
||||
...
|
||||
LL | has_cleanup();
|
||||
| ------------- in this inlined function call
|
||||
|
|
||||
= note: inside `panic_abort` at $DIR/terminate-terminator.rs:LL:CC
|
||||
= note: inside `has_cleanup` at $DIR/terminate-terminator.rs:LL:CC
|
||||
note: inside `panic_abort`
|
||||
--> $DIR/terminate-terminator.rs:LL:CC
|
||||
|
|
||||
LL | has_cleanup();
|
||||
| ^^^^^^^^^^^^^
|
||||
note: inside `main`
|
||||
--> $DIR/terminate-terminator.rs:LL:CC
|
||||
|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue