[Symbolize] Check if the PE file has a PDB and emit an error if we can't load it

Summary:
Previously we would try to load PDBs for every PE executable we tried to
symbolize. If that failed, we would fall back to DWARF. If there wasn't
any DWARF, we'd print mostly useless symbol information using the export
table.

With this change, we only try to load PDBs for executables that claim to
have them. If that fails, we can now print an error rather than falling
back silently. This should make it a lot easier to diagnose and fix
common symbolization issues, such as not having DIA or not having a PDB.

Reviewers: zturner, eugenis

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D20982

llvm-svn: 271725
This commit is contained in:
Reid Kleckner
2016-06-03 20:25:09 +00:00
parent 9faa5bcf13
commit f27f3f8491
9 changed files with 161 additions and 86 deletions

View File

@@ -86,10 +86,12 @@ static cl::opt<int> ClPrintSourceContextLines(
"print-source-context-lines", cl::init(0),
cl::desc("Print N number of source file context"));
static bool error(std::error_code ec) {
if (!ec)
template<typename T>
static bool error(Expected<T> &ResOrErr) {
if (ResOrErr)
return false;
errs() << "LLVMSymbolizer: error reading file: " << ec.message() << ".\n";
logAllUnhandledErrors(ResOrErr.takeError(), errs(),
"LLVMSymbolizer: error reading file: ");
return true;
}
@@ -185,14 +187,14 @@ int main(int argc, char **argv) {
}
if (IsData) {
auto ResOrErr = Symbolizer.symbolizeData(ModuleName, ModuleOffset);
Printer << (error(ResOrErr.getError()) ? DIGlobal() : ResOrErr.get());
Printer << (error(ResOrErr) ? DIGlobal() : ResOrErr.get());
} else if (ClPrintInlining) {
auto ResOrErr = Symbolizer.symbolizeInlinedCode(ModuleName, ModuleOffset);
Printer << (error(ResOrErr.getError()) ? DIInliningInfo()
Printer << (error(ResOrErr) ? DIInliningInfo()
: ResOrErr.get());
} else {
auto ResOrErr = Symbolizer.symbolizeCode(ModuleName, ModuleOffset);
Printer << (error(ResOrErr.getError()) ? DILineInfo() : ResOrErr.get());
Printer << (error(ResOrErr) ? DILineInfo() : ResOrErr.get());
}
outs() << "\n";
outs().flush();