Bug 32299 - [gdb/symtab] incorrect parent for cooked index entries
Summary: [gdb/symtab] incorrect parent for cooked index entries
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: 29366
  Show dependency treegraph
 
Reported: 2024-10-23 18:35 UTC by Tom de Vries
Modified: 2025-11-26 16:36 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
Project(s) to access:
ssh public key:


Attachments
patch adding test-case gdb.dwarf2/dwz-2.exp (1.48 KB, patch)
2024-10-23 18:35 UTC, Tom de Vries
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2024-10-23 18:35:01 UTC
Created attachment 15758 [details]
patch adding test-case gdb.dwarf2/dwz-2.exp

I rebased this patch series ( https://sourceware.org/pipermail/gdb-patches/2023-December/205054.html ) on top of trunk, and was left with two patches, variants of:
- [gdb/symtab] Recurse into c++ DW_TAG_subprogram DIEs for cooked index
- [gdb/symtab] Keep track of all parents for cooked index

Since the first one is in question (see PR30728), I tried to write a test-case for the second one that does not involve DW_TAG_inlined_subroutine.

I managed to write a test-case, see attached patch.

With gdb trunk, we get either:
...
$ gdb -q -batch outputs/gdb.dwarf2/dwz-2/dwz-2 \
    -ex "set lang c++" \
    -ex "print ns::foo" \
    -ex "print ns::bar" 
No symbol "foo" in namespace "ns".
$1 = {int (void)} 0x4101b4 <ns::bar()>
...
or:
...
$ gdb -q -batch outputs/gdb.dwarf2/dwz-2/dwz-2 \
    -ex "set lang c++" \
    -ex "print ns::foo" \
    -ex "print ns::bar" 
$1 = {int (void)} 0x4101ac <ns::foo()>
No symbol "bar" in namespace "ns".
...

With readnow:
...
$ gdb -readnow -q -batch outputs/gdb.dwarf2/dwz-2/dwz-2 \
    -ex "set lang c++" \
    -ex "print ns::foo" \
    -ex "print ns::bar" 
$1 = {int (void)} 0x4101ac <ns::foo()>
$2 = {int (void)} 0x4101b4 <ns::bar()>
...

Also, without the "set lang c++":
...
$ gdb -q -batch dwz-2 -ex "print ns::foo" -ex "print ns::bar"
$1 = {int (void)} 0x4101ac <ns::foo()>
$2 = {int (void)} 0x4101b4 <ns::bar()>
...
which is necessary because the dwarf assembly does not mention main and it's language.

The original series does not seem to fix this either.