gdb: Support the c.mv insn in the riscv prologue scanner.
authorLancelot SIX <lsix@lancelotsix.com>
Mon, 27 Sep 2021 21:56:58 +0000 (21:56 +0000)
committerLancelot SIX <lsix@lancelotsix.com>
Sun, 3 Oct 2021 14:00:58 +0000 (14:00 +0000)
commit2b014cc535e9d8eeb2203b1f5e9fd5c5e8fb5028
treedeac1d41f717e0b6c198964e868fee9e70bb7d23
parentd4e8e096a57a6384a5e0e97ade6f77bf1d418a90
gdb: Support the c.mv insn in the riscv prologue scanner.

While working on other problems, I encountered situations where GDB
fails to properly unwind the stack because some functions use the C.MV
instruction in the prologue.  The prologue scanner stops when it hits
this instruction assuming its job is done at this point.  Unfortunately
the prologue is not necessarily finished yet, preventing GDB to properly
unwind.

This commit adds support for handling such instruction in
riscv_scan_prologue.

Note that C.MV is part of the compressed instruction set.  The MV
counterpart from the base ISA is a pseudo instruction that expands to
'ADDI RD,RS1,0' which is already supported.

Tested on riscv64-linux-gnu.

All feedback are welcome.
gdb/riscv-tdep.c
gdb/testsuite/gdb.arch/riscv64-unwind-prologue-with-mv.c [new file with mode: 0644]
gdb/testsuite/gdb.arch/riscv64-unwind-prologue-with-mv.exp [new file with mode: 0644]
gdb/testsuite/gdb.arch/riscv64-unwind-prologue-with-mv.s [new file with mode: 0644]