Merge pull request #306 from da-x/probestack-frame-pointer

probestack: add frame pointers for easier traceback
This commit is contained in:
Alex Crichton 2019-07-24 09:04:02 -05:00 committed by GitHub
commit c8b08eb470
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -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
@ -89,6 +92,7 @@ pub unsafe extern "C" fn __rust_probestack() {
// return.
add %rax,%rsp
leave
ret
" ::: "memory" : "volatile");
::core::intrinsics::unreachable();
@ -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
@ -122,6 +128,7 @@ pub unsafe extern "C" fn __rust_probestack() {
add %eax,%esp
pop %ecx
leave
ret
" ::: "memory" : "volatile");
::core::intrinsics::unreachable();