[gdb/symtab] Find filename in shared psymtab
authorTom de Vries <tdevries@suse.de>
Wed, 22 Apr 2020 06:24:11 +0000 (08:24 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 22 Apr 2020 06:24:11 +0000 (08:24 +0200)
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.

gdb/ChangeLog
gdb/psymtab.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.dwarf2/imported-unit.exp

index 3f1cce59e7d3505061e127838187d46eaed33fcc..fdafdb99db4d748b97dd378115016b6ff20e6cbb 100644 (file)
@@ -1,3 +1,9 @@
+2020-04-22  Tom de Vries  <tdevries@suse.de>
+
+       PR symtab/25801
+       * psymtab.c (psym_map_symtabs_matching_filename): Don't skip shared
+       symtabs.
+
 2020-04-22  Tom de Vries  <tdevries@suse.de>
 
        PR symtab/25700
index b156aa0e228da6970f5dedb42cc130d14339fc3c..376cbeedcdf392d17270a57ee3a26c6d69080e2f 100644 (file)
@@ -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;
index f6c52c8e4250de84944ee23af653831b8c148094..1331fe5248b29621ca9656996aeea0c05e6d6ede 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2020-04-22  Tom de Vries  <tdevries@suse.de>
 
        PR symtab/25700
index d7b3d4c53980cf9c86c2921fe4bb4ddd5df75662..32a9abf6204d518111c55c7f6de51aa62169567c 100644 (file)
@@ -186,6 +186,12 @@ if { $psymtabs_p } {
     unsupported $test
 }
 
+gdb_test "l imported_unit.c:1" \
+    "1\timported_unit.c: No such file or directory\."
+
+gdb_test "info source" "\r\nCurrent source file is imported_unit.c\r\n.*" \
+    "info source for imported_unit.c"
+
 # Sanity check
 gdb_test "ptype main" "= int \\(void\\)"
 
This page took 0.035778 seconds and 4 git commands to generate.