rt: Make unwinding through __morestack work on mac

Had to bump the min stack size in some of the tests from 256 bytes
to 1024 bytes. Not sure why yet.
This commit is contained in:
Brian Anderson 2011-12-11 17:50:12 -08:00
parent 7bc34f63d8
commit 7a8e73662d
4 changed files with 9 additions and 21 deletions

View File

@ -47,17 +47,17 @@
#endif #endif
MORESTACK: MORESTACK:
#ifdef __linux__ #if defined(__linux__) || defined(__APPLE__)
.cfi_startproc .cfi_startproc
#endif #endif
pushl %ebp pushl %ebp
#ifdef __linux__ #if defined(__linux__) || defined(__APPLE__)
.cfi_def_cfa_offset 8 .cfi_def_cfa_offset 8
.cfi_offset %ebp, -8 .cfi_offset %ebp, -8
#endif #endif
movl %esp, %ebp movl %esp, %ebp
#ifdef __linux__ #if defined(__linux__) || defined(__APPLE__)
.cfi_def_cfa_register %ebp .cfi_def_cfa_register %ebp
#endif #endif
@ -69,7 +69,7 @@ MORESTACK:
jz .L$bail jz .L$bail
// During unwinding we want to skip our caller. // During unwinding we want to skip our caller.
#ifdef __linux__ #if defined(__linux__) || defined(__APPLE__)
// Don't understand this line. I think it means that // Don't understand this line. I think it means that
// the next frame's pc is the return address of our caller. // the next frame's pc is the return address of our caller.
.cfi_offset 8, 8 .cfi_offset 8, 8
@ -134,7 +134,7 @@ MORESTACK:
addl $16,%esp addl $16,%esp
popl %ebp popl %ebp
#ifdef __linux__ #if defined(__linux__) || defined(__APPLE__)
.cfi_restore %ebp .cfi_restore %ebp
.cfi_def_cfa %esp, 4 .cfi_def_cfa %esp, 4
#endif #endif
@ -150,7 +150,7 @@ MORESTACK:
jmpl *%edx jmpl *%edx
#ifdef __linux__ #if defined(__linux__) || defined(__APPLE__)
.cfi_endproc .cfi_endproc
#endif #endif

View File

@ -50,30 +50,22 @@
#if defined(__linux__) || defined(__APPLE__) #if defined(__linux__) || defined(__APPLE__)
MORESTACK: MORESTACK:
#if defined(__ELF__)
.cfi_startproc .cfi_startproc
#endif
// Set up a normal backtrace // Set up a normal backtrace
pushq %rbp pushq %rbp
#if defined(__ELF__)
.cfi_def_cfa_offset 16 .cfi_def_cfa_offset 16
.cfi_offset %rbp, -16 .cfi_offset %rbp, -16
#endif
movq %rsp, %rbp movq %rsp, %rbp
#if defined(__ELF__)
.cfi_def_cfa_register %rbp .cfi_def_cfa_register %rbp
#endif
// During unwinding we want to skip our caller since it's not // During unwinding we want to skip our caller since it's not
// a complete frame and will make the unwinder sad // a complete frame and will make the unwinder sad
#if defined(__linux__)
// Don't understand this line // Don't understand this line
.cfi_offset 16, 0 .cfi_offset 16, 0
// Tell the unwinding where to get the stack pointer for // Tell the unwinding where to get the stack pointer for
// our grandparent frame // our grandparent frame
.cfi_offset %rsp, -24 .cfi_offset %rsp, -24
#endif
// Save the grandparent stack pointer for the unwinder // Save the grandparent stack pointer for the unwinder
leaq 16(%rbp), %rax leaq 16(%rbp), %rax
@ -147,15 +139,11 @@ MORESTACK:
addq $8, %rsp addq $8, %rsp
popq %rbp popq %rbp
#ifdef __linux__
.cfi_restore %rbp .cfi_restore %rbp
.cfi_def_cfa %rsp, 8 .cfi_def_cfa %rsp, 8
#endif
ret ret
#if defined(__ELF__)
.cfi_endproc .cfi_endproc
#endif
#else #else
MORESTACK: MORESTACK:

View File

@ -33,7 +33,7 @@ resource and_then_get_big_again(_i: ()) {
} }
fn main() { fn main() {
rustrt::set_min_stack(256u); rustrt::set_min_stack(1024u);
std::task::spawn((), fn (&&_i: ()) { std::task::spawn((), fn (&&_i: ()) {
let r = and_then_get_big_again(()); let r = and_then_get_big_again(());
getbig_call_c_and_fail(10000); getbig_call_c_and_fail(10000);

View File

@ -29,6 +29,6 @@ resource and_then_get_big_again(_i: @int) {
} }
fn main() { fn main() {
rustrt::set_min_stack(256u); rustrt::set_min_stack(1024u);
std::task::spawn(100, getbig_and_fail); std::task::spawn(400, getbig_and_fail);
} }