gdb/riscv: use a single regset supply function for riscv fbsd & linux
authorAndrew Burgess <andrew.burgess@embecosm.com>
Wed, 2 Dec 2020 15:10:06 +0000 (15:10 +0000)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Mon, 18 Jan 2021 14:14:11 +0000 (14:14 +0000)
commit6a9ad81c449922e8c0d3228c18422f68136eef17
tree7d9dfb01516aed307b3f1531b8a00dc12296ff0c
parent326adec374dd43086dbf9bb2b8f18d547389e678
gdb/riscv: use a single regset supply function for riscv fbsd & linux

The RISC-V x0 register is hard-coded to zero.  As such neither Linux
or FreeBSD supply the value of the register x0 in their core dump
files.

For FreeBSD we take care of this by manually supplying the value of x0
in riscv_fbsd_supply_gregset, however we don't do this for Linux.  As
a result after loading a core file on Linux we see this behaviour:

  (gdb) p $x0
  $1 = <unavailable>

In this commit I make riscv_fbsd_supply_gregset a common function that
can be shared between RISC-V for FreeBSD and Linux, this resolves the
above issue.

There is a similar problem for the two registers `fflags` and `frm`.
These two floating point related CSRs are a little weird.  They are
separate CSRs in the RISC-V specification, but are actually sub-fields
of the `fcsr` CSR.

As a result neither Linux or FreeBSD supply the `fflags` or `frm`
registers as separate fields in their core dumps, and so, after
restoring a core dump these register are similarly unavailable.

In this commit I supply `fflags` and `frm` by first asking for the
value of `fcsr`, extracting the two fields, and using these to supply
the values for `fflags` and `frm`.

gdb/ChangeLog:

* riscv-fbsd-tdep.c (riscv_fbsd_supply_gregset): Delete.
(riscv_fbsd_gregset): Use riscv_supply_regset.
(riscv_fbsd_fpregset): Likewise.
* riscv-linux-tdep.c (riscv_linux_gregset): Likewise.
(riscv_linux_fregset): Likewise.
* riscv-tdep.c (riscv_supply_regset): Define new function.
* riscv-tdep.h (riscv_supply_regset): Declare new function.
gdb/ChangeLog
gdb/riscv-fbsd-tdep.c
gdb/riscv-linux-tdep.c
gdb/riscv-tdep.c
gdb/riscv-tdep.h
This page took 0.02535 seconds and 4 git commands to generate.