[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #92328)
Zequan Wu via lldb-commits
lldb-commits at lists.llvm.org
Thu May 30 08:57:43 PDT 2024
ZequanWu wrote:
For this specific case, we could fix it by making `DW_TAG_structure_type` equals to `DW_TAG_class_type` in the `UniqueDWARFASTTypeList::Find`.
There's few things I noticed with this:
1. If `DW_TAG_structure_type` and `DW_TAG_class_type` are interchangeable, then this comparison on DIE tags also needs to be updated: https://github.com/llvm/llvm-project/blob/a871470a0d0c828718409c7a6dfb067a3231d013/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp#L40-L42, because the one parent DIE could be struct another one could be class and they need to be treated as matched.
2. I wonder why this is not a problem before this change. Before, when `ParseStructureLikeDIE` sees a struct declaration, it searches for definition DIE from type index, which just checks for the fully qualified name of the types. So, it will find the DIE `DW_TAG_class_type` as a definition DIE and create one type from the definition DIE. If `ParseStructureLikeDIE` sees the class definition first. the lldb will be created and `UniqueDWARFASTTypeMap` will have a cache of the type. Later when `ParseStructureLikeDIE` parses the struct declaration, it will still failed to find the cache type in the `UniqueDWARFASTTypeMap` but the call to `FindDefinitionTypeForDWARFDeclContext` will find the definition DIE using fully qualified name which avoid creating the type twice.
So, basically this PR relies `UniqueDWARFASTTypeMap` to correctly find the mapping from declaration DIEs to definition DIE and start definition on the clang type (might created from declaration), while it had a backup call to `FindDefinitionTypeForDWARFDeclContext` to find definition DIE with just fully qualified name before this PR.
In case of we failed to find existing clang type (created from declaration) in `UniqueDWARFASTTypeMap`, I think it's good to start definition in `CompleteRecordType` if the clang type hasn't started its definition. Sent https://github.com/llvm/llvm-project/pull/93839 to fix it.
https://github.com/llvm/llvm-project/pull/92328
More information about the lldb-commits
mailing list