Skip to content

probestack: add frame pointers for easier traceback #306

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 1 commit into from
Jul 24, 2019
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
7 changes: 7 additions & 0 deletions src/probestack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ pub unsafe extern "C" fn __rust_probestack() {
// The ABI here is that the stack frame size is located in `%eax`. Upon
// return we're not supposed to modify `%esp` or `%eax`.
asm!("
pushq %rbp
movq %rsp, %rbp

mov %rax,%r11 // duplicate %rax as we're clobbering %r11

// Main loop, taken in one page increments. We're decrementing rsp by
Expand Down Expand Up @@ -89,6 +92,7 @@ pub unsafe extern "C" fn __rust_probestack() {
// return.
add %rax,%rsp

leave
ret
" ::: "memory" : "volatile");
::core::intrinsics::unreachable();
Expand All @@ -104,6 +108,8 @@ pub unsafe extern "C" fn __rust_probestack() {
//
// The ABI here is the same as x86_64, except everything is 32-bits large.
asm!("
push %ebp
mov %esp, %ebp
push %ecx
mov %eax,%ecx

Expand All @@ -122,6 +128,7 @@ pub unsafe extern "C" fn __rust_probestack() {

add %eax,%esp
pop %ecx
leave
ret
" ::: "memory" : "volatile");
::core::intrinsics::unreachable();
Expand Down