Re: [PATCH v2 03/28] Emit some type declarations in .gdb_index

Tom Tromey
2025-04-21T14:50:43Z

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> On 2025-04-02 19:45, Tom Tromey wrote:
>> If you run struct-decl.exp with the .gdb_index board, you will see
>> that "the_type" is not emitted in the index. This would cause a
>> failure in this series. The fix is to ensure that certain necessary
>> type declarations are emitted.
>>
>> However, a naive fix here will regress stub-array-size.exp, where a
>> type declaration and a type definition are both seen -- but the
>> declaration is seen first and causes a failure. This is handled by
>> adding some code (including a mild hack) to filter out type
>> declarations when a corresponding type definition is seen.

Simon> I don't really understand the use of GDB_INDEX_SYMBOL_KIND_UNUSED5, what
Simon> does it mean?

I thought it was reasonably well explained in the comments.
Could you say which part needs more text to be clear?

+ /* We sort the indexes in a funny way: GDB_INDEX_SYMBOL_KIND_UNUSED5
+ is always sorted last; then otherwise we sort by numeric value.
+ This ensures that we prefer the definition when both a definition
+ and a declaration (stub type) are seen. */
...
+ /* Rewrite GDB_INDEX_SYMBOL_KIND_UNUSED5. This ensures that a type
+ declaration will be deleted by the subsequent squashing step, if
+ warranted. */
...
+ /* If we added a type declaration, we want to note this
+ fact for later, because we don't want a type declaration
+ to cause the real definition to be omitted from the
+ index. GDB_INDEX_SYMBOL_KIND_UNUSED5 is used here, but
+ rewritten later before the index is written. */

Tom