|
| 1 | +From 5b08e0c06e038448a63aa9bd7f163b23d824ba4b Mon Sep 17 00:00:00 2001 |
| 2 | +From: Ben Gamari < [email protected]> |
| 3 | +Date: Mon, 3 Feb 2020 09:27:42 -0500 |
| 4 | +Subject: [PATCH] StgCRun: Enable unwinding only on Linux |
| 5 | + |
| 6 | +It's broken on macOS due and SmartOS due to assembler differences |
| 7 | +(#15207) so let's be conservative in enabling it. Also, refactor things |
| 8 | +to make the intent clearer. |
| 9 | +--- |
| 10 | + rts/StgCRun.c | 15 +++++++++++---- |
| 11 | + 1 file changed, 11 insertions(+), 4 deletions(-) |
| 12 | + |
| 13 | +diff --git a/rts/StgCRun.c b/rts/StgCRun.c |
| 14 | +index 2600f1e569ca..55a3bf0c2d97 100644 |
| 15 | +--- a/rts/StgCRun.c |
| 16 | ++++ b/rts/StgCRun.c |
| 17 | +@@ -29,6 +29,13 @@ |
| 18 | + #include "PosixSource.h" |
| 19 | + #include "ghcconfig.h" |
| 20 | + |
| 21 | ++// Enable DWARF Call-Frame Information (used for stack unwinding) on Linux. |
| 22 | ++// This is not supported on Darwin and SmartOS due to assembler differences |
| 23 | ++// (#15207). |
| 24 | ++#if defined(linux_HOST_OS) |
| 25 | ++#define ENABLE_UNWINDING |
| 26 | ++#endif |
| 27 | ++ |
| 28 | + #if defined(sparc_HOST_ARCH) || defined(USE_MINIINTERPRETER) |
| 29 | + /* include Stg.h first because we want real machine regs in here: we |
| 30 | + * have to get the value of R1 back from Stg land to C land intact. |
| 31 | +@@ -405,7 +412,7 @@ StgRunIsImplementedInAssembler(void) |
| 32 | + "movq %%xmm15,136(%%rax)\n\t" |
| 33 | + #endif |
| 34 | + |
| 35 | +-#if !defined(darwin_HOST_OS) |
| 36 | ++#if defined(ENABLE_UNWINDING) |
| 37 | + /* |
| 38 | + * Let the unwinder know where we saved the registers |
| 39 | + * See Note [Unwinding foreign exports on x86-64]. |
| 40 | +@@ -444,7 +451,7 @@ StgRunIsImplementedInAssembler(void) |
| 41 | + #error "RSP_DELTA too big" |
| 42 | + #endif |
| 43 | + "\n\t" |
| 44 | +-#endif /* !defined(darwin_HOST_OS) */ |
| 45 | ++#endif /* defined(ENABLE_UNWINDING) */ |
| 46 | + |
| 47 | + /* |
| 48 | + * Set BaseReg |
| 49 | +@@ -519,7 +526,7 @@ StgRunIsImplementedInAssembler(void) |
| 50 | + "i"(RESERVED_C_STACK_BYTES + STG_RUN_STACK_FRAME_SIZE |
| 51 | + /* rip relative to cfa */) |
| 52 | + |
| 53 | +-#if !defined(darwin_HOST_OS) |
| 54 | ++#if defined(ENABLE_UNWINDING) |
| 55 | + , "i"((RSP_DELTA & 127) | (128 * ((RSP_DELTA >> 7) > 0))) |
| 56 | + /* signed LEB128-encoded delta from rsp - byte 1 */ |
| 57 | + #if (RSP_DELTA >> 7) > 0 |
| 58 | +@@ -538,7 +545,7 @@ StgRunIsImplementedInAssembler(void) |
| 59 | + #endif |
| 60 | + #undef RSP_DELTA |
| 61 | + |
| 62 | +-#endif /* !defined(darwin_HOST_OS) */ |
| 63 | ++#endif /* defined(ENABLE_UNWINDING) */ |
| 64 | + |
| 65 | + ); |
| 66 | + /* |
0 commit comments