[Lldb-commits] [lldb] [lldb/aarch64] Fix unwinding when signal interrupts a leaf function (PR #91321)
Jason Molenda via lldb-commits
lldb-commits at lists.llvm.org
Fri May 10 16:47:18 PDT 2024
jasonmolenda wrote:
Ah, I misunderstood what the nature of the failure was. I tried running the shell test, and it's failing for different reasons. I almost never touch shell tests, I find them really hard to debug so I'm not sure what the problem is. If I run it by hand,
```
(lldb) settings set platform.plugin.darwin.ignored-exceptions EXC_BAD_INSTRUCTION
(lldb) b sigill_handler
Breakpoint 1: where = a.out`sigill_handler + 20 at signal-in-leaf-function-aarch64.c:10:34, address = 0x0000000100003f4c
(lldb) r
Process 25854 launched: '/tmp/a.out' (arm64)
Process 25854 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGILL
frame #0: 0x0000000100003f2c a.out`signal_generating_add at signal-in-leaf-function-aarch64.c:5:3
2 #include <unistd.h>
3
4 int __attribute__((naked)) signal_generating_add(int a, int b) {
-> 5 asm("add w0, w1, w0\n\t"
6 "udf #0xdead\n\t"
7 "ret");
8 }
(lldb) c
Process 25854 resuming
Process 25854 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100003f4c a.out`sigill_handler(signo=4) at signal-in-leaf-function-aarch64.c:10:34
7 "ret");
8 }
9
-> 10 void sigill_handler(int signo) { _exit(0); }
11
12 int main() {
13 signal(SIGILL, sigill_handler);
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
* frame #0: 0x0000000100003f4c a.out`sigill_handler(signo=4) at signal-in-leaf-function-aarch64.c:10:34
frame #1: 0x0000000197f93584 libsystem_platform.dylib`_sigtramp + 56
frame #2: 0x0000000100003f7c a.out`main at signal-in-leaf-function-aarch64.c:14:3
frame #3: 0x0000000197bda0e0 dyld`start + 2360
(lldb)
```
which all looks good to me, but it the shell test fails with
```
/Volumes/work/llvm/llvm-project/lldb/test/Shell/Unwind/signal-in-leaf-function-aarch64.test:26:10: error: CHECK: expected string not found in input
# CHECK: frame #{{[0-9]+}}: [[ADD]] {{.*}}`signal_generating_add
^
<stdin>:32:86: note: scanning from here
frame #0: 0x0000000100003f38 signal-in-leaf-function-aarch64.test.tmp`sigill_handler
^
<stdin>:32:86: note: with "ADD" equal to "0x0000000100003f2c"
frame #0: 0x0000000100003f38 signal-in-leaf-function-aarch64.test.tmp`sigill_handler
^
<stdin>:33:23: note: possible intended match here
signal-in-leaf-function-aarch64.test.tmp`sigill_handler:
^
Input file: <stdin>
Check file: /Volumes/work/llvm/llvm-project/lldb/test/Shell/Unwind/signal-in-leaf-function-aarch64.test
-dump-input=help explains the following input dump.
Input was:
<<<<<<
.
.
.
27: frame #2: 0x0000000197bda0e0 dyld`start + 2360
28: (lldb) continue
29: Process 23467 resuming
30: Process 23467 stopped
31: * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
32: frame #0: 0x0000000100003f38 signal-in-leaf-function-aarch64.test.tmp`sigill_handler
check:26'0 X error: no match found
check:26'1 with "ADD" equal to "0x0000000100003f2c"
33: signal-in-leaf-function-aarch64.test.tmp`sigill_handler:
check:26'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:26'2 ? possible intended match
34: -> 0x100003f38 <+0>: sub sp, sp, #0x20
check:26'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
35: 0x100003f3c <+4>: stp x29, x30, [sp, #0x10]
check:26'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36: 0x100003f40 <+8>: add x29, sp, #0x10
check:26'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37: 0x100003f44 <+12>: stur w0, [x29, #-0x4]
check:26'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38: (lldb) thread backtrace
check:26'0 ~~~~~~~~~~~~~~~~~~~~~~~~
.
.
.
>>>>>>
```
https://github.com/llvm/llvm-project/pull/91321
More information about the lldb-commits
mailing list