aboutsummaryrefslogtreecommitdiff
path: root/gdb/solib.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-08-08 09:56:47 -0600
committerTom Tromey <tromey@adacore.com>2022-08-08 10:00:57 -0600
commitce81f9d6fa885a3faa41613debc8771304dc469b (patch)
tree64a09a47e85c4d07c7719c29c9cec0f31d6adfc3 /gdb/solib.c
parente441b55e94c905c6ee4417be3e5d88021d9c5aa6 (diff)
downloadgdb-ce81f9d6fa885a3faa41613debc8771304dc469b.zip
gdb-ce81f9d6fa885a3faa41613debc8771304dc469b.tar.gz
gdb-ce81f9d6fa885a3faa41613debc8771304dc469b.tar.bz2
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
Diffstat (limited to 'gdb/solib.c')
-rw-r--r--gdb/solib.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gdb/solib.c b/gdb/solib.c
index d889673..25adf58 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. */