Skip to content

Commit

Permalink
move mergeAbstractOrigin() and mergeSpecification() from readDwarf.cp…
Browse files Browse the repository at this point in the history
…p to dwarf2pdb.cpp, so they don't create a dependency for dumplines.exe
  • Loading branch information
rainers committed Apr 2, 2023
1 parent 4d9596c commit da6546c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 51 deletions.
50 changes: 50 additions & 0 deletions src/dwarf2pdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<RangeEntry> &ranges, DIECursor cursor)
{
unsigned int pclo = ranges.front().pclo - codeSegOff;
Expand Down
48 changes: 0 additions & 48 deletions src/readDwarf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
3 changes: 0 additions & 3 deletions src/readDwarf.h
Original file line number Diff line number Diff line change
Expand Up @@ -547,9 +547,6 @@ typedef std::unordered_map<std::pair<unsigned, unsigned>, 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
{
Expand Down

0 comments on commit da6546c

Please sign in to comment.