aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-07-04 12:51:52 -0600
committerTom Tromey <tom@tromey.com>2021-07-17 10:41:42 -0600
commitd030267c9cc0fb594d3dda264b78114afc6eb214 (patch)
tree101853657cc9d826cf7fe6c5137536e45e2c89db
parentdcce7ec41082666e51e39480e2c4037124e1e1b5 (diff)
downloadgdb-d030267c9cc0fb594d3dda264b78114afc6eb214.zip
gdb-d030267c9cc0fb594d3dda264b78114afc6eb214.tar.gz
gdb-d030267c9cc0fb594d3dda264b78114afc6eb214.tar.bz2
Simplify file_and_directory storage management
file_and_directory carries a std::string in case the compilation directory is computed, but a subsequent patch wants to preserve this string without also having to maintain the storage for it. So, this patch arranges for the compilation directory string to be stored in the per-BFD string bcache instead.
-rw-r--r--gdb/dwarf2/read.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 95246cb..e0007b7 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1533,14 +1533,10 @@ struct file_and_directory
const char *name;
/* The compilation directory. NULL if not known. If we needed to
- compute a new string, this points to COMP_DIR_STORAGE, otherwise,
- points directly to the DW_AT_comp_dir string attribute owned by
- the obstack that owns the DIE. */
+ compute a new string, it will be stored in the per-BFD string
+ bcache; otherwise, points directly to the DW_AT_comp_dir string
+ attribute owned by the obstack that owns the DIE. */
const char *comp_dir;
-
- /* If we needed to build a new string for comp_dir, this is what
- owns the storage. */
- std::string comp_dir_storage;
};
static file_and_directory find_file_and_directory (struct die_info *die,
@@ -10387,9 +10383,10 @@ find_file_and_directory (struct die_info *die, struct dwarf2_cu *cu)
&& producer_is_gcc_lt_4_3 (cu) && res.name != NULL
&& IS_ABSOLUTE_PATH (res.name))
{
- res.comp_dir_storage = ldirname (res.name);
- if (!res.comp_dir_storage.empty ())
- res.comp_dir = res.comp_dir_storage.c_str ();
+ std::string comp_dir_storage = ldirname (res.name);
+ if (!comp_dir_storage.empty ())
+ res.comp_dir
+ = cu->per_objfile->objfile->intern (comp_dir_storage.c_str ());
}
if (res.comp_dir != NULL)
{