public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug symtab/30829] New: [gdb/symtab] Review write_gdbindex for dwz
@ 2023-09-07 13:15 vries at gcc dot gnu.org
  2023-09-07 17:50 ` [Bug symtab/30829] " tromey at sourceware dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-07 13:15 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 30829
           Summary: [gdb/symtab] Review write_gdbindex for dwz
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: minor
          Priority: P2
         Component: symtab
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

While working on fixing PR3082, I noticed a few things in write_gdbindex.

We do this:
...
      const auto insertpair = cu_index_htab.emplace (per_cu, counter);
...
which looks incorrect for per_cu->is_dwz.

Then we do:
...
      data_buf &cu_list = (per_cu->is_debug_types
                           ? types_cu_list
                           : per_cu->is_dwz ? dwz_cu_list : objfile_cu_list);
  ...
  write_gdbindex_1 (dwz_out_file, dwz_cu_list, {}, {}, {}, {});
...
which seems to exclude the possibility that a dwz file has a .debug_types
section.

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

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

* [Bug symtab/30829] [gdb/symtab] Review write_gdbindex for dwz
  2023-09-07 13:15 [Bug symtab/30829] New: [gdb/symtab] Review write_gdbindex for dwz vries at gcc dot gnu.org
@ 2023-09-07 17:50 ` tromey at sourceware dot org
  2023-09-08  5:54 ` vries at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at sourceware dot org @ 2023-09-07 17:50 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
(In reply to Tom de Vries from comment #0)

> which seems to exclude the possibility that a dwz file has a .debug_types
> section.

I think that's probably not supported.

dwz came into existence because I wanted to change the distro
to use .debug_types as a DWARF compression scheme.
Jakub wrote dwz (in like 1 week) specifically to prevent that :-)

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

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

* [Bug symtab/30829] [gdb/symtab] Review write_gdbindex for dwz
  2023-09-07 13:15 [Bug symtab/30829] New: [gdb/symtab] Review write_gdbindex for dwz vries at gcc dot gnu.org
  2023-09-07 17:50 ` [Bug symtab/30829] " tromey at sourceware dot org
@ 2023-09-08  5:54 ` vries at gcc dot gnu.org
  2023-09-08 12:59 ` vries at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-08  5:54 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom Tromey from comment #1)
> (In reply to Tom de Vries from comment #0)
> 
> > which seems to exclude the possibility that a dwz file has a .debug_types
> > section.
> 
> I think that's probably not supported.
> 

Ok, I'll try to come up with a patch that makes that explicit.

> dwz came into existence because I wanted to change the distro
> to use .debug_types as a DWARF compression scheme.
> Jakub wrote dwz (in like 1 week) specifically to prevent that :-)

Ah, interesting, thanks for that bit of context :)

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

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

* [Bug symtab/30829] [gdb/symtab] Review write_gdbindex for dwz
  2023-09-07 13:15 [Bug symtab/30829] New: [gdb/symtab] Review write_gdbindex for dwz vries at gcc dot gnu.org
  2023-09-07 17:50 ` [Bug symtab/30829] " tromey at sourceware dot org
  2023-09-08  5:54 ` vries at gcc dot gnu.org
@ 2023-09-08 12:59 ` vries at gcc dot gnu.org
  2023-09-08 13:14 ` vries at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-08 12:59 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #0)
> We do this:
> ...
>       const auto insertpair = cu_index_htab.emplace (per_cu, counter);
> ...
> which looks incorrect for per_cu->is_dwz.

This is actually used.

Consider test-case gdb.dwarf2/dwzbuildid.exp.

When running the test-case using target board cc-with-gdb-index, it passes
(well for the one executable that it manages to build), but gdb quietly ignores
the .gdb_index section, because the .gnu_debugaltlink file doesn't have a
.gdb_index section.

The target board uses gdb-add-index, which currently doesn't support this.

So I wrote a new target board cc-with-index-cache, because the index-cache
already does support this.

To my surprise, the test-case still passes.

There seems to be some undocumented behaviour going on (at least, I don't see
any explicit mention of the following here:
https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html#Index-Section-Format
).

Indeed each .gdb_index section has a CU/TU table, and the section for the
.gnu_debugaltlink file contains nothing else.

I think the assumption was that a .gnu_debugaltlink contains only PUs, and that
the toplevel symbol table only contains references to CUs/TUs, which will be
pointing to the toplevel CU/TU table.

However, in this test-case the .gnu_debugaltlink file contains a CU.

And the reference in the toplevel symbol table point towards it, in the sense
that the virtual toplevel CU/TU table (otherwise known as all_units) first
contains the toplevel CU/PUs, then toplevel TUs, then .gnu_debugaltlink CU/PUs,
then .gnu_debugaltlink TUs.

Readelf doesn't understand this, and consequently shows:
...
[512] the_int: T1 [static, variable]
...
But there are no type units, and this could be printed as 'L1', meaning the
first item in the CU list of the .gdb_index section in the .gnu_debugaltlink
file.

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

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

* [Bug symtab/30829] [gdb/symtab] Review write_gdbindex for dwz
  2023-09-07 13:15 [Bug symtab/30829] New: [gdb/symtab] Review write_gdbindex for dwz vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-09-08 12:59 ` vries at gcc dot gnu.org
@ 2023-09-08 13:14 ` vries at gcc dot gnu.org
  2023-09-08 13:24 ` vries at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-08 13:14 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #4 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #3)
> However, in this test-case the .gnu_debugaltlink file contains a CU.

Hmm, something else is going on here.

I changed the CU to a PU, and the test started to fail with target board unix,
as I expected.  However, it didn't fail with the cc-with-index-cache target
board, while it should.

A PU is just a dwarf repository that has significance only in terms of the CUs
that reference and/or import it.  An unreferenced PU should be ignored.

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

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

* [Bug symtab/30829] [gdb/symtab] Review write_gdbindex for dwz
  2023-09-07 13:15 [Bug symtab/30829] New: [gdb/symtab] Review write_gdbindex for dwz vries at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-09-08 13:14 ` vries at gcc dot gnu.org
@ 2023-09-08 13:24 ` vries at gcc dot gnu.org
  2023-09-12  8:46 ` vries at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-08 13:24 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #5 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #4)
> (In reply to Tom de Vries from comment #3)
> > However, in this test-case the .gnu_debugaltlink file contains a CU.
> 
> Hmm, something else is going on here.
> 
> I changed the CU to a PU, and the test started to fail with target board
> unix, as I expected.  However, it didn't fail with the cc-with-index-cache
> target board, while it should.
> 
> A PU is just a dwarf repository that has significance only in terms of the
> CUs that reference and/or import it.  An unreferenced PU should be ignored.

Sorry, scrap that, that was an artifact of not yet having implemented cleaning
up the cache dir in the new target board.

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

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

* [Bug symtab/30829] [gdb/symtab] Review write_gdbindex for dwz
  2023-09-07 13:15 [Bug symtab/30829] New: [gdb/symtab] Review write_gdbindex for dwz vries at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-09-08 13:24 ` vries at gcc dot gnu.org
@ 2023-09-12  8:46 ` vries at gcc dot gnu.org
  2023-09-12 10:01 ` vries at gcc dot gnu.org
  2023-09-12 10:05 ` vries at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-12  8:46 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #6 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #2)
> (In reply to Tom Tromey from comment #1)
> > (In reply to Tom de Vries from comment #0)
> > 
> > > which seems to exclude the possibility that a dwz file has a .debug_types
> > > section.
> > 
> > I think that's probably not supported.
> > 
> 
> Ok, I'll try to come up with a patch that makes that explicit.
> 

I've filed this issue as enhancement PR symtab/30838, and submitted a patch
that throws a dwarf error.

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

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

* [Bug symtab/30829] [gdb/symtab] Review write_gdbindex for dwz
  2023-09-07 13:15 [Bug symtab/30829] New: [gdb/symtab] Review write_gdbindex for dwz vries at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2023-09-12  8:46 ` vries at gcc dot gnu.org
@ 2023-09-12 10:01 ` vries at gcc dot gnu.org
  2023-09-12 10:05 ` vries at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-12 10:01 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #7 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #3)
> There seems to be some undocumented behaviour going on (at least, I don't
> see any explicit mention of the following here:
> https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html#Index-
> Section-Format ).
> 
> Indeed each .gdb_index section has a CU/TU table, and the section for the
> .gnu_debugaltlink file contains nothing else.
> 
> I think the assumption was that a .gnu_debugaltlink contains only PUs, and
> that the toplevel symbol table only contains references to CUs/TUs, which
> will be pointing to the toplevel CU/TU table.
> 
> However, in this test-case the .gnu_debugaltlink file contains a CU.
> 
> And the reference in the toplevel symbol table point towards it, in the
> sense that the virtual toplevel CU/TU table (otherwise known as all_units)
> first contains the toplevel CU/PUs, then toplevel TUs, then
> .gnu_debugaltlink CU/PUs

I've submitted a doc patch:
https://sourceware.org/pipermail/gdb-patches/2023-September/202359.html

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

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

* [Bug symtab/30829] [gdb/symtab] Review write_gdbindex for dwz
  2023-09-07 13:15 [Bug symtab/30829] New: [gdb/symtab] Review write_gdbindex for dwz vries at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2023-09-12 10:01 ` vries at gcc dot gnu.org
@ 2023-09-12 10:05 ` vries at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: vries at gcc dot gnu.org @ 2023-09-12 10:05 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #8 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #3)
> The target board uses gdb-add-index, which currently doesn't support this.

Filed enhancement PR symtab/30841.

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

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

end of thread, other threads:[~2023-09-12 10:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-07 13:15 [Bug symtab/30829] New: [gdb/symtab] Review write_gdbindex for dwz vries at gcc dot gnu.org
2023-09-07 17:50 ` [Bug symtab/30829] " tromey at sourceware dot org
2023-09-08  5:54 ` vries at gcc dot gnu.org
2023-09-08 12:59 ` vries at gcc dot gnu.org
2023-09-08 13:14 ` vries at gcc dot gnu.org
2023-09-08 13:24 ` vries at gcc dot gnu.org
2023-09-12  8:46 ` vries at gcc dot gnu.org
2023-09-12 10:01 ` vries at gcc dot gnu.org
2023-09-12 10:05 ` 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).