Skip to content

Commit 985a430

Browse files
committed
probestack: add frame pointers for easier traceback
This turns the following backtrace, ``` >> bt #0 0x0000555555576f73 in __rust_probestack () at /cargo/registry/src/jiasu.xzqcsaa.nyc.mn-1ecc6299db9ec823/compiler_builtins-0.1.14/src/probestack.rs:55 Backtrace stopped: Cannot access memory at address 0x7fffff7fedf0 ``` To this: ``` >>> bt #0 0x0000555555574e47 in __rust_probestack () #1 0x00005555555595ba in test::main () #2 0x00005555555594f3 in std::rt::lang_start::{{closure}} () #3 0x0000555555561ae3 in std::panicking::try::do_call () #4 0x000055555556595a in __rust_maybe_catch_panic () #5 0x000055555555af9b in std::rt::lang_start_internal () #6 0x00005555555594d5 in std::rt::lang_start () #7 0x000055555555977b in main () ```
1 parent 6566ad9 commit 985a430

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/probestack.rs

+7
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ pub unsafe extern "C" fn __rust_probestack() {
5353
// The ABI here is that the stack frame size is located in `%eax`. Upon
5454
// return we're not supposed to modify `%esp` or `%eax`.
5555
asm!("
56+
pushq %rbp
57+
movq %rsp, %rbp
58+
5659
mov %rax,%r11 // duplicate %rax as we're clobbering %r11
5760
5861
// Main loop, taken in one page increments. We're decrementing rsp by
@@ -89,6 +92,7 @@ pub unsafe extern "C" fn __rust_probestack() {
8992
// return.
9093
add %rax,%rsp
9194
95+
leave
9296
ret
9397
" ::: "memory" : "volatile");
9498
::core::intrinsics::unreachable();
@@ -104,6 +108,8 @@ pub unsafe extern "C" fn __rust_probestack() {
104108
//
105109
// The ABI here is the same as x86_64, except everything is 32-bits large.
106110
asm!("
111+
push %ebp
112+
mov %esp, %ebp
107113
push %ecx
108114
mov %eax,%ecx
109115
@@ -122,6 +128,7 @@ pub unsafe extern "C" fn __rust_probestack() {
122128
123129
add %eax,%esp
124130
pop %ecx
131+
leave
125132
ret
126133
" ::: "memory" : "volatile");
127134
::core::intrinsics::unreachable();

0 commit comments

Comments
 (0)