gdb/riscv: Don't use default bfd to define required features
authorAndrew Burgess <andrew.burgess@embecosm.com>
Thu, 4 Jul 2019 20:02:43 +0000 (21:02 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Tue, 9 Jul 2019 08:41:55 +0000 (09:41 +0100)
When we initialise a gdbarch object we perform a check to try and
detect if the user is doing something silly; trying to run an RV64
binary on an RV32 target.  To perform this check we compare the xlen
from the target description with the xlen specified in the headers on
the ELF being debugged.

If there is no ELF being debugged then we (currently) try to use the
bfd_arch_info from the gdbarch_info object, which will have been set
to the default architecture if no bfd is currently being debugged.
For RISC-V the default architecture is RV64.

What this means is that if a user tries to connect to an RV32 target
without specifying the BFD to debug then GDB will assume RV64.  The
sanity check mentioned above will failed (xlen difference) and GDB
will throw an error.  The error causes GDB to disconnect from the
remote target.

After this commit GDB no longer relies on the default bfd
architecture.  If the user tries to connect without specifying the bfd
then GDB will simply make use of the xlen extracted from the target
description in order to find or create a suitable gdbarch object.

gdb/ChangeLog:

* riscv-tdep.c (riscv_features_from_gdbarch_info): Don't modify
required features based on default bfd type when no specific bfd
is present.

gdb/ChangeLog
gdb/riscv-tdep.c

index 2f406ae2bd044c2ce19e4c45fa7919b52fb0ee67..854eeb5b0e53eb6539b80ddd29baff244134a035 100644 (file)
@@ -1,3 +1,9 @@
+2019-07-09  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * riscv-tdep.c (riscv_features_from_gdbarch_info): Don't modify
+       required features based on default bfd type when no specific bfd
+       is present.
+
 2019-07-08  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
 
        * NEWS: Mention that GDB printf and eval commands can now print
index bae987cf66ba4b052550a8f822ba515ba85797b4..828beea7e2bc3187a630e2d81900e3f1f544773a 100644 (file)
@@ -2917,18 +2917,6 @@ riscv_features_from_gdbarch_info (const struct gdbarch_info info)
       else if (e_flags & EF_RISCV_FLOAT_ABI_SINGLE)
        features.flen = 4;
     }
-  else
-    {
-      const struct bfd_arch_info *binfo = info.bfd_arch_info;
-
-      if (binfo->bits_per_word == 32)
-       features.xlen = 4;
-      else if (binfo->bits_per_word == 64)
-       features.xlen = 8;
-      else
-       internal_error (__FILE__, __LINE__, _("unknown bits_per_word %d"),
-                       binfo->bits_per_word);
-    }
 
   return features;
 }
This page took 0.030634 seconds and 4 git commands to generate.