You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
riscv/crt0: Add .cfi_* annotations to allow GDB to unwind out of _trap
We have to tell GDB about the correct "return" address (mepc) as well as
the saved stack pointer to continue unwinding beyond the current frame.
With this change and a __builtin_trap added to fclose(), I get the
following mostly-sensible (unwinding fails one frame up) backtrace
when breaking at the end of _trap:
```
$ gdb -q test/test-fopen '-ex=b crt0.c:169' '-ex=target remote :1234' -ex=c -ex=bt
Reading symbols from test/test-fopen...
Breakpoint 1 at 0x800001c0: file ../../picolibc/picocrt/machine/riscv/crt0.c, line 169.
Remote debugging using :1234
0x0000000000001000 in ?? ()
Continuing.
Breakpoint 1, _trap () at ../../picolibc/picocrt/machine/riscv/crt0.c:169
169 __asm__("j _ctrap");
#0 _trap () at ../../picolibc/picocrt/machine/riscv/crt0.c:169
#1 0x00000000800013d0 in fclose (f=0x0) at ../../picolibc/newlib/libc/tinystdio/fclose.c:39
#2 0x0000000000000000 in ?? ()
Backtrace stopped: frame did not save the PC
```
0 commit comments