From da6546c45efdbf53f796192d1b65c5557d1f1882 Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Sun, 2 Apr 2023 11:41:41 +0200 Subject: move mergeAbstractOrigin() and mergeSpecification() from readDwarf.cpp to dwarf2pdb.cpp, so they don't create a dependency for dumplines.exe --- src/dwarf2pdb.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/readDwarf.cpp | 48 ------------------------------------------------ src/readDwarf.h | 3 --- 3 files changed, 50 insertions(+), 51 deletions(-) diff --git a/src/dwarf2pdb.cpp b/src/dwarf2pdb.cpp index b65d73d..c46ab32 100644 --- a/src/dwarf2pdb.cpp +++ b/src/dwarf2pdb.cpp @@ -786,6 +786,56 @@ void CV2PDB::formatFullyQualifiedName(const DWARF_InfoData* node, char* buf, siz } } +void mergeSpecification(DWARF_InfoData& id, const CV2PDB& context); + +// Find the source of an inlined function by following its 'abstract_origin' +// attribute references and recursively merge it into 'id'. +// TODO: this description isn't quite right. See section 3.3.8.1 in DWARF 4 spec. +void mergeAbstractOrigin(DWARF_InfoData& id, const CV2PDB& context) +{ + DWARF_InfoData* abstractOrigin = context.findEntryByPtr(id.abstract_origin); + if (!abstractOrigin) { + // Could not find abstract origin. Why not? + assert(false); + return; + } + + // assert seems invalid, combination DW_TAG_member and DW_TAG_variable found + // in the wild. + // + // assert(id.tag == idspec.tag); + + if (abstractOrigin->abstract_origin) + mergeAbstractOrigin(*abstractOrigin, context); + if (abstractOrigin->specification) + mergeSpecification(*abstractOrigin, context); + id.merge(*abstractOrigin); +} + +// Find the declaration entry for a definition by following its 'specification' +// attribute references and merge it into 'id'. +void mergeSpecification(DWARF_InfoData& id, const CV2PDB& context) +{ + DWARF_InfoData* idspec = context.findEntryByPtr(id.specification); + if (!idspec) { + // Could not find decl for this definition. Why not? + assert(false); + return; + } + + // assert seems invalid, combination DW_TAG_member and DW_TAG_variable found + // in the wild. + // + // assert(id.tag == idspec.tag); + + if (idspec->abstract_origin) + mergeAbstractOrigin(*idspec, context); + if (idspec->specification) { + mergeSpecification(*idspec, context); + } + id.merge(*idspec); +} + bool CV2PDB::addDWARFProc(DWARF_InfoData& procid, const std::vector &ranges, DIECursor cursor) { unsigned int pclo = ranges.front().pclo - codeSegOff; diff --git a/src/readDwarf.cpp b/src/readDwarf.cpp index 6562980..e6f187c 100644 --- a/src/readDwarf.cpp +++ b/src/readDwarf.cpp @@ -363,54 +363,6 @@ Location decodeLocation(const DWARF_Attribute& attr, const Location* frameBase, return stack[0]; } -// Find the source of an inlined function by following its 'abstract_origin' -// attribute references and recursively merge it into 'id'. -// TODO: this description isn't quite right. See section 3.3.8.1 in DWARF 4 spec. -void mergeAbstractOrigin(DWARF_InfoData& id, const CV2PDB& context) -{ - DWARF_InfoData* abstractOrigin = context.findEntryByPtr(id.abstract_origin); - if (!abstractOrigin) { - // Could not find abstract origin. Why not? - assert(false); - return; - } - - // assert seems invalid, combination DW_TAG_member and DW_TAG_variable found - // in the wild. - // - // assert(id.tag == idspec.tag); - - if (abstractOrigin->abstract_origin) - mergeAbstractOrigin(*abstractOrigin, context); - if (abstractOrigin->specification) - mergeSpecification(*abstractOrigin, context); - id.merge(*abstractOrigin); -} - -// Find the declaration entry for a definition by following its 'specification' -// attribute references and merge it into 'id'. -void mergeSpecification(DWARF_InfoData& id, const CV2PDB& context) -{ - DWARF_InfoData* idspec = context.findEntryByPtr(id.specification); - if (!idspec) { - // Could not find decl for this definition. Why not? - assert(false); - return; - } - - // assert seems invalid, combination DW_TAG_member and DW_TAG_variable found - // in the wild. - // - // assert(id.tag == idspec.tag); - - if (idspec->abstract_origin) - mergeAbstractOrigin(*idspec, context); - if (idspec->specification) { - mergeSpecification(*idspec, context); - } - id.merge(*idspec); -} - LOCCursor::LOCCursor(const DIECursor& parent, unsigned long off) : parent(parent) { diff --git a/src/readDwarf.h b/src/readDwarf.h index 4b0ac98..b4f2f85 100644 --- a/src/readDwarf.h +++ b/src/readDwarf.h @@ -547,9 +547,6 @@ typedef std::unordered_map, byte*> abbrevMap_t; // as either an absolute value, a register, or a register-relative address. Location decodeLocation(const DWARF_Attribute& attr, const Location* frameBase = 0, int at = 0); -void mergeAbstractOrigin(DWARF_InfoData& id, const CV2PDB& context); -void mergeSpecification(DWARF_InfoData& id, const CV2PDB& context); - // Debug Information Entry Cursor class DIECursor { -- cgit v0.12