Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [pushed] Fix regression from gdbarch registry change
@ 2022-08-08 16:06 Tom Tromey via Gdb-patches
  0 siblings, 0 replies; only message in thread
From: Tom Tromey via Gdb-patches @ 2022-08-08 16:06 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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
---
 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.  */
-- 
2.34.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-08 16:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-08 16:06 [pushed] Fix regression from gdbarch registry change Tom Tromey via Gdb-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox