aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdb_bfd.c
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2015-04-13 16:56:23 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2015-08-18 14:03:14 +0100
commit566f5e3b385a99c09b5babc9f90dae93e052d52c (patch)
tree229e1f15bd0ae0595f88537411d2a0db93dd3e93 /gdb/gdb_bfd.c
parent18989b3c5642e2ba533e02737797dcf06134229b (diff)
downloadfsf-binutils-gdb-566f5e3b385a99c09b5babc9f90dae93e052d52c.zip
fsf-binutils-gdb-566f5e3b385a99c09b5babc9f90dae93e052d52c.tar.gz
fsf-binutils-gdb-566f5e3b385a99c09b5babc9f90dae93e052d52c.tar.bz2
gdb: Add debug tracing for bfd cache activity.
This patch adds a new debug flag bfd-cache, which when set to non-zero produces debugging log messages relating to gdb's bfd cache. gdb/ChangeLog: * gdb_bfd.c (debug_bfd_cache): New variable. (show_bfd_cache_debug): New function. (gdb_bfd_open): Add debug logging. (gdb_bfd_ref): Likewise. (gdb_bfd_unref): Likewise. (_initialize_gdb_bfd): Add new set/show command. * NEWS: Mention new command. gdb/doc/ChangeLog: * gdb.texinfo (File Caching): Document "set/show debug bfd-cache".
Diffstat (limited to 'gdb/gdb_bfd.c')
-rw-r--r--gdb/gdb_bfd.c51
1 files changed, 50 insertions, 1 deletions
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
index 8471775..eb53766 100644
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -122,6 +122,16 @@ show_bfd_sharing (struct ui_file *file, int from_tty,
fprintf_filtered (file, _("BFD sharing is %s.\n"), value);
}
+/* When non-zero debugging of the bfd caches is enabled. */
+
+static unsigned int debug_bfd_cache;
+static void
+show_bfd_cache_debug (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ fprintf_filtered (file, _("BFD cache debugging is %s.\n"), value);
+}
+
/* The type of an object being looked up in gdb_bfd_cache. We use
htab's capability of storing one kind of object (BFD in this case)
and using a different sort of object for searching. */
@@ -407,6 +417,11 @@ gdb_bfd_open (const char *name, const char *target, int fd)
abfd = htab_find_with_hash (gdb_bfd_cache, &search, hash);
if (bfd_sharing && abfd != NULL)
{
+ if (debug_bfd_cache)
+ fprintf_unfiltered (gdb_stdlog,
+ "Reusing cached bfd %s for %s\n",
+ host_address_to_string (abfd),
+ bfd_get_filename (abfd));
close (fd);
gdb_bfd_ref (abfd);
return abfd;
@@ -416,6 +431,12 @@ gdb_bfd_open (const char *name, const char *target, int fd)
if (abfd == NULL)
return NULL;
+ if (debug_bfd_cache)
+ fprintf_unfiltered (gdb_stdlog,
+ "Creating new bfd %s for %s\n",
+ host_address_to_string (abfd),
+ bfd_get_filename (abfd));
+
if (bfd_sharing)
{
slot = htab_find_slot_with_hash (gdb_bfd_cache, &search, hash, INSERT);
@@ -484,6 +505,12 @@ gdb_bfd_ref (struct bfd *abfd)
gdata = bfd_usrdata (abfd);
+ if (debug_bfd_cache)
+ fprintf_unfiltered (gdb_stdlog,
+ "Increase reference count on bfd %s (%s)\n",
+ host_address_to_string (abfd),
+ bfd_get_filename (abfd));
+
if (gdata != NULL)
{
gdata->refc += 1;
@@ -537,7 +564,20 @@ gdb_bfd_unref (struct bfd *abfd)
gdata->refc -= 1;
if (gdata->refc > 0)
- return;
+ {
+ if (debug_bfd_cache)
+ fprintf_unfiltered (gdb_stdlog,
+ "Decrease reference count on bfd %s (%s)\n",
+ host_address_to_string (abfd),
+ bfd_get_filename (abfd));
+ return;
+ }
+
+ if (debug_bfd_cache)
+ fprintf_unfiltered (gdb_stdlog,
+ "Delete final reference count on bfd %s (%s)\n",
+ host_address_to_string (abfd),
+ bfd_get_filename (abfd));
archive_bfd = gdata->archive_bfd;
search.filename = bfd_get_filename (abfd);
@@ -968,4 +1008,13 @@ filename, file size, file modification time, and file inode."),
&show_bfd_sharing,
&maintenance_set_cmdlist,
&maintenance_show_cmdlist);
+
+ add_setshow_zuinteger_cmd ("bfd-cache", class_maintenance,
+ &debug_bfd_cache, _("\
+Set bfd cache debugging."), _("\
+Show bfd cache debugging."), _("\
+When non-zero, bfd cache specific debugging is enabled."),
+ NULL,
+ &show_bfd_cache_debug,
+ &setdebuglist, &showdebuglist);
}