gdb/riscv: Support c.li in prologue unwinder
authorAndrew Burgess <aburgess@redhat.com>
Sun, 26 Mar 2023 09:42:10 +0000 (09:42 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Tue, 11 Apr 2023 09:11:14 +0000 (10:11 +0100)
commit6abf2eeffa3771cf5dbd30fef79c9b7a8c39b973
treef3a1c20d336a98620670e9d71bda771e6d77ecf1
parent44019209faf3db952a6a04aaeeaa779a8ff7e661
gdb/riscv: Support c.li in prologue unwinder

I was seeing some failures in gdb.threads/omp-par-scope.exp when run
on a riscv64 target.  It turns out the cause of the problem is that I
didn't have debug information installed for libgomp.so, which this
test makes use of.  The test requires GDB to backtrace through a
libgomp function, and the riscv prologue unwinder was failing to
unwind this particular stack frame.

The reason for the failure to unwind was that the function prologue
includes a c.li (compressed load immediate) instruction, and the riscv
prologue scanning unwinder doesn't know what to do with this
instruction, though the unwinder does understand c.lui (compressed
load unsigned immediate).

This commit adds support for c.li.  After this GDB is able to unwind
through libgomp, and I no longer see any unexpected failures in
gdb.threads/omp-par-scope.exp.

I've also included a new test in gdb.arch/ which specifically checks
for our c.li support.
gdb/riscv-tdep.c
gdb/testsuite/gdb.arch/riscv64-unwind-prologue-with-c_li-foo.s [new file with mode: 0644]
gdb/testsuite/gdb.arch/riscv64-unwind-prologue-with-c_li.c [new file with mode: 0644]
gdb/testsuite/gdb.arch/riscv64-unwind-prologue-with-c_li.exp [new file with mode: 0644]