Skip to content

Commit 471b4d6

Browse files
committed
rt: Use a DWARF CFI scheme that works on mac in __morestack
1 parent 7da8ab8 commit 471b4d6

File tree

3 files changed

+34
-24
lines changed

3 files changed

+34
-24
lines changed

src/rt/arch/i386/morestack.S

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ MORESTACK:
5353

5454
pushl %ebp
5555
#if defined(__linux__) || defined(__APPLE__)
56-
.cfi_def_cfa_offset 8
57-
.cfi_offset %ebp, -8
56+
.cfi_def_cfa_offset 20
57+
.cfi_offset %ebp, -20
5858
#endif
5959
movl %esp, %ebp
6060
#if defined(__linux__) || defined(__APPLE__)
@@ -79,16 +79,6 @@ MORESTACK:
7979
testl %eax,%eax
8080
jz .L$bail
8181

82-
// During unwinding we want to skip our caller.
83-
#if defined(__linux__) || defined(__APPLE__)
84-
// Don't understand this line. I think it means that
85-
// the next frame's pc is the return address of our caller.
86-
.cfi_offset 8, 8
87-
// The next frame's esp is stored at our CFA - 12
88-
// (by the code below)
89-
.cfi_offset %esp, -12
90-
#endif
91-
9282
// Save the the correct %esp value for our grandparent frame,
9383
// for the unwinder
9484
leal 20(%ebp), %eax
@@ -156,7 +146,7 @@ MORESTACK:
156146
popl %ebp
157147
#if defined(__linux__) || defined(__APPLE__)
158148
.cfi_restore %ebp
159-
.cfi_def_cfa %esp, 4
149+
.cfi_def_cfa %esp, 16
160150
#endif
161151
retl $8
162152

src/rt/arch/x86_64/morestack.S

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,11 @@ MORESTACK:
5454

5555
// Set up a normal backtrace
5656
pushq %rbp
57-
.cfi_def_cfa_offset 16
58-
.cfi_offset %rbp, -16
57+
.cfi_def_cfa_offset 24
58+
.cfi_offset %rbp, -24
5959
movq %rsp, %rbp
6060
.cfi_def_cfa_register %rbp
6161

62-
// During unwinding we want to skip our caller since it's not
63-
// a complete frame and will make the unwinder sad
64-
// Don't understand this line
65-
.cfi_offset 16, 0
66-
// Tell the unwinding where to get the stack pointer for
67-
// our grandparent frame
68-
.cfi_offset %rsp, -24
69-
7062
// Save the grandparent stack pointer for the unwinder
7163
leaq 24(%rbp), %rax
7264
pushq %rax
@@ -140,7 +132,7 @@ MORESTACK:
140132
addq $8, %rsp
141133
popq %rbp
142134
.cfi_restore %rbp
143-
.cfi_def_cfa %rsp, 8
135+
.cfi_def_cfa %rsp, 16
144136
ret
145137

146138
.cfi_endproc

src/test/run-fail/morestack4.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// xfail-test
2+
// error-pattern:explicit failure
3+
// compile-flags:--stack-growth
4+
5+
// Just testing unwinding
6+
7+
use std;
8+
9+
native mod rustrt {
10+
fn set_min_stack(size: uint);
11+
}
12+
13+
fn getbig_and_fail(&&i: int) {
14+
let r = and_then_get_big_again(@0);
15+
if i != 0 {
16+
getbig_and_fail(i - 1);
17+
} else {
18+
fail;
19+
}
20+
}
21+
22+
resource and_then_get_big_again(_i: @int) {
23+
}
24+
25+
fn main() {
26+
rustrt::set_min_stack(256u);
27+
task::spawn(1, getbig_and_fail);
28+
}

0 commit comments

Comments
 (0)