https://github.com/Endilll created https://github.com/llvm/llvm-project/pull/66879
Migrated from https://reviews.llvm.org/D156774 >From 72f83fb2944829c60bd6f12a079bfba95da4f6e7 Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov <serebrennikov.vladis...@gmail.com> Date: Thu, 14 Sep 2023 09:46:53 +0300 Subject: [PATCH 1/2] Implementation (migrated from Phabricator) --- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 15 +++++++++------ .../SymbolFile/DWARF/DWARFASTParserClang.h | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 37fb16d4e0351c9..fc340da8eba0763 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2150,14 +2150,14 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die, std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases; // Parse members and base classes first - std::vector<DWARFDIE> member_function_dies; + std::vector<DWARFDIE> member_function_and_type_dies; DelayedPropertyList delayed_properties; - ParseChildMembers(die, clang_type, bases, member_function_dies, + ParseChildMembers(die, clang_type, bases, member_function_and_type_dies, delayed_properties, default_accessibility, layout_info); - // Now parse any methods if there were any... - for (const DWARFDIE &die : member_function_dies) + // Now parse any methods or nested types if there were any... + for (const DWARFDIE &die : member_function_and_type_dies) dwarf->ResolveType(die); if (type_is_objc_object_or_interface) { @@ -3153,7 +3153,7 @@ void DWARFASTParserClang::ParseSingleMember( bool DWARFASTParserClang::ParseChildMembers( const DWARFDIE &parent_die, CompilerType &class_clang_type, std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes, - std::vector<DWARFDIE> &member_function_dies, + std::vector<DWARFDIE> &member_function_and_type_dies, DelayedPropertyList &delayed_properties, const AccessType default_accessibility, ClangASTImporter::LayoutInfo &layout_info) { @@ -3189,8 +3189,11 @@ bool DWARFASTParserClang::ParseChildMembers( break; case DW_TAG_subprogram: + case DW_TAG_enumeration_type: + case DW_TAG_structure_type: + case DW_TAG_union_type: // Let the type parsing code handle this one for us. - member_function_dies.push_back(die); + member_function_and_type_dies.push_back(die); break; case DW_TAG_inheritance: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h index 88bfc490e890744..d4218959e61a8fa 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h @@ -157,7 +157,7 @@ class DWARFASTParserClang : public DWARFASTParser { bool ParseChildMembers( const DWARFDIE &die, lldb_private::CompilerType &class_compiler_type, std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes, - std::vector<DWARFDIE> &member_function_dies, + std::vector<DWARFDIE> &member_function_and_type_dies, DelayedPropertyList &delayed_properties, const lldb::AccessType default_accessibility, lldb_private::ClangASTImporter::LayoutInfo &layout_info); >From 4a4aa7ad35124414aafdb7db44c89e51f498aa83 Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov <serebrennikov.vladis...@gmail.com> Date: Wed, 20 Sep 2023 12:32:44 +0300 Subject: [PATCH 2/2] Add an incomplete unit test --- .../DWARF/DWARFASTParserClangTests.cpp | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp index 20a085741f73d00..d47f9b636ec15eb 100644 --- a/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp +++ b/lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp @@ -462,3 +462,96 @@ TEST_F(DWARFASTParserClangTests, TestDefaultTemplateParamParsing) { } } } + +TEST_F(DWARFASTParserClangTests, EnsureNestedTypesOfTypeAreParsed) { + const char *yamldata = R"( +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_386 +DWARF: + debug_str: + - Info + - B + - C + - Mask + - Enum + debug_abbrev: + - Table: + - Code: 0x1 + Tag: DW_TAG_compile_unit + Children: DW_CHILDREN_yes + Attributes: + - Attribute: DW_AT_language + Form: DW_FORM_data2 + - Code: 0x2 + Tag: DW_TAG_structure_type + Children: DW_CHILDREN_yes + Attributes: + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Code: 0x3 + Tag: DW_TAG_union_type + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Code: 0x4 + Tag: DW_TAG_structure_type + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Code: 0x5 + Tag: DW_TAG_enumeration_type + Children: DW_CHILDREN_yes + Attributes: + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Code: 0x6 + Tag: DW_TAG_enumerator + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_name + Form: DW_FORM_strp + debug_info: + - Version: 5 + AddrSize: 8 + UnitType: DW_UT_compile + Entries: + - AbbrCode: 0x1 + Values: + - Value: 0x21 + - AbbrCode: 0x2 + Values: + - Value: 0x0 + - AbbrCode: 0x3 + Values: + - Value: 0x5 + - AbbrCode: 0x4 + Values: + - Value: 0x7 + - AbbrCode: 0x5 + Values: + - Value: 0x9 + - AbbrCode: 0x6 + Values: + - Value: 0xE +)"; + + YAMLModuleTester t(yamldata); + + DWARFUnit *unit = t.GetDwarfUnit(); + ASSERT_NE(unit, nullptr); + const DWARFDebugInfoEntry *cu_entry = unit->DIE().GetDIE(); + ASSERT_EQ(cu_entry->Tag(), DW_TAG_compile_unit); + DWARFDIE cu_die(unit, cu_entry); + + auto holder = std::make_unique<clang_utils::TypeSystemClangHolder>("ast"); + auto &ast_ctx = *holder->GetAST(); + DWARFASTParserClangStub ast_parser(ast_ctx); + + EXPECT_TRUE(false); +} _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits