David has pretty much summed it up, but to restate: 

When we implemented this, we had to be able to distinguish the two cases below:
1. there are no IDX_parent in an accelerator table because the producer did not 
generate them.
2. there are no IDX_parent in an accelerator table because the parent is not 
indexed.

Case 1 is represented by the absence of IDX_parent, whereas Case 2 is captured 
by the "flag_present" case.
We also needed case 2 to be space-efficient, which is accomplished through the 
use of a Form that has no data associated with it (other than its abbreviation 
entry).

There is more context on this in the thread below.
https://discourse.llvm.org/t/rfc-improve-dwarf-5-debug-names-type-lookup-parsing-speed/74151/42

Maybe this is something we could submit for standardization?

> On Sep 3, 2024, at 15:05, Adrian Prantl via Dwarf-discuss 
> <dwarf-discuss@lists.dwarfstd.org> wrote:
> 
> CC'ing Felipe Piovezan, who implement this feature, in case he wants to fill 
> in more details.
> 
> -- adrian
> 
>> On Sep 3, 2024, at 10:06 AM, David Blaikie via Dwarf-discuss 
>> <dwarf-discuss@lists.dwarfstd.org> wrote:
>> 
>> Some context:
>> https://discourse.llvm.org/t/rfc-improve-dwarf-5-debug-names-type-lookup-parsing-speed/74151/44
>> https://github.com/llvm/llvm-project/pull/77457
>> 
>> Essentially clang/llvm produces DW_IDX_parent with DW_FORM_flag_present when 
>> the entry has a parent, but that parent isn't indexed (I think this mostly 
>> comes up for the entities that are direct children of the unit DIE).
>> 
>> This is designed to make it more efficient for consumers (lldb, in 
>> particular) to do quicker comparisons from the index for qualified names.
>> 
>> My vague recollection is the idea that the consumer needs that info to know 
>> the difference between "this thing may or may not have a parent" and "this 
>> thing has an unnamed/unindexed parent".
>> 
>> On Sat, Aug 31, 2024 at 1:03 PM David Anderson via Dwarf-discuss 
>> <dwarf-discuss@lists.dwarfstd.org <mailto:dwarf-discuss@lists.dwarfstd.org>> 
>> wrote:
>>> Dwarf5. The Name Table .debug_names
>>> 
>>> Background:
>>> 6.1.1.2, page 141
>>> Parent debugging information entry, a reference to the
>>> index entry for the parent. This is represented as the
>>> offset of the entry relative to the start of the entry
>>> pool.
>>> 
>>> Table 7.232 Name index attribute encodings
>>>        DW_IDX_parent constant
>>> 
>>> 
>>> However clang version 18.1.8 generates
>>> 
>>> DW_IDX_parent      DW_FORM_flag_present
>>> when there is no parent entry to refer to.
>>> 
>>> And that does not seem to match what DWARF5
>>> says to do.
>>> 
>>> So what is 'true' supposed to mean for DW_IDX_parent?
>>> 
>>> A bit puzzled here.
>>> Thanks for any insight.
>>> David Anderson
>>> 
>>> --
>>> Lisp Users: Due to the holiday next
>>> Monday, there will be no garbage
>>> collection. --seen on Slashdot
>>> -- 
>>> Dwarf-discuss mailing list
>>> Dwarf-discuss@lists.dwarfstd.org <mailto:Dwarf-discuss@lists.dwarfstd.org>
>>> https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss
>> -- 
>> Dwarf-discuss mailing list
>> Dwarf-discuss@lists.dwarfstd.org
>> https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss
> 
> -- 
> Dwarf-discuss mailing list
> Dwarf-discuss@lists.dwarfstd.org
> https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss

-- 
Dwarf-discuss mailing list
Dwarf-discuss@lists.dwarfstd.org
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss

Reply via email to