summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/DebugInfo')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFContext.cpp10
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp27
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp21
3 files changed, 37 insertions, 21 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index decf7a284b3..e159303ab20 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -387,7 +387,7 @@ void DWARFContext::dump(
if (DumpOffset && Offset != *DumpOffset) {
// Find the size of this part of the line table section and skip it.
unsigned OldOffset = Offset;
- LineTable.Prologue.parse(LineData, &Offset, U);
+ LineTable.Prologue.parse(LineData, &Offset, *this, U);
Offset = OldOffset + LineTable.Prologue.TotalLength +
LineTable.Prologue.sizeofTotalLength();
continue;
@@ -397,9 +397,9 @@ void DWARFContext::dump(
OS << "debug_line[" << format("0x%8.8x", Offset) << "]\n";
unsigned OldOffset = Offset;
if (DumpOpts.Verbose) {
- LineTable.parse(LineData, &Offset, U, &OS);
+ LineTable.parse(LineData, &Offset, *this, U, &OS);
} else {
- LineTable.parse(LineData, &Offset, U);
+ LineTable.parse(LineData, &Offset, *this, U);
LineTable.dump(OS);
}
// Check for unparseable prologue, to avoid infinite loops.
@@ -422,7 +422,7 @@ void DWARFContext::dump(
U = It->second;
DWARFDebugLine::LineTable LineTable;
unsigned OldOffset = Offset;
- if (!LineTable.Prologue.parse(LineData, &Offset, U))
+ if (!LineTable.Prologue.parse(LineData, &Offset, *this, U))
break;
if (!DumpOffset || OldOffset == *DumpOffset)
LineTable.dump(OS);
@@ -781,7 +781,7 @@ DWARFContext::getLineTableForUnit(DWARFUnit *U) {
// We have to parse it first.
DWARFDataExtractor lineData(*DObj, U->getLineSection(), isLittleEndian(),
U->getAddressByteSize());
- return Line->getOrParseLineTable(lineData, stmtOffset, U);
+ return Line->getOrParseLineTable(lineData, stmtOffset, *this, U);
}
void DWARFContext::parseCompileUnits() {
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
index 7bc6f10e516..0bc56aed07c 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -157,8 +157,9 @@ parseV5EntryFormat(const DWARFDataExtractor &DebugLineData, uint32_t *OffsetPtr,
static bool
parseV5DirFileTables(const DWARFDataExtractor &DebugLineData,
uint32_t *OffsetPtr, uint64_t EndPrologueOffset,
- const DWARFFormParams &FormParams, const DWARFUnit *U,
- bool &HasMD5, std::vector<StringRef> &IncludeDirectories,
+ const DWARFFormParams &FormParams, const DWARFContext &Ctx,
+ const DWARFUnit *U, bool &HasMD5,
+ std::vector<StringRef> &IncludeDirectories,
std::vector<DWARFDebugLine::FileNameEntry> &FileNames) {
// Get the directory entry description.
ContentDescriptors DirDescriptors =
@@ -175,7 +176,7 @@ parseV5DirFileTables(const DWARFDataExtractor &DebugLineData,
DWARFFormValue Value(Descriptor.Form);
switch (Descriptor.Type) {
case DW_LNCT_path:
- if (!Value.extractValue(DebugLineData, OffsetPtr, FormParams, U))
+ if (!Value.extractValue(DebugLineData, OffsetPtr, FormParams, &Ctx, U))
return false;
IncludeDirectories.push_back(Value.getAsCString().getValue());
break;
@@ -200,7 +201,7 @@ parseV5DirFileTables(const DWARFDataExtractor &DebugLineData,
DWARFDebugLine::FileNameEntry FileEntry;
for (auto Descriptor : FileDescriptors) {
DWARFFormValue Value(Descriptor.Form);
- if (!Value.extractValue(DebugLineData, OffsetPtr, FormParams, U))
+ if (!Value.extractValue(DebugLineData, OffsetPtr, FormParams, &Ctx, U))
return false;
switch (Descriptor.Type) {
case DW_LNCT_path:
@@ -230,7 +231,9 @@ parseV5DirFileTables(const DWARFDataExtractor &DebugLineData,
}
bool DWARFDebugLine::Prologue::parse(const DWARFDataExtractor &DebugLineData,
- uint32_t *OffsetPtr, const DWARFUnit *U) {
+ uint32_t *OffsetPtr,
+ const DWARFContext &Ctx,
+ const DWARFUnit *U) {
const uint64_t PrologueOffset = *OffsetPtr;
clear();
@@ -271,7 +274,7 @@ bool DWARFDebugLine::Prologue::parse(const DWARFDataExtractor &DebugLineData,
if (getVersion() >= 5) {
if (!parseV5DirFileTables(DebugLineData, OffsetPtr, EndPrologueOffset,
- FormParams, U, HasMD5, IncludeDirectories,
+ FormParams, Ctx, U, HasMD5, IncludeDirectories,
FileNames)) {
fprintf(stderr,
"warning: parsing line table prologue at 0x%8.8" PRIx64
@@ -401,25 +404,27 @@ DWARFDebugLine::getLineTable(uint32_t Offset) const {
const DWARFDebugLine::LineTable *
DWARFDebugLine::getOrParseLineTable(DWARFDataExtractor &DebugLineData,
- uint32_t Offset, const DWARFUnit *U) {
+ uint32_t Offset, const DWARFContext &Ctx,
+ const DWARFUnit *U) {
std::pair<LineTableIter, bool> Pos =
LineTableMap.insert(LineTableMapTy::value_type(Offset, LineTable()));
LineTable *LT = &Pos.first->second;
if (Pos.second) {
- if (!LT->parse(DebugLineData, &Offset, U))
+ if (!LT->parse(DebugLineData, &Offset, Ctx, U))
return nullptr;
}
return LT;
}
bool DWARFDebugLine::LineTable::parse(DWARFDataExtractor &DebugLineData,
- uint32_t *OffsetPtr, const DWARFUnit *U,
- raw_ostream *OS) {
+ uint32_t *OffsetPtr,
+ const DWARFContext &Ctx,
+ const DWARFUnit *U, raw_ostream *OS) {
const uint32_t DebugLineOffset = *OffsetPtr;
clear();
- if (!Prologue.parse(DebugLineData, OffsetPtr, U)) {
+ if (!Prologue.parse(DebugLineData, OffsetPtr, Ctx, U)) {
// Restore our offset and return false to indicate failure!
*OffsetPtr = DebugLineOffset;
return false;
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
index 81b60c57daa..089df4cdc97 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
@@ -293,7 +293,11 @@ bool DWARFFormValue::isFormClass(DWARFFormValue::FormClass FC) const {
bool DWARFFormValue::extractValue(const DWARFDataExtractor &Data,
uint32_t *OffsetPtr, DWARFFormParams FP,
+ const DWARFContext *Ctx,
const DWARFUnit *CU) {
+ if (!Ctx && CU)
+ Ctx = &CU->getContext();
+ C = Ctx;
U = CU;
bool Indirect = false;
bool IsBlock = false;
@@ -591,11 +595,12 @@ Optional<const char *> DWARFFormValue::getAsCString() const {
if (Form == DW_FORM_string)
return Value.cstr;
// FIXME: Add support for DW_FORM_GNU_strp_alt
- if (Form == DW_FORM_GNU_strp_alt || U == nullptr)
+ if (Form == DW_FORM_GNU_strp_alt || C == nullptr)
return None;
uint32_t Offset = Value.uval;
if (Form == DW_FORM_line_strp) {
- if (const char *Str = U->getLineStringExtractor().getCStr(&Offset))
+ // .debug_line_str is tracked in the Context.
+ if (const char *Str = C->getLineStringExtractor().getCStr(&Offset))
return Str;
return None;
}
@@ -603,13 +608,19 @@ Optional<const char *> DWARFFormValue::getAsCString() const {
Form == DW_FORM_strx1 || Form == DW_FORM_strx2 || Form == DW_FORM_strx3 ||
Form == DW_FORM_strx4) {
uint64_t StrOffset;
- if (!U->getStringOffsetSectionItem(Offset, StrOffset))
+ if (!U || !U->getStringOffsetSectionItem(Offset, StrOffset))
return None;
Offset = StrOffset;
}
- if (const char *Str = U->getStringExtractor().getCStr(&Offset)) {
- return Str;
+ // Prefer the Unit's string extractor, because for .dwo it will point to
+ // .debug_str.dwo, while the Context's extractor always uses .debug_str.
+ if (U) {
+ if (const char *Str = U->getStringExtractor().getCStr(&Offset))
+ return Str;
+ return None;
}
+ if (const char *Str = C->getStringExtractor().getCStr(&Offset))
+ return Str;
return None;
}
OpenPOWER on IntegriCloud