]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
RISC-V/Linux/native: Determine FLEN dynamically
authorMaciej W. Rozycki <macro@wdc.com>
Mon, 3 Feb 2020 12:07:02 +0000 (12:07 +0000)
committerMaciej W. Rozycki <macro@wdc.com>
Mon, 3 Feb 2020 12:07:02 +0000 (12:07 +0000)
commitee98c0daf93476e323134492cf604e71b05ca883
tree35eaf43d8c9642e3e260cb2142f1b842bf3189c9
parentb0029748ca991c64cf9f0851217b7762e4877854
RISC-V/Linux/native: Determine FLEN dynamically

Fix RISC-V native Linux support to handle a 64-bit FPU (FLEN == 64) with
both RV32 and RV64 systems, which is a part of the current Linux ABI for
hard-float systems, rather than assuming that (FLEN == XLEN) in target
description determination and that (FLEN == 64) in register access.

We can do better however and not rely on any particular value of FLEN
and probe for it dynamically, by observing that the PTRACE_GETREGSET
ptrace(2) call will only accept an exact regset size, and that will
reflect FLEN.  Therefore iterate over the call in target description
determination with a geometrically increasing regset size until a match
is marked by a successful ptrace(2) call completion or we run beyond the
maximum size we can support.

Update register accessors accordingly, using FLEN determined to size the
buffer used for NT_PRSTATUS requests and then to exchange data with the
regcache.

Also handle a glibc bug where ELF_NFPREG is defined in terms of NFPREG,
however NFPREG is nowhere defined.

gdb/
* riscv-linux-nat.c [!NFPREG] (NFPREG): New macro.
(supply_fpregset_regnum, fill_fpregset): Handle regset buffer
offsets according to FLEN determined.
(riscv_linux_nat_target::read_description): Determine FLEN
dynamically.
(riscv_linux_nat_target::fetch_registers): Size regset buffer
according to FLEN determined.
(riscv_linux_nat_target::store_registers): Likewise.
gdb/ChangeLog
gdb/riscv-linux-nat.c