diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2022-04-27 12:47:35 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2022-07-29 20:54:49 -0400 |
commit | ee26d001cdf44cff897f994c89ad333bfa66d59e (patch) | |
tree | c0825dfef4b22115497f213c4c311c3d560a3f4c /gdb | |
parent | f71ad5556cf5ad3bb938d6ba1b5eca1e79d8d740 (diff) | |
download | gdb-ee26d001cdf44cff897f994c89ad333bfa66d59e.zip gdb-ee26d001cdf44cff897f994c89ad333bfa66d59e.tar.gz gdb-ee26d001cdf44cff897f994c89ad333bfa66d59e.tar.bz2 |
gdb: remove code to prepend comp dir in buildsym_compunit::start_subfile
The bit of code removed by this patch was introduced to fix the same
kind of problem that the previous patch fixes. That is, to try to match
existing subfiles when different name forms are used to refer to a same
file.
The thread for the patch that introduced this code is:
https://pi.simark.ca/gdb-patches/45F8CBDF.9090501@hq.tensilica.com/
The important bits are that the compiler produced a compilation unit
with:
DW_AT_name : test.c
DW_AT_comp_dir : /home/maxim/W/BadgerPass/PR_14999
and DWARF v2 line table with:
The Directory Table:
/home/maxim/W/BadgerPass/PR_14999
The File Name Table:
Entry Dir Time Size Name
1 1 1173897037 152 test.c
Because the main symtab was created with only DW_AT_name, it was named
"test.c". And because the path built from the line header contained the
"directory" part, it was "/home/maxim/W/BadgerPass/PR_14999/test.c".
Because of this mismatch, thing didn't work, so they added this code to
prepend the compilation directory to the existing subfile names, so that
this specific case would work.
With the changes done earlier in this series, where subfiles are
identified using the "most complete path possible", this case would be
handled. The main subfile's would be
"/home/maxim/W/BadgerPass/PR_14999/test.c" from the start
(DW_AT_comp_dir + DW_AT_name). It's not so different from some DWARF 5
cases actually, which make the compilation directory explicit in the
line table header.
I therefore think that this code is no longer needed. It does feel like
a quick hack to make one specific case work, and we have a more general
solution now. Also, this code was introduced to work around a problem
in the DWARF debug info or the DWARF debug info reader. In general, I
think it's preferable for these hacks to be located in the specific
debug info reader code, rather than in the common code.
Even though this code was added to work around a DWARF reader problem,
it's possible that some other debug info reader has started taking
advantage of this code in the mean time. It's very difficult to
know or verify, but I think the likelyhood is quite small, so I'm
proposing to get rid of it to simplify things a little bit.
Change-Id: I710b8ec0d449d1b110d67ddf9fcbdb2b37108306
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/buildsym.c | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 67d88a9..d7c935a 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -495,31 +495,13 @@ buildsym_compunit::start_subfile (const char *name, const char *name_for_id) symtab_create_debug_printf ("name = %s, name_for_id = %s", name, name_for_id); for (subfile *subfile = m_subfiles; subfile; subfile = subfile->next) - { - std::string subfile_name_holder; - const char *subfile_name_for_id; - - /* If NAME is an absolute path, and this subfile is not, then - attempt to create an absolute path to compare. */ - if (IS_ABSOLUTE_PATH (name_for_id) - && !IS_ABSOLUTE_PATH (subfile->name_for_id) - && !m_comp_dir.empty ()) - { - subfile_name_holder = path_join (m_comp_dir.c_str (), - subfile->name_for_id.c_str ()); - subfile_name_for_id = subfile_name_holder.c_str (); - } - else - subfile_name_for_id = subfile->name_for_id.c_str (); - - if (FILENAME_CMP (subfile_name_for_id, name_for_id) == 0) - { - symtab_create_debug_printf ("found existing symtab with name_for_id %s (%s)", - subfile->name_for_id.c_str (), subfile_name_for_id); - m_current_subfile = subfile; - return; - } - } + if (FILENAME_CMP (subfile->name_for_id.c_str (), name_for_id) == 0) + { + symtab_create_debug_printf ("found existing symtab with name_for_id %s", + subfile->name_for_id.c_str ()); + m_current_subfile = subfile; + return; + } /* This subfile is not known. Add an entry for it. */ |