public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug symtab/25801] New: Filename of shared psymtab is ignored
@ 2020-04-08  9:01 vries at gcc dot gnu.org
  2020-04-08  9:03 ` [Bug symtab/25801] " vries at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: vries at gcc dot gnu.org @ 2020-04-08  9:01 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=25801

            Bug ID: 25801
           Summary: Filename of shared psymtab is ignored
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: symtab
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

Consider test-case gdb.ada/dgopt.exp.

The test-case uses gnatmake option -gnatDG, which translates to:
...
-gnatD
    Create expanded source files for source level debugging. This switch also
suppresses generation of cross-reference information (see -gnatx). Note that
this switch is not allowed if a previous -gnatR switch has been given, since
these two switches are not compatible. 

-gnateG
    Save result of preprocessing in a text file. 
...

This causes the file x.adb to be expanded into x.adb.dg, which is then
compiled.

The effect of this is described in the .exp file:
...
# the
# .adb file did not end up in the file table, but did show up in the
# DWARF
...

We can confirm this by looking at the DWARF:
...
 <0><7f1>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <7f7>   DW_AT_name        : gdb/testsuite/gdb.ada/dgopt/x.adb
...
with corresponding file table:
...
 The File Name Table (offset 0x1ce):
  Entry Dir     Time    Size    Name
  1     0       0       0       x.adb.dg
...

With gcc-7, and target board
unix/-flto/-O0/-flto-partition=none/-ffat-lto-objects, we run into:
...
(gdb) list x.adb:16, 16^M
No source file named x.adb.^M
(gdb) FAIL: gdb.ada/dgopt.exp: list x.adb:16, 16
...
because the corresponding CU has been renamed to <artificial>:
...
 <0><d2>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <d8>   DW_AT_name        : <artificial>
...

This FAIL is fixed in gcc-8, gcc-9 and gcc-10, where we have instead:
...
 <0><15a5>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <15ab>   DW_AT_name        : <artificial>
 <1><15c7>: Abbrev Number: 2 (DW_TAG_imported_unit)
    <15c8>   DW_AT_import      : <0x15ef>       [Abbrev Number: 1]
 <0><15ef>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <15f5>   DW_AT_name        : gdb/testsuite/gdb.ada/dgopt/x.adb
...

However, with the tentative fix for PR25700 at PR25700 comment 3, we again run
into:
...
(gdb) list x.adb:16, 16^M
No source file named x.adb.^M
(gdb) FAIL: gdb.ada/dgopt.exp: list x.adb:16, 16
...
which we can fix by using -readnow.

The explanation is that without the tentative fix for PR25700, we have an
unshared psymtab:
...
  { psymtab gdb/testsuite/gdb.ada/dgopt/x.adb ((struct partial_symtab *)
0x37e3600)^M
    readin no^M
    fullname (null)^M
    text addresses 0x0 -- 0x0^M
    psymtabs_addrmap_supported yes^M
    globals (none)^M
    statics (none)^M
    dependencies (none)^M
  }^M
...
and a shared psymtab (with user test):
...
  { psymtab gdb/testsuite/gdb.ada/dgopt/x.adb ((struct partial_symtab *)
0x36d56f0)^M
    readin no^M
    fullname (null)^M
    text addresses 0x0 -- 0x0^M
    psymtabs_addrmap_supported yes^M
    globals (none)^M
    statics (none)^M
    user <artificial>@0x159a ((struct partial_symtab *) 0x37b57c0)^M
    dependencies (none)^M
  }^M
...

The tentative fix for PR25700 removes the unshared psymtab.

Then when trying to find a psymtab matching x.adb in
psym_map_symtabs_matching_filename, we run into this continue for the shared
psymtab:
...
  for (partial_symtab *pst : require_partial_symbols (objfile, true))
    {
      /* We can skip shared psymtabs here, because any file name will be
        attached to the unshared psymtab.  */
      if (pst->user != NULL)
       continue;
...
and consequently cannot find the file.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug symtab/25801] Filename of shared psymtab is ignored
  2020-04-08  9:01 [Bug symtab/25801] New: Filename of shared psymtab is ignored vries at gcc dot gnu.org
@ 2020-04-08  9:03 ` vries at gcc dot gnu.org
  2020-04-08 11:04 ` vries at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: vries at gcc dot gnu.org @ 2020-04-08  9:03 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=25801

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
This tentative patch fixes things:
...
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index d952f453d9..5e4e7d116f 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -157,17 +157,15 @@ psym_map_symtabs_matching_filename

   for (partial_symtab *pst : require_partial_symbols (objfile, true))
     {
-      /* We can skip shared psymtabs here, because any file name will be
-        attached to the unshared psymtab.  */
-      if (pst->user != NULL)
-       continue;
-
       /* Anonymous psymtabs don't have a file name.  */
       if (pst->anonymous)
        continue;

       if (compare_filenames_for_search (pst->filename, name))
        {
+         while (pst->user)
+           pst = pst->user;
+
          if (partial_map_expand_apply (objfile, name, real_path,
                                        pst, callback))
            return true;
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug symtab/25801] Filename of shared psymtab is ignored
  2020-04-08  9:01 [Bug symtab/25801] New: Filename of shared psymtab is ignored vries at gcc dot gnu.org
  2020-04-08  9:03 ` [Bug symtab/25801] " vries at gcc dot gnu.org
@ 2020-04-08 11:04 ` vries at gcc dot gnu.org
  2020-04-15  7:18 ` luciham20 at gmail dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: vries at gcc dot gnu.org @ 2020-04-08 11:04 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=25801

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
Submitted patch:
https://sourceware.org/pipermail/gdb-patches/2020-April/167452.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug symtab/25801] Filename of shared psymtab is ignored
  2020-04-08  9:01 [Bug symtab/25801] New: Filename of shared psymtab is ignored vries at gcc dot gnu.org
  2020-04-08  9:03 ` [Bug symtab/25801] " vries at gcc dot gnu.org
  2020-04-08 11:04 ` vries at gcc dot gnu.org
@ 2020-04-15  7:18 ` luciham20 at gmail dot com
  2020-04-22  6:24 ` cvs-commit at gcc dot gnu.org
  2020-04-22  6:24 ` vries at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: luciham20 at gmail dot com @ 2020-04-15  7:18 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=25801

Lucille F. Parham <luciham20 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |luciham20 at gmail dot com

--- Comment #3 from Lucille F. Parham <luciham20 at gmail dot com> ---
Many thanks for making the effort to discuss this, I feel strongly about this
and like studying a great deal more on this topic.
https://sites.google.com/view/subwaysurferspc

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug symtab/25801] Filename of shared psymtab is ignored
  2020-04-08  9:01 [Bug symtab/25801] New: Filename of shared psymtab is ignored vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-04-15  7:18 ` luciham20 at gmail dot com
@ 2020-04-22  6:24 ` cvs-commit at gcc dot gnu.org
  2020-04-22  6:24 ` vries at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-22  6:24 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=25801

--- Comment #4 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=eea9e35758138f83e8c44e0e5a5e47e351f8f31a

commit eea9e35758138f83e8c44e0e5a5e47e351f8f31a
Author: Tom de Vries <tdevries@suse.de>
Date:   Wed Apr 22 08:24:11 2020 +0200

    [gdb/symtab] Find filename in shared psymtab

    When running test-case gdb.ada/dgopt.exp with target board
    unix/-flto/-O0/-flto-partition=none/-ffat-lto-objects and gcc-8, gcc-9 or
    gcc-10, and the fix for PR25700, we run into this regression:
    ...
    (gdb) list x.adb:16, 16^M
    No source file named x.adb.^M
    (gdb) FAIL: gdb.ada/dgopt.exp: list x.adb:16, 16
    ...

    The reason for the failure is that without the fix for PR25700, we
    have an unshared psymtab:
    ...
      { psymtab gdb.ada/dgopt/x.adb ((struct partial_symtab *) $hex)^M
        readin no^M
        fullname (null)^M
        text addresses 0x0 -- 0x0^M
        psymtabs_addrmap_supported yes^M
        globals (none)^M
        statics (none)^M
        dependencies (none)^M
      }^M
    ...
    and a shared psymtab (with user field set):
    ...
      { psymtab gdb.ada/dgopt/x.adb ((struct partial_symtab *) $hex)^M
        readin no^M
        fullname (null)^M
        text addresses 0x0 -- 0x0^M
        psymtabs_addrmap_supported yes^M
        globals (none)^M
        statics (none)^M
        user <artificial>@0x159a ((struct partial_symtab *) 0x37b57c0)^M
        dependencies (none)^M
      }^M
    ...

    The fix for PR25700 removes the unshared psymtab.

    Then when trying to find a psymtab matching x.adb in
    psym_map_symtabs_matching_filename, we run into this continue for the
shared
    psymtab:
    ...
      for (partial_symtab *pst : require_partial_symbols (objfile, true))
        {
          /* We can skip shared psymtabs here, because any file name will be
            attached to the unshared psymtab.  */
          if (pst->user != NULL)
           continue;
    ...
    and consequently cannot find the file.

    Fix this by not skipping the shared symtab in
    psym_map_symtabs_matching_filename.

    Build and reg-tested on x86_64-linux.

    gdb/ChangeLog:

    2020-04-22  Tom de Vries  <tdevries@suse.de>

            PR symtab/25801
            * psymtab.c (psym_map_symtabs_matching_filename): Don't skip shared
            symtabs.

    gdb/testsuite/ChangeLog:

    2020-04-22  Tom de Vries  <tdevries@suse.de>

            PR symtab/25801
            * gdb.dwarf2/imported-unit.exp: Test that we can get
imported_unit.c
            in "info source" output.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug symtab/25801] Filename of shared psymtab is ignored
  2020-04-08  9:01 [Bug symtab/25801] New: Filename of shared psymtab is ignored vries at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2020-04-22  6:24 ` cvs-commit at gcc dot gnu.org
@ 2020-04-22  6:24 ` vries at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: vries at gcc dot gnu.org @ 2020-04-22  6:24 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=25801

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #5 from Tom de Vries <vries at gcc dot gnu.org> ---
Patch with test-case committed, marking resolved-fixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-04-22  6:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-08  9:01 [Bug symtab/25801] New: Filename of shared psymtab is ignored vries at gcc dot gnu.org
2020-04-08  9:03 ` [Bug symtab/25801] " vries at gcc dot gnu.org
2020-04-08 11:04 ` vries at gcc dot gnu.org
2020-04-15  7:18 ` luciham20 at gmail dot com
2020-04-22  6:24 ` cvs-commit at gcc dot gnu.org
2020-04-22  6:24 ` vries at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).