[llvm] r257943 - [codeview] Handle multiple frame descriptions in readobj
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 15 14:09:13 PST 2016
Author: rnk
Date: Fri Jan 15 16:09:13 2016
New Revision: 257943
URL: http://llvm.org/viewvc/llvm-project?rev=257943&view=rev
Log:
[codeview] Handle multiple frame descriptions in readobj
Modified:
llvm/trunk/test/tools/llvm-readobj/codeview-linetables.test
llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
Modified: llvm/trunk/test/tools/llvm-readobj/codeview-linetables.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/codeview-linetables.test?rev=257943&r1=257942&r2=257943&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/codeview-linetables.test (original)
+++ llvm/trunk/test/tools/llvm-readobj/codeview-linetables.test Fri Jan 15 16:09:13 2016
@@ -34,11 +34,11 @@ MFUN32-NEXT: Subsection [
MFUN32-NEXT: SubSectionType: Symbols (0xF1)
MFUN32-NEXT: SubSectionSize: 0x52
MFUN32: ]
-MFUN32: Subsection [
+MFUN32: Subsection [
MFUN32-NEXT: SubSectionType: FrameData (0xF5)
MFUN32-NEXT: SubSectionSize: 0x24
MFUN32: ]
-MFUN32-NEXT: Subsection [
+MFUN32: Subsection [
MFUN32-NEXT: SubSectionType: Symbols (0xF1)
MFUN32-NEXT: SubSectionSize: 0x4B
MFUN32: ProcStart {
@@ -48,7 +48,7 @@ MFUN32: LinkageName: _x
MFUN32: }
MFUN32: ProcEnd
MFUN32: ]
-MFUN32-NEXT: Subsection [
+MFUN32: Subsection [
MFUN32-NEXT: SubSectionType: Lines (0xF2)
MFUN32-NEXT: SubSectionSize: 0x30
MFUN32: LinkageName: _x
@@ -57,7 +57,7 @@ MFUN32-NEXT: Subsection [
MFUN32-NEXT: SubSectionType: FrameData (0xF5)
MFUN32-NEXT: SubSectionSize: 0x24
MFUN32: ]
-MFUN32-NEXT: Subsection [
+MFUN32: Subsection [
MFUN32-NEXT: SubSectionType: Symbols (0xF1)
MFUN32-NEXT: SubSectionSize: 0x4B
MFUN32: ProcStart {
@@ -76,7 +76,7 @@ MFUN32-NEXT: Subsection [
MFUN32-NEXT: SubSectionType: FrameData (0xF5)
MFUN32-NEXT: SubSectionSize: 0x24
MFUN32: ]
-MFUN32-NEXT: Subsection [
+MFUN32: Subsection [
MFUN32-NEXT: SubSectionType: Symbols (0xF1)
MFUN32-NEXT: SubSectionSize: 0x4B
MFUN32: ProcStart {
@@ -86,7 +86,7 @@ MFUN32: LinkageName: _f
MFUN32: }
MFUN32: ProcEnd
MFUN32: ]
-MFUN32-NEXT: Subsection [
+MFUN32: Subsection [
MFUN32-NEXT: SubSectionType: Lines (0xF2)
MFUN32-NEXT: SubSectionSize: 0x40
MFUN32: LinkageName: _f
@@ -362,7 +362,7 @@ MFILE32: Subsection [
MFILE32-NEXT: SubSectionType: FrameData (0xF5)
MFILE32-NEXT: SubSectionSize: 0x24
MFILE32: ]
-MFILE32-NEXT: Subsection [
+MFILE32: Subsection [
MFILE32-NEXT: SubSectionType: Symbols (0xF1)
MFILE32-NEXT: SubSectionSize: 0x4B
MFILE32: ProcStart {
Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=257943&r1=257942&r2=257943&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Fri Jan 15 16:09:13 2016
@@ -988,7 +988,6 @@ void COFFDumper::printCodeViewSymbolSect
SmallVector<StringRef, 10> FunctionNames;
StringMap<StringRef> FunctionLineTables;
- std::map<StringRef, const FrameData *> FunctionFrameData;
ListScope D(W, "CodeViewDebugInfo");
// Print the section to allow correlation with printSections.
@@ -1028,7 +1027,8 @@ void COFFDumper::printCodeViewSymbolSect
// Optionally print the subsection bytes in case our parsing gets confused
// later.
if (opts::CodeViewSubsectionBytes)
- W.printBinaryBlock("SubSectionContents", Contents);
+ printBinaryBlockWithRelocs("SubSectionContents", Section, SectionContents,
+ Contents);
switch (ModuleSubstreamKind(SubType)) {
case ModuleSubstreamKind::Symbols:
@@ -1070,23 +1070,30 @@ void COFFDumper::printCodeViewSymbolSect
break;
}
case ModuleSubstreamKind::FrameData: {
- const size_t RelocationSize = 4;
- if (SubSectionSize != sizeof(FrameData) + RelocationSize) {
- // There should be exactly one relocation followed by the FrameData
- // contents.
- error(object_error::parse_failed);
- return;
- }
-
- const auto *FD = reinterpret_cast<const FrameData *>(
- Contents.drop_front(RelocationSize).data());
-
+ // First four bytes is a relocation against the function.
+ const uint32_t *CodePtr;
+ error(consumeObject(Contents, CodePtr));
StringRef LinkageName;
- error(resolveSymbolName(Obj->getCOFFSection(Section), SectionOffset,
- LinkageName));
- if (!FunctionFrameData.insert(std::make_pair(LinkageName, FD)).second) {
- error(object_error::parse_failed);
- return;
+ error(resolveSymbolName(Obj->getCOFFSection(Section), SectionContents,
+ CodePtr, LinkageName));
+ W.printString("LinkageName", LinkageName);
+
+ // To find the active frame description, search this array for the
+ // smallest PC range that includes the current PC.
+ while (!Contents.empty()) {
+ const FrameData *FD;
+ error(consumeObject(Contents, FD));
+ DictScope S(W, "FrameData");
+ W.printHex("RvaStart", FD->RvaStart);
+ W.printHex("CodeSize", FD->CodeSize);
+ W.printHex("LocalSize", FD->LocalSize);
+ W.printHex("ParamsSize", FD->ParamsSize);
+ W.printHex("MaxStackSize", FD->MaxStackSize);
+ W.printString("FrameFunc",
+ CVStringTable.drop_front(FD->FrameFunc).split('\0').first);
+ W.printHex("PrologSize", FD->PrologSize);
+ W.printHex("SavedRegsSize", FD->SavedRegsSize);
+ W.printFlags("Flags", FD->Flags, makeArrayRef(FrameDataFlags));
}
break;
}
@@ -1095,6 +1102,7 @@ void COFFDumper::printCodeViewSymbolSect
default:
break;
}
+ W.flush();
}
// Dump the line tables now that we've read all the subsections and know all
@@ -1168,22 +1176,6 @@ void COFFDumper::printCodeViewSymbolSect
}
}
}
-
- for (auto FrameDataPair : FunctionFrameData) {
- StringRef LinkageName = FrameDataPair.first;
- const FrameData *FD = FrameDataPair.second;
- ListScope S(W, "FunctionFrameData");
- W.printString("LinkageName", LinkageName);
- W.printHex("RvaStart", FD->RvaStart);
- W.printHex("CodeSize", FD->CodeSize);
- W.printHex("LocalSize", FD->LocalSize);
- W.printHex("ParamsSize", FD->ParamsSize);
- W.printHex("MaxStackSize", FD->MaxStackSize);
- W.printString("FrameFunc", StringRef(CVStringTable.data() + FD->FrameFunc));
- W.printHex("PrologSize", FD->PrologSize);
- W.printHex("SavedRegsSize", FD->SavedRegsSize);
- W.printFlags("Flags", FD->Flags, makeArrayRef(FrameDataFlags));
- }
}
static std::error_code decodeNumerictLeaf(StringRef &Data, APSInt &Num) {
@@ -1435,7 +1427,7 @@ void COFFDumper::printCodeViewSymbolsSub
W.printNumber("ChangeCodeLength", GetCompressedAnnotation());
break;
case ChangeFile:
- W.printHex("ChangeFile", GetCompressedAnnotation());
+ printFileNameForOffset("ChangeFile", GetCompressedAnnotation());
break;
case ChangeLineOffset:
W.printNumber("ChangeLineOffset",
@@ -1711,7 +1703,9 @@ void COFFDumper::printCodeViewSymbolsSub
if (opts::CodeViewSubsectionBytes)
printBinaryBlockWithRelocs("SymData", Section, SectionContents,
OrigSymData);
+ W.flush();
}
+ W.flush();
}
void COFFDumper::printCodeViewFileChecksums(StringRef Subsection) {
More information about the llvm-commits
mailing list