diff options
Diffstat (limited to 'gdb/gdb_bfd.c')
-rw-r--r-- | gdb/gdb_bfd.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c index ee29531..8471775 100644 --- a/gdb/gdb_bfd.c +++ b/gdb/gdb_bfd.c @@ -111,6 +111,17 @@ DEFINE_REGISTRY (bfd, GDB_BFD_DATA_ACCESSOR) static htab_t gdb_bfd_cache; +/* When true gdb will reuse an existing bfd object if the filename, + modification time, and file size all match. */ + +static int bfd_sharing = 1; +static void +show_bfd_sharing (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + fprintf_filtered (file, _("BFD sharing 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. */ @@ -394,7 +405,7 @@ gdb_bfd_open (const char *name, const char *target, int fd) opening the BFD may fail; and this would violate hashtab invariants. */ abfd = htab_find_with_hash (gdb_bfd_cache, &search, hash); - if (abfd != NULL) + if (bfd_sharing && abfd != NULL) { close (fd); gdb_bfd_ref (abfd); @@ -405,9 +416,12 @@ gdb_bfd_open (const char *name, const char *target, int fd) if (abfd == NULL) return NULL; - slot = htab_find_slot_with_hash (gdb_bfd_cache, &search, hash, INSERT); - gdb_assert (!*slot); - *slot = abfd; + if (bfd_sharing) + { + slot = htab_find_slot_with_hash (gdb_bfd_cache, &search, hash, INSERT); + gdb_assert (!*slot); + *slot = abfd; + } gdb_bfd_ref (abfd); return abfd; @@ -942,4 +956,16 @@ _initialize_gdb_bfd (void) add_cmd ("bfds", class_maintenance, maintenance_info_bfds, _("\ List the BFDs that are currently open."), &maintenanceinfolist); + + add_setshow_boolean_cmd ("bfd-sharing", no_class, + &bfd_sharing, _("\ +Set whether gdb will share bfds that appear to be the same file."), _("\ +Show whether gdb will share bfds that appear to be the same file."), _("\ +When enabled gdb will reuse existing bfds rather than reopening the\n\ +same file. To decide if two files are the same then gdb compares the\n\ +filename, file size, file modification time, and file inode."), + NULL, + &show_bfd_sharing, + &maintenance_set_cmdlist, + &maintenance_show_cmdlist); } |