public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Fix regression from gdbarch registry change
Date: Mon,  8 Aug 2022 16:06:48 +0000 (GMT)	[thread overview]
Message-ID: <20220808160648.0E6A53857004@sourceware.org> (raw)

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

commit ce81f9d6fa885a3faa41613debc8771304dc469b
Author: Tom Tromey <tromey@adacore.com>
Date:   Mon Aug 8 09:56:47 2022 -0600

    Fix regression from gdbarch registry change
    
    The gdbarch registry patch introduced a regression that could cause a
    crash when opening files in gdb.  The bug is that, previously, the
    solib ops would default to current_target_so_ops; but the patch
    changed this code to default to nullptr.  This patch fixes the bug by
    reintroducing the earlier behavior.  This is PR gdb/29449.
    
    I managed to reproduce the bug with a riscv-elf build and then
    verified that this fixes the problem.
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29449

Diff:
---
 gdb/solib.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gdb/solib.c b/gdb/solib.c
index d889673dabf..25adf586a02 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -64,7 +64,13 @@ static const registry<gdbarch>::key<const struct target_so_ops,
 static const struct target_so_ops *
 solib_ops (struct gdbarch *gdbarch)
 {
-  return solib_data.get (gdbarch);
+  const struct target_so_ops *result = solib_data.get (gdbarch);
+  if (result == nullptr)
+    {
+      result = current_target_so_ops;
+      set_solib_ops (gdbarch, current_target_so_ops);
+    }
+  return result;
 }
 
 /* Set the solib operations for GDBARCH to NEW_OPS.  */


                 reply	other threads:[~2022-08-08 16:06 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=20220808160648.0E6A53857004@sourceware.org \
    --to=tromey@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).