gdb/riscv: Improve logic for when h/w float abi should be used
authorAndrew Burgess <andrew.burgess@embecosm.com>
Mon, 3 Dec 2018 17:48:49 +0000 (17:48 +0000)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Wed, 5 Dec 2018 13:23:23 +0000 (13:23 +0000)
commit90af06793e9d391c0aa33994f21bba6971d084f7
tree28fcd0951972d035bf769717b5c193717b248e2e
parent13f2ed32e14311bdcdb9d6efe263486d5d128cfd
gdb/riscv: Improve logic for when h/w float abi should be used

Currently, if the target announces that it has floating point
registers in its target description then GDB assumes that the hardware
float ABI should be used.  However, there's nothing stopping a user
compiling a program for the soft-float abi, and then trying to run
this on a target with hardware floating point registers.

This commit adjusts the logic that decides if GDB should use the
hardware float abi.  The primary decision now is based on what the ELF
currently being executed says in its headers.  If the file was
compiled for h/w float abi, then GDB uses h/w float abi, otherwise s/w
float is used.

If the current BFD is not an ELF then we don't currently have a
mechanism for figuring out if the file was compiled for float or not.
In this case we disable the h/w float abi.  This shouldn't be a
problem as, right now, the RISC-V linker can only produce ELFs.

If there is NO current BFD (can this happen?) then we will enable h/w
float abi if the target has floating point hardware, otherwise, s/w
float abi is used.

This commit also adds some sanity checking that the features requested
in the BFD (xlen and flen) match the target description.

For testing I ran the testsuite on a target that returns a target
description containing both integer and floating point registers, but
used a compiler that didn't have floating point support.  Before this
commit I would see failures on may tests that made inferior calls
using floating point arguments, after this commit, all of these issues
are resolved.  One example from the testsuite is
gdb.base/infcall-nested-structs.exp.

gdb/ChangeLog:

* riscv-tdep.c (riscv_features_from_gdbarch_info): New function.
(riscv_find_default_target_description): Use new function to
extract feature from gdbarch_info.
(riscv_gdbarch_init): Add error checks for xlen and flen between
target description and bfd headers.  Be smarter about when we
think the hardware floating point abi should be used.
gdb/ChangeLog
gdb/riscv-tdep.c
This page took 0.024869 seconds and 4 git commands to generate.