From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id C6D93384B83A; Sat, 30 Jul 2022 00:55:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C6D93384B83A Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: remove code to prepend comp dir in buildsym_compunit::start_subfile X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: f71ad5556cf5ad3bb938d6ba1b5eca1e79d8d740 X-Git-Newrev: ee26d001cdf44cff897f994c89ad333bfa66d59e Message-Id: <20220730005534.C6D93384B83A@sourceware.org> Date: Sat, 30 Jul 2022 00:55:34 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jul 2022 00:55:34 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dee26d001cdf4= 4cff897f994c89ad333bfa66d59e commit ee26d001cdf44cff897f994c89ad333bfa66d59e Author: Simon Marchi Date: Wed Apr 27 12:47:35 2022 -0400 gdb: remove code to prepend comp dir in buildsym_compunit::start_subfile =20 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. =20 The thread for the patch that introduced this code is: =20 https://pi.simark.ca/gdb-patches/45F8CBDF.9090501@hq.tensilica.com/ =20 The important bits are that the compiler produced a compilation unit with: =20 DW_AT_name : test.c DW_AT_comp_dir : /home/maxim/W/BadgerPass/PR_14999 =20 and DWARF v2 line table with: =20 The Directory Table: /home/maxim/W/BadgerPass/PR_14999 =20 The File Name Table: Entry Dir Time Size Name 1 1 1173897037 152 test.c =20 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. =20 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. =20 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. =20 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. =20 Change-Id: I710b8ec0d449d1b110d67ddf9fcbdb2b37108306 Diff: --- gdb/buildsym.c | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 67d88a94ba9..d7c935af703 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -495,31 +495,13 @@ buildsym_compunit::start_subfile (const char *name, c= onst char *name_for_id) symtab_create_debug_printf ("name =3D %s, name_for_id =3D %s", name, nam= e_for_id); =20 for (subfile *subfile =3D m_subfiles; subfile; subfile =3D 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 =3D path_join (m_comp_dir.c_str (), - subfile->name_for_id.c_str ()); - subfile_name_for_id =3D subfile_name_holder.c_str (); - } - else - subfile_name_for_id =3D subfile->name_for_id.c_str (); - - if (FILENAME_CMP (subfile_name_for_id, name_for_id) =3D=3D 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 =3D subfile; - return; - } - } + if (FILENAME_CMP (subfile->name_for_id.c_str (), name_for_id) =3D=3D 0) + { + symtab_create_debug_printf ("found existing symtab with name_for_id %s", + subfile->name_for_id.c_str ()); + m_current_subfile =3D subfile; + return; + } =20 /* This subfile is not known. Add an entry for it. */