public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] gdb/riscv: Don't use default bfd to define required features
Date: Tue, 09 Jul 2019 08:42:00 -0000	[thread overview]
Message-ID: <20190709084256.37142.qmail@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b3a7d1711e4557811865333a0ac96fc16b750869

commit b3a7d1711e4557811865333a0ac96fc16b750869
Author: Andrew Burgess <andrew.burgess@embecosm.com>
Date:   Thu Jul 4 21:02:43 2019 +0100

    gdb/riscv: Don't use default bfd to define required features
    
    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.

Diff:
---
 gdb/ChangeLog    |  6 ++++++
 gdb/riscv-tdep.c | 12 ------------
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2f406ae..854eeb5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index bae987c..828beea 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -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;
 }


                 reply	other threads:[~2019-07-09  8:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190709084256.37142.qmail@sourceware.org \
    --to=aburgess@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).