]> git.lizzy.rs Git - rust.git/commitdiff
rt: Use a DWARF CFI scheme that works on mac in __morestack
authorBrian Anderson <banderson@mozilla.com>
Sat, 17 Dec 2011 21:51:35 +0000 (13:51 -0800)
committerBrian Anderson <banderson@mozilla.com>
Sat, 17 Dec 2011 22:10:44 +0000 (14:10 -0800)
src/rt/arch/i386/morestack.S
src/rt/arch/x86_64/morestack.S
src/test/run-fail/morestack4.rs [new file with mode: 0644]

index 6d67984c91b9b7d3089a2ba8888873b4f2dd21e1..6e53ef850a0297ce40920312c694fe3fce67a7b2 100644 (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
 
index 369e4a340e026d13fe932d5a47e15d35efbfa53f..5378a1dcc60fcef095aceab6aa5438e6c90c1c26 100644 (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
diff --git a/src/test/run-fail/morestack4.rs b/src/test/run-fail/morestack4.rs
new file mode 100644 (file)
index 0000000..87c5ac5
--- /dev/null
@@ -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);
+}
\ No newline at end of file