mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-22 23:24:59 +00:00
[DWARF parser] Make DWARF parser more robust against missing compile/type units.
DWARF standard claims that each compilation/type unit header in .debug_info/.debug_types section must be followed by corresponding compile/type unit DIE, possibly with its children. Two situations are possible: * compile/type unit DIE is missing because DWARF producer failed to emit it. * DWARF parser failed to parse unit DIE correctly, for instance if it contains some unsupported attributes (see r237721, for instance). In either of these cases, the library, and the tools that use it (llvm-dwarfdump, llvm-symbolizer) should not crash. Insert appropriate checks to protect against this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237733 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -195,9 +195,8 @@ public:
|
||||
BaseAddr = base_addr;
|
||||
}
|
||||
|
||||
const DWARFDebugInfoEntryMinimal *
|
||||
getCompileUnitDIE(bool extract_cu_die_only = true) {
|
||||
extractDIEsIfNeeded(extract_cu_die_only);
|
||||
const DWARFDebugInfoEntryMinimal *getUnitDIE(bool ExtractUnitDIEOnly = true) {
|
||||
extractDIEsIfNeeded(ExtractUnitDIEOnly);
|
||||
return DieArray.empty() ? nullptr : &DieArray[0];
|
||||
}
|
||||
|
||||
@@ -226,8 +225,7 @@ public:
|
||||
/// It is illegal to call this method with a DIE that hasn't be
|
||||
/// created by this unit. In other word, it's illegal to call this
|
||||
/// method on a DIE that isn't accessible by following
|
||||
/// children/sibling links starting from this unit's
|
||||
/// getCompileUnitDIE().
|
||||
/// children/sibling links starting from this unit's getUnitDIE().
|
||||
uint32_t getDIEIndex(const DWARFDebugInfoEntryMinimal *DIE) {
|
||||
assert(!DieArray.empty() && DIE >= &DieArray[0] &&
|
||||
DIE < &DieArray[0] + DieArray.size());
|
||||
|
Reference in New Issue
Block a user