rt: Use a DWARF CFI scheme that works on mac in __morestack

This commit is contained in:
Brian Anderson 2011-12-17 13:51:35 -08:00
parent 7da8ab8fab
commit 471b4d6e58
3 changed files with 34 additions and 24 deletions

View file

@ -53,8 +53,8 @@ MORESTACK:
pushl %ebp
#if defined(__linux__) || defined(__APPLE__)
.cfi_def_cfa_offset 8
.cfi_offset %ebp, -8
.cfi_def_cfa_offset 20
.cfi_offset %ebp, -20
#endif
movl %esp, %ebp
#if defined(__linux__) || defined(__APPLE__)
@ -79,16 +79,6 @@ MORESTACK:
testl %eax,%eax
jz .L$bail
// During unwinding we want to skip our caller.
#if defined(__linux__) || defined(__APPLE__)
// Don't understand this line. I think it means that
// the next frame's pc is the return address of our caller.
.cfi_offset 8, 8
// The next frame's esp is stored at our CFA - 12
// (by the code below)
.cfi_offset %esp, -12
#endif
// Save the the correct %esp value for our grandparent frame,
// for the unwinder
leal 20(%ebp), %eax
@ -156,7 +146,7 @@ MORESTACK:
popl %ebp
#if defined(__linux__) || defined(__APPLE__)
.cfi_restore %ebp
.cfi_def_cfa %esp, 4
.cfi_def_cfa %esp, 16
#endif
retl $8

View file

@ -54,19 +54,11 @@ MORESTACK:
// Set up a normal backtrace
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
.cfi_def_cfa_offset 24
.cfi_offset %rbp, -24
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
// During unwinding we want to skip our caller since it's not
// a complete frame and will make the unwinder sad
// Don't understand this line
.cfi_offset 16, 0
// Tell the unwinding where to get the stack pointer for
// our grandparent frame
.cfi_offset %rsp, -24
// Save the grandparent stack pointer for the unwinder
leaq 24(%rbp), %rax
pushq %rax
@ -140,7 +132,7 @@ MORESTACK:
addq $8, %rsp
popq %rbp
.cfi_restore %rbp
.cfi_def_cfa %rsp, 8
.cfi_def_cfa %rsp, 16
ret
.cfi_endproc

View file

@ -0,0 +1,28 @@
// xfail-test
// error-pattern:explicit failure
// compile-flags:--stack-growth
// Just testing unwinding
use std;
native mod rustrt {
fn set_min_stack(size: uint);
}
fn getbig_and_fail(&&i: int) {
let r = and_then_get_big_again(@0);
if i != 0 {
getbig_and_fail(i - 1);
} else {
fail;
}
}
resource and_then_get_big_again(_i: @int) {
}
fn main() {
rustrt::set_min_stack(256u);
task::spawn(1, getbig_and_fail);
}