Skip to content

Commit d030267

Browse files
committed
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.
1 parent dcce7ec commit d030267

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

gdb/dwarf2/read.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,14 +1533,10 @@ struct file_and_directory
15331533
const char *name;
15341534

15351535
/* The compilation directory. NULL if not known. If we needed to
1536-
compute a new string, this points to COMP_DIR_STORAGE, otherwise,
1537-
points directly to the DW_AT_comp_dir string attribute owned by
1538-
the obstack that owns the DIE. */
1536+
compute a new string, it will be stored in the per-BFD string
1537+
bcache; otherwise, points directly to the DW_AT_comp_dir string
1538+
attribute owned by the obstack that owns the DIE. */
15391539
const char *comp_dir;
1540-
1541-
/* If we needed to build a new string for comp_dir, this is what
1542-
owns the storage. */
1543-
std::string comp_dir_storage;
15441540
};
15451541

15461542
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)
1038710383
&& producer_is_gcc_lt_4_3 (cu) && res.name != NULL
1038810384
&& IS_ABSOLUTE_PATH (res.name))
1038910385
{
10390-
res.comp_dir_storage = ldirname (res.name);
10391-
if (!res.comp_dir_storage.empty ())
10392-
res.comp_dir = res.comp_dir_storage.c_str ();
10386+
std::string comp_dir_storage = ldirname (res.name);
10387+
if (!comp_dir_storage.empty ())
10388+
res.comp_dir
10389+
= cu->per_objfile->objfile->intern (comp_dir_storage.c_str ());
1039310390
}
1039410391
if (res.comp_dir != NULL)
1039510392
{

0 commit comments

Comments
 (0)