aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-02-14 14:16:23 -0700
committerTom Tromey <tom@tromey.com>2020-02-14 14:16:24 -0700
commita4a38eb437382fbf2b2c6788fe35dd3340f9664a (patch)
treeac18d982d4265f3cef76ab880280a91a1c45cec1
parentf251f50533110132ce83678d644d53b1d1110b05 (diff)
downloadgdb-a4a38eb437382fbf2b2c6788fe35dd3340f9664a.zip
gdb-a4a38eb437382fbf2b2c6788fe35dd3340f9664a.tar.gz
gdb-a4a38eb437382fbf2b2c6788fe35dd3340f9664a.tar.bz2
Cache .gnu_debugdata BFD
While looking at the output of "maint info bfd" with multiple inferiors, I noticed that there were duplicate entries for .gnu_debugdata. There is no reason to re-create this BFD each time it is needed. This patch arranges to share the data. gdb/ChangeLog 2020-02-14 Tom Tromey <tom@tromey.com> * minidebug.c (gnu_debug_key): New global. (find_separate_debug_file_in_section): Use it. Change-Id: If139f89f0f07db33f399afdbcfbf5aaeffe4de46
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/minidebug.c11
2 files changed, 16 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b71251c..fd9b6a8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2020-02-14 Tom Tromey <tom@tromey.com>
+
+ * minidebug.c (gnu_debug_key): New global.
+ (find_separate_debug_file_in_section): Use it.
+
2020-02-14 Simon Marchi <simon.marchi@efficios.com>
* gdbarch.sh (displaced_step_copy_insn): Change return type to an
diff --git a/gdb/minidebug.c b/gdb/minidebug.c
index a56a822..dbf14c7 100644
--- a/gdb/minidebug.c
+++ b/gdb/minidebug.c
@@ -26,6 +26,10 @@
#ifdef HAVE_LIBLZMA
+/* We stash a reference to the .gnu_debugdata BFD on the enclosing
+ BFD. */
+static const bfd_key<gdb_bfd_ref_ptr> gnu_debug_key;
+
#include <lzma.h>
/* Allocator function for LZMA. */
@@ -269,6 +273,10 @@ find_separate_debug_file_in_section (struct objfile *objfile)
return NULL;
#ifdef HAVE_LIBLZMA
+ gdb_bfd_ref_ptr *shared = gnu_debug_key.get (objfile->obfd);
+ if (shared != nullptr)
+ return *shared;
+
std::string filename = string_printf (_(".gnu_debugdata for %s"),
objfile_name (objfile));
@@ -282,6 +290,9 @@ find_separate_debug_file_in_section (struct objfile *objfile)
warning (_("Cannot parse .gnu_debugdata section; not a BFD object"));
return NULL;
}
+
+ gnu_debug_key.emplace (objfile->obfd, abfd);
+
#else
warning (_("Cannot parse .gnu_debugdata section; LZMA support was "
"disabled at compile time"));