Skip to content

Commit

Permalink
[llvm-pdbutil] Add support for dumping lines and inlinee lines.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305529 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Zachary Turner committed Jun 15, 2017
1 parent ae75a98 commit 7b1eb00
Show file tree
Hide file tree
Showing 12 changed files with 308 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace llvm {
namespace codeview {

class DebugInlineeLinesSubsectionsRef;
class DebugInlineeLinesSubsectionRef;
class DebugChecksumsSubsection;

enum class InlineeLinesSignature : uint32_t {
Expand Down
2 changes: 2 additions & 0 deletions include/llvm/DebugInfo/CodeView/StringsAndChecksums.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class StringsAndChecksumsRef {
StringsAndChecksumsRef(const DebugStringTableSubsectionRef &Strings,
const DebugChecksumsSubsectionRef &Checksums);

void setChecksums(const DebugChecksumsSubsectionRef &CS);

template <typename T> void initialize(T &&FragmentRange) {
for (const DebugSubsectionRecord &R : FragmentRange) {
if (Strings && Checksums)
Expand Down
6 changes: 4 additions & 2 deletions include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ModuleDebugStreamRef {
public:
ModuleDebugStreamRef(const DbiModuleDescriptor &Module,
std::unique_ptr<msf::MappedBlockStream> Stream);
ModuleDebugStreamRef(ModuleDebugStreamRef &&Other);
ModuleDebugStreamRef(ModuleDebugStreamRef &&Other) = default;
~ModuleDebugStreamRef();

Error reload();
Expand All @@ -45,6 +45,8 @@ class ModuleDebugStreamRef {
return SymbolsSubstream;
}

ModuleDebugStreamRef &operator=(ModuleDebugStreamRef &&Other) = default;

llvm::iterator_range<DebugSubsectionIterator> subsections() const;

bool hasDebugSubsections() const;
Expand All @@ -59,7 +61,7 @@ class ModuleDebugStreamRef {

uint32_t Signature;

std::unique_ptr<msf::MappedBlockStream> Stream;
std::shared_ptr<msf::MappedBlockStream> Stream;

codeview::CVSymbolArray SymbolsSubstream;
BinaryStreamRef C11LinesSubstream;
Expand Down
2 changes: 2 additions & 0 deletions include/llvm/DebugInfo/PDB/Native/PDBFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ class PDBFile : public msf::IMSFFile {
bool hasPDBTpiStream() const;
bool hasPDBStringTable();

uint32_t getPointerSize();

private:
Expected<std::unique_ptr<msf::MappedBlockStream>>
safelyCreateIndexedStream(const msf::MSFLayout &Layout,
Expand Down
7 changes: 7 additions & 0 deletions lib/DebugInfo/CodeView/StringsAndChecksums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ void StringsAndChecksumsRef::initializeStrings(
Strings = OwnedStrings.get();
}

void StringsAndChecksumsRef::setChecksums(
const DebugChecksumsSubsectionRef &CS) {
OwnedChecksums = llvm::make_unique<DebugChecksumsSubsectionRef>();
*OwnedChecksums = CS;
Checksums = OwnedChecksums.get();
}

void StringsAndChecksumsRef::initializeChecksums(
const DebugSubsectionRecord &FCR) {
assert(FCR.kind() == DebugSubsectionKind::FileChecksums);
Expand Down
9 changes: 0 additions & 9 deletions lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ ModuleDebugStreamRef::ModuleDebugStreamRef(
std::unique_ptr<MappedBlockStream> Stream)
: Mod(Module), Stream(std::move(Stream)) {}

ModuleDebugStreamRef::ModuleDebugStreamRef(ModuleDebugStreamRef &&Other)
: Mod(Other.Mod), Signature(Other.Signature),
Stream(std::move(Other.Stream)),
SymbolsSubstream(std::move(Other.SymbolsSubstream)),
C11LinesSubstream(std::move(Other.C11LinesSubstream)),
C13LinesSubstream(std::move(Other.C13LinesSubstream)),
GlobalRefsSubstream(std::move(Other.GlobalRefsSubstream)),
Subsections(std::move(Other.Subsections)) {}

ModuleDebugStreamRef::~ModuleDebugStreamRef() = default;

Error ModuleDebugStreamRef::reload() {
Expand Down
10 changes: 10 additions & 0 deletions lib/DebugInfo/PDB/Native/PDBFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,16 @@ Expected<PDBStringTable &> PDBFile::getStringTable() {
return *Strings;
}

uint32_t PDBFile::getPointerSize() {
auto DbiS = getPDBDbiStream();
if (!DbiS)
return 0;
PDB_Machine Machine = DbiS->getMachineType();
if (Machine == PDB_Machine::Amd64)
return 8;
return 4;
}

bool PDBFile::hasPDBDbiStream() const { return StreamDBI < getNumStreams(); }

bool PDBFile::hasPDBGlobalsStream() {
Expand Down
11 changes: 11 additions & 0 deletions test/DebugInfo/PDB/pdbdump-headers.test
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ ALL-NEXT: ============================================================
ALL-NEXT: Mod 0000 | `d:\src\llvm\test\DebugInfo\PDB\Inputs\empty.obj`:
ALL-NEXT: - (MD5: A0A5BD0D3ECD93FC29D19DE826FBF4BC) d:\src\llvm\test\debuginfo\pdb\inputs\empty.cpp
ALL-NEXT: Mod 0001 | `* Linker *`:
ALL: Lines
ALL-NEXT: ============================================================
ALL-NEXT: Mod 0000 | `d:\src\llvm\test\DebugInfo\PDB\Inputs\empty.obj`:
ALL-NEXT: d:\src\llvm\test\debuginfo\pdb\inputs\empty.cpp (MD5: A0A5BD0D3ECD93FC29D19DE826FBF4BC)
ALL-NEXT: 0001:00000010-0000001A, line/addr entries = 3
ALL-NEXT: 5 00000010 6 00000013 7 00000018
ALL: Mod 0001 | `* Linker *`:
ALL: Inlinee Lines
ALL-NEXT: ============================================================
ALL-NEXT: Mod 0000 | `d:\src\llvm\test\DebugInfo\PDB\Inputs\empty.obj`:
ALL-NEXT: Mod 0001 | `* Linker *`:
ALL: Types (TPI Stream)
ALL-NEXT: ============================================================
ALL-NEXT: Showing 75 records
Expand Down
Loading

0 comments on commit 7b1eb00

Please sign in to comment.