summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2015-02-12 21:09:24 +0000
committerZachary Turner <zturner@google.com>2015-02-12 21:09:24 +0000
commitc074de041b92af6a8279ea84a3675ab79579ec20 (patch)
tree6dba14e46c1e40f84304087e8ded45dfa6ac04f6 /llvm/lib/DebugInfo
parentcf7d164ec1c85e9f4d7a1508486342b67828e408 (diff)
downloadbcm5719-llvm-c074de041b92af6a8279ea84a3675ab79579ec20.tar.gz
bcm5719-llvm-c074de041b92af6a8279ea84a3675ab79579ec20.zip
Add concrete type overloads to PDBSymbol::findChildren().
Frequently you only want to iterate over children of a specific type (e.g. functions). Previously you would get back a generic interface that allowed iteration over the base symbol type, which you would have to dyn_cast<> each one of. With this patch, we allow the user to specify the concrete type as a template parameter, and it will return an iterator which returns instances of the concrete type directly. llvm-svn: 228960
Diffstat (limited to 'llvm/lib/DebugInfo')
-rw-r--r--llvm/lib/DebugInfo/PDB/PDBExtras.cpp2
-rw-r--r--llvm/lib/DebugInfo/PDB/PDBSymbol.cpp6
-rw-r--r--llvm/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp16
-rw-r--r--llvm/lib/DebugInfo/PDB/PDBSymbolData.cpp2
-rw-r--r--llvm/lib/DebugInfo/PDB/PDBSymbolFunc.cpp26
-rw-r--r--llvm/lib/DebugInfo/PDB/PDBSymbolThunk.cpp12
6 files changed, 29 insertions, 35 deletions
diff --git a/llvm/lib/DebugInfo/PDB/PDBExtras.cpp b/llvm/lib/DebugInfo/PDB/PDBExtras.cpp
index e7acebc0005..28870870de5 100644
--- a/llvm/lib/DebugInfo/PDB/PDBExtras.cpp
+++ b/llvm/lib/DebugInfo/PDB/PDBExtras.cpp
@@ -75,7 +75,7 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, const PDB_RegisterId &Reg) {
CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, R14, OS)
CASE_OUTPUT_ENUM_CLASS_NAME(PDB_RegisterId, R15, OS)
default:
- OS << "Unknown";
+ OS << static_cast<int>(Reg);
}
return OS;
}
diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp
index d65a153623a..4b6122b2858 100644
--- a/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp
+++ b/llvm/lib/DebugInfo/PDB/PDBSymbol.cpp
@@ -105,8 +105,8 @@ void PDBSymbol::defaultDump(raw_ostream &OS, int Indent,
PDB_SymType PDBSymbol::getSymTag() const { return RawSymbol->getSymTag(); }
-std::unique_ptr<IPDBEnumSymbols> PDBSymbol::findChildren(PDB_SymType Type) const {
- return RawSymbol->findChildren(Type);
+std::unique_ptr<IPDBEnumSymbols> PDBSymbol::findAllChildren() const {
+ return RawSymbol->findChildren(PDB_SymType::None);
}
std::unique_ptr<IPDBEnumSymbols>
@@ -128,7 +128,7 @@ PDBSymbol::findInlineFramesByRVA(uint32_t RVA) const {
std::unique_ptr<IPDBEnumSymbols>
PDBSymbol::getChildStats(TagStats &Stats) const {
- std::unique_ptr<IPDBEnumSymbols> Result(findChildren(PDB_SymType::None));
+ std::unique_ptr<IPDBEnumSymbols> Result(findAllChildren());
Stats.clear();
while (auto Child = Result->getNext()) {
++Stats[Child->getSymTag()];
diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp
index 13f6cccd0a2..39bb9bc90f1 100644
--- a/llvm/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp
+++ b/llvm/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp
@@ -19,6 +19,7 @@
#include "llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h"
#include "llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/Path.h"
using namespace llvm;
@@ -28,9 +29,11 @@ PDBSymbolCompiland::PDBSymbolCompiland(const IPDBSession &PDBSession,
void PDBSymbolCompiland::dump(raw_ostream &OS, int Indent,
PDB_DumpLevel Level) const {
- std::string Name = getName();
- OS << "---- [IDX: " << getSymIndexId() << "] Compiland: " << Name
- << " ----\n";
+ std::string FullName = getName();
+ StringRef Name = llvm::sys::path::filename(StringRef(FullName.c_str()));
+
+ OS.indent(Indent);
+ OS << "Compiland: " << Name << "\n";
std::string Source = getSourceFileName();
std::string Library = getLibraryName();
@@ -54,11 +57,8 @@ void PDBSymbolCompiland::dump(raw_ostream &OS, int Indent,
}
}
- std::unique_ptr<IPDBEnumSymbols> DetailsEnum(
- findChildren(PDB_SymType::CompilandDetails));
- if (auto DetailsPtr = DetailsEnum->getNext()) {
- const auto *CD = dyn_cast<PDBSymbolCompilandDetails>(DetailsPtr.get());
- assert(CD && "We only asked for compilands, but got something else!");
+ auto DetailsEnum(findAllChildren<PDBSymbolCompilandDetails>());
+ if (auto CD = DetailsEnum->getNext()) {
VersionInfo FE;
VersionInfo BE;
CD->getFrontEndVersion(FE);
diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolData.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolData.cpp
index f605af26771..bffad8af751 100644
--- a/llvm/lib/DebugInfo/PDB/PDBSymbolData.cpp
+++ b/llvm/lib/DebugInfo/PDB/PDBSymbolData.cpp
@@ -25,9 +25,11 @@ void PDBSymbolData::dump(raw_ostream &OS, int Indent,
if (Level == PDB_DumpLevel::Compact) {
PDB_LocType Loc = getLocationType();
OS << Loc << " data [";
+ int Length;
switch (Loc) {
case PDB_LocType::Static:
OS << format_hex(getRelativeVirtualAddress(), 10);
+ Length = getLength();
break;
case PDB_LocType::TLS:
OS << getAddressSection() << ":" << format_hex(getAddressOffset(), 10);
diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolFunc.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolFunc.cpp
index dfb684d1657..17473c17a45 100644
--- a/llvm/lib/DebugInfo/PDB/PDBSymbolFunc.cpp
+++ b/llvm/lib/DebugInfo/PDB/PDBSymbolFunc.cpp
@@ -27,35 +27,21 @@ void PDBSymbolFunc::dump(raw_ostream &OS, int Indent,
if (Level == PDB_DumpLevel::Compact) {
uint32_t FuncStart = getRelativeVirtualAddress();
uint32_t FuncEnd = FuncStart + getLength();
- auto DebugEndSymbol = findChildren(PDB_SymType::FuncDebugEnd);
OS << stream_indent(Indent);
OS << "[" << format_hex(FuncStart, 8);
- if (auto DebugStartEnum = findChildren(PDB_SymType::FuncDebugStart)) {
- if (auto StartSym = DebugStartEnum->getNext()) {
- auto DebugStart = dyn_cast<PDBSymbolFuncDebugStart>(StartSym.get());
- OS << "+" << DebugStart->getRelativeVirtualAddress() - FuncStart;
- }
- }
+ if (auto DebugStart = findOneChild<PDBSymbolFuncDebugStart>())
+ OS << "+" << DebugStart->getRelativeVirtualAddress() - FuncStart;
OS << " - " << format_hex(FuncEnd, 8);
- if (auto DebugEndEnum = findChildren(PDB_SymType::FuncDebugEnd)) {
- if (auto DebugEndSym = DebugEndEnum->getNext()) {
- auto DebugEnd = dyn_cast<PDBSymbolFuncDebugEnd>(DebugEndSym.get());
+ if (auto DebugEnd = findOneChild<PDBSymbolFuncDebugEnd>())
OS << "-" << FuncEnd - DebugEnd->getRelativeVirtualAddress();
- }
- }
OS << "] ";
PDB_RegisterId Reg = getLocalBasePointerRegisterId();
if (Reg == PDB_RegisterId::VFrame)
OS << "(VFrame)";
- else if (hasFramePointer()) {
- if (Reg == PDB_RegisterId::EBP)
- OS << "(EBP)";
- else
- OS << "(" << (int)Reg << ")";
- } else {
+ else if (hasFramePointer())
+ OS << "(" << Reg << ")";
+ else
OS << "(FPO)";
- }
OS << " " << getName() << "\n";
}
- OS.flush();
}
diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolThunk.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolThunk.cpp
index a7bd96a3479..eac1a544d33 100644
--- a/llvm/lib/DebugInfo/PDB/PDBSymbolThunk.cpp
+++ b/llvm/lib/DebugInfo/PDB/PDBSymbolThunk.cpp
@@ -25,11 +25,17 @@ void PDBSymbolThunk::dump(raw_ostream &OS, int Indent,
if (Level == PDB_DumpLevel::Compact) {
OS.indent(Indent);
PDB_ThunkOrdinal Ordinal = getThunkOrdinal();
- OS << "THUNK[" << Ordinal << "] ";
- OS << "[" << format_hex(getRelativeVirtualAddress(), 10);
+ uint32_t RVA = getRelativeVirtualAddress();
+ if (Ordinal == PDB_ThunkOrdinal::TrampIncremental) {
+ OS << format_hex(RVA, 10);
+ } else {
+ OS << "[" << format_hex(RVA, 10);
+ OS << " - " << format_hex(RVA + getLength(), 10) << "]";
+ }
+ OS << " thunk(" << Ordinal << ")";
if (Ordinal == PDB_ThunkOrdinal::TrampIncremental)
OS << " -> " << format_hex(getTargetRelativeVirtualAddress(), 10);
- OS << "] ";
+ OS << " ";
std::string Name = getName();
if (!Name.empty())
OS << Name;
OpenPOWER on IntegriCloud