Skip to content

Commit dd3c72b

Browse files
committed
Added new tool, and test code
1 parent c6bacae commit dd3c72b

File tree

9 files changed

+511
-4
lines changed

9 files changed

+511
-4
lines changed

llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class DWARFFormValue {
8383

8484
LLVM_ABI bool isFormClass(FormClass FC) const;
8585
const DWARFUnit *getUnit() const { return U; }
86+
LLVM_DUMP_METHOD void dump() const;
8687
LLVM_ABI void dump(raw_ostream &OS,
8788
DIDumpOptions DumpOpts = DIDumpOptions()) const;
8889
LLVM_ABI void dumpSectionedAddress(raw_ostream &OS, DIDumpOptions DumpOpts,

llvm/include/llvm/DebugInfo/LogicalView/Core/LVLocation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ class LLVM_ABI LVLocation : public LVObject {
159159

160160
void print(raw_ostream &OS, bool Full = true) const override;
161161
void printExtra(raw_ostream &OS, bool Full = true) const override;
162+
virtual void printLocations(raw_ostream &OS) const {}
162163
};
163164

164165
class LLVM_ABI LVLocationSymbol final : public LVLocation {
@@ -179,6 +180,7 @@ class LLVM_ABI LVLocationSymbol final : public LVLocation {
179180

180181
void printRawExtra(raw_ostream &OS, bool Full = true) const override;
181182
void printExtra(raw_ostream &OS, bool Full = true) const override;
183+
void printLocations(raw_ostream &OS) const override;
182184
};
183185

184186
} // end namespace logicalview

llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,8 @@ void DWARFFormValue::dumpAddressSection(const DWARFObject &Obj, raw_ostream &OS,
379379
OS << format(" [%" PRIu64 "]", SectionIndex);
380380
}
381381

382+
LLVM_DUMP_METHOD void DWARFFormValue::dump() const { dump(dbgs()); }
383+
382384
void DWARFFormValue::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
383385
uint64_t UValue = Value.uval;
384386
bool CURelativeOffset = false;

llvm/lib/DebugInfo/LogicalView/Core/LVLocation.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,19 @@ void LVLocation::print(LVLocations *Locations, raw_ostream &OS, bool Full) {
648648
Location->print(OS, Full);
649649
}
650650

651+
void LVLocationSymbol::printLocations(raw_ostream &OS) const {
652+
if (Entries) {
653+
bool CodeViewLocation = getParentSymbol()->getHasCodeViewLocation();
654+
std::string Leading;
655+
for (LVOperation *Operation : *Entries) {
656+
OS << Leading
657+
<< (CodeViewLocation ? Operation->getOperandsCodeViewInfo()
658+
: Operation->getOperandsDWARFInfo());
659+
Leading = ", ";
660+
}
661+
}
662+
}
663+
651664
void LVLocationSymbol::printExtra(raw_ostream &OS, bool Full) const {
652665
OS << "{Location}";
653666
if (getIsCallSite())
@@ -657,15 +670,19 @@ void LVLocationSymbol::printExtra(raw_ostream &OS, bool Full) const {
657670

658671
// Print location entries.
659672
if (Full && Entries) {
673+
std::string Str;
674+
raw_string_ostream Stream(Str);
675+
printLocations(Stream);
676+
#if 0
660677
bool CodeViewLocation = getParentSymbol()->getHasCodeViewLocation();
661-
std::stringstream Stream;
662678
std::string Leading;
663679
for (LVOperation *Operation : *Entries) {
664680
Stream << Leading
665681
<< (CodeViewLocation ? Operation->getOperandsCodeViewInfo()
666682
: Operation->getOperandsDWARFInfo());
667683
Leading = ", ";
668684
}
685+
#endif
669686
printAttributes(OS, Full, "{Entry} ", const_cast<LVLocationSymbol *>(this),
670687
StringRef(Stream.str()),
671688
/*UseQuotes=*/false,

llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ void LVScope::addElement(LVLine *Line) {
134134
if (!Lines)
135135
Lines = std::make_unique<LVLines>();
136136

137+
if (Line->getAddress() == 0x2fc)
138+
outs() << "Set Parent for line at addr: " << Line->getAddress()
139+
<< "\n ";
137140
// Add it to parent.
138141
Lines->push_back(Line);
139142
Line->setParent(this);

llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,9 @@ void LVBinaryReader::processLines(LVLines *DebugLines,
733733
for (LVLine *Line : *DebugLines) {
734734
// Using the current line address, get its associated lexical scope and
735735
// add the line information to it.
736+
737+
if (Line->getAddress() == 0x2fc)
738+
outs() << "";
736739
Scope = ScopesWithRanges->getEntry(Line->getAddress());
737740
if (!Scope) {
738741
// If missing scope, use the compile unit.

llvm/lib/DebugInfo/LogicalView/Readers/LVDWARFReader.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
252252

253253
case dwarf::DW_AT_ranges:
254254
if (RangesDataAvailable && options().getGeneralCollectRanges()) {
255+
if (CurrentScope->getID() == 2237)
256+
outs() << "";
255257
auto GetRanges = [](const DWARFFormValue &FormValue,
256258
DWARFUnit *U) -> Expected<DWARFAddressRangesVector> {
257259
if (FormValue.getForm() == dwarf::DW_FORM_rnglistx)
@@ -274,7 +276,7 @@ void LVDWARFReader::processOneAttribute(const DWARFDie &Die,
274276
for (DWARFAddressRange &Range : Ranges) {
275277
// This seems to be a tombstone for empty ranges.
276278
if ((Range.LowPC == Range.HighPC) ||
277-
(Range.LowPC = getTombstoneAddress()))
279+
(Range.LowPC == getTombstoneAddress()))
278280
continue;
279281
// Store the real upper limit for the address range.
280282
if (UpdateHighAddress && Range.HighPC > 0)
@@ -461,13 +463,16 @@ LVScope *LVDWARFReader::processOneDie(const DWARFDie &InputDIE, LVScope *Parent,
461463
if (!CurrentRanges.empty()) {
462464
for (LVAddressRange &Range : CurrentRanges)
463465
addSectionRange(SectionIndex, CurrentScope, Range.first,
464-
Range.second);
466+
Range.second > Range.first ? Range.second - 1
467+
: Range.second);
465468
CurrentRanges.clear();
466469
}
467470
// If the scope is the CU, do not update the ranges set.
468471
if (FoundLowPC && FoundHighPC && !IsCompileUnit) {
469472
addSectionRange(SectionIndex, CurrentScope, CurrentLowPC,
470-
CurrentHighPC);
473+
CurrentHighPC > CurrentLowPC
474+
? CurrentHighPC - 1
475+
: CurrentHighPC); // Make hi-pc exclusive
471476
}
472477
}
473478
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
set(LLVM_LINK_COMPONENTS
2+
AllTargetsDescs
3+
AllTargetsDisassemblers
4+
AllTargetsInfos
5+
BinaryFormat
6+
DebugInfoCodeView
7+
DebugInfoLogicalView
8+
DebugInfoPDB
9+
MC
10+
MCDisassembler
11+
Object
12+
Support
13+
)
14+
15+
add_llvm_tool(llvm-debuginfo-check
16+
llvm-debuginfo-check.cpp
17+
)

0 commit comments

Comments
 (0)