From: Tom Tromey <tom@tromey.com>
To: Simon Marchi <simark@simark.ca>
Cc: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2 8/8] Update .debug_names documentation
Date: Tue, 10 Feb 2026 09:14:43 -0700 [thread overview]
Message-ID: <87zf5gvamk.fsf@tromey.com> (raw)
In-Reply-To: <f40639cd-39d8-44ac-825e-f7ffecdb5e0a@simark.ca> (Simon Marchi's message of "Mon, 9 Feb 2026 23:26:57 -0500")
>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
>> +The @code{DW_IDX_parent} for a C-style enumerator does not point at
>> +the entry for @code{enum} itself, but rather the parent of the type.
>> +The reason for this is that C-style enumerators are injected into the
>> +containing scope, and so their name is not qualified by the
>> +@code{enum}; and furthermore there is no way to distinguish between
>> +C-style enumerators and @code{enum class}-style enumerators in
>> +@samp{.debug_names}.
Simon> Ok, so IIUC: there is a way to distinguish between C enums and C++
Simon> enum-class enums in the debug info itself, but not in .debug_names. So
Simon> there is no way just from the index to tell if an enumerator name should
Simon> be visible from the enclosing scope of not.
Simon> It sounds like another fix I could bring up to the committee, if we can
Simon> find a good solution.
The gdb fix of changing the parentage seems reasonable. More on the
rationale below.
Simon> So, is putting enumerators in .debug_names an extension to the standard
Simon> in itself?
Oh maybe so.
Simon> I don't really understand the logic of not putting the non-enum-class
Simon> enumerators in the index.
Indeed but there are many mysteries in DWARF.
Perhaps omitting enum class enumerators would be ok. It might require
some changes to gdb. I don't plan to work on this, I barely think the
indexes are worthwhile any more.
>> +Similarly, @code{DW_IDX_parent} is omitted for any linkage name
>> +entries that are written.
Simon> Is this just an optimization? Because for a linkage name, you don't need
Simon> to know the parent, since there is not need to build the fully qualified
Simon> name?
gdb could of course ignore the parentage of a linkage name entry.
But my view is that the name table is there not to tell gdb the DIE
parentage in some abstract way, but instead to indicate the names of
entities. That's because I see the index as an enhancement to lookup
and not as a summary version of the .debug_info.
This view informs both the enum case and the linkage name case.
That is, my thought is that the DW_IDX_parent stuff is there to explain
to the debugger how to do a name lookup -- it describes the names, not
the DWARF.
So, a linkage name doesn't have a parent in this sense, because it is
already a fully-qualified name. And likewise an ordinary enumerator is
hoisted into the outer scope.
>> +A further special case applies to @code{DW_TAG_inlined_subroutine}
>> +entries. An inlined subroutine appearing in a partial unit may be
>> +inlined in all of the outermost compilation units that directly or
>> +indirectly include the partial unit. Therefore, in this case,
>> +@value{GDBN} will emit a separate index entry for the entry, once for
>> +each such containing unit.
>> +@end itemize
Simon> This question probably relates more to the previous patch, but I don't
Simon> quite understand why this applies to inlined functions but not to other
Simon> entities found in the PU. You'd think that if you have a static
Simon> (file-local) variable defined in a PU, it means that all including CUs
Simon> have this variable defined. So wouldn't you want an entry at that name
Simon> for all these CUs?
For a variable to be shared in a PU, either it will just be a
declaration and each including CU will have a separate definition that
refers to it; or alternatively every such variable will have the same
address. But in the latter case they are the same variable.
Inline functions are different. An inline function will have a
DW_TAG_subprogram DIE somewhere (the CU level or appropriate namespace
scope or whatever) that is a marker indicating "this function is inlined
somewhere in this CU".
If you want to find out where it was inlined, the reader has to scan
that CU looking for DW_TAG_inlined_subroutine.
In the dwz case, the marker DIE might well be moved into a PU. This
isn't like the variable case because there isn't necessarily an address,
just an DW_AT_inline on the DIE.
If this DIE is in a PU, then potentially the function has been inlined
somewhere in all including CUs.
BTW the DWARF approach to inline functions will also hamper incremental
CU expansion (if we ever get there). At the very least when finding an
inline function gdb will have to scan all DIEs in the CUs just in case.
Tom
next prev parent reply other threads:[~2026-02-10 16:15 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-26 21:33 [PATCH v2 0/8] Correctly handle inline functions with dwz Tom Tromey
2026-01-26 21:33 ` [PATCH v2 1/8] Don't call add_dependence from index_imported_unit Tom Tromey
2026-01-26 21:33 ` [PATCH v2 2/8] Skip partial units in process_psymtab_comp_unit Tom Tromey
2026-01-26 21:33 ` [PATCH v2 3/8] Don't consider DW_TAG_inlined_subroutine as interesting Tom Tromey
2026-01-26 21:33 ` [PATCH v2 4/8] Combine two cases in cooked_index_functions::search Tom Tromey
2026-01-26 21:33 ` [PATCH v2 5/8] Remove C++ special case from process_imported_unit_die Tom Tromey
2026-01-26 21:33 ` [PATCH v2 6/8] Have iterate_over_one_compunit_symtab search included symtabs Tom Tromey
2026-01-30 22:04 ` Simon Marchi
2026-01-31 15:04 ` Tom Tromey
2026-01-26 21:33 ` [PATCH v2 7/8] Handle inline functions with dwz Tom Tromey
2026-02-10 3:51 ` Simon Marchi
2026-01-26 21:33 ` [PATCH v2 8/8] Update .debug_names documentation Tom Tromey
2026-02-10 4:26 ` Simon Marchi
2026-02-10 16:14 ` Tom Tromey [this message]
2026-02-10 17:03 ` Simon Marchi
2026-02-10 19:52 ` Tom Tromey
2026-02-10 20:25 ` Simon Marchi
2026-02-10 20:46 ` Tom Tromey
2026-01-26 21:42 ` [PATCH v2 0/8] Correctly handle inline functions with dwz Simon Marchi
2026-01-26 23:31 ` Tom Tromey
2026-01-26 22:05 ` Tom de Vries
2026-01-30 22:06 ` Simon Marchi
2026-03-05 18:53 ` Tom Tromey
2026-02-06 19:14 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zf5gvamk.fsf@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
--cc=simark@simark.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox