diff options
author | David Blaikie <dblaikie@gmail.com> | 2020-04-14 14:21:33 -0700 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2020-04-14 14:44:32 -0700 |
commit | 208a11ab3a7be7c3e5d3fae9dd4affdb01a0ed1f (patch) | |
tree | 0c6a17b3d6c381afe9d7542de561826b72f15d67 /llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp | |
parent | 37b520763fd9a51c94c446108907f48d04b7cab1 (diff) | |
download | llvm-208a11ab3a7be7c3e5d3fae9dd4affdb01a0ed1f.zip llvm-208a11ab3a7be7c3e5d3fae9dd4affdb01a0ed1f.tar.gz llvm-208a11ab3a7be7c3e5d3fae9dd4affdb01a0ed1f.tar.bz2 |
Reapply "llvm-dwarfdump: Report errors when failing to parse loclist/debug_loc entries""
Originally committed as 416fa7720e30750939c53935051c6c750dfad2c2
Reverted (due to buildbot failure - breaking lldb) in 7a45aeacf3a23449039ef2efcf476995ae1c7007.
I still can't seem to build lldb locally, but Pavel Labath has kindly
provided a potential fix to preserve the old behavior in lldb by
registering a simple recoverable error handler there that prints to the
desired stream in lldb, rather than stderr.
Diffstat (limited to 'llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp')
-rw-r--r-- | llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp index 14115c8..31de753 100644 --- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -243,7 +243,7 @@ static void error(StringRef Prefix, std::error_code EC) { exit(1); } -static DIDumpOptions getDumpOpts() { +static DIDumpOptions getDumpOpts(DWARFContext& C) { DIDumpOptions DumpOpts; DumpOpts.DumpType = DumpType; DumpOpts.ChildRecurseDepth = ChildRecurseDepth; @@ -254,6 +254,7 @@ static DIDumpOptions getDumpOpts() { DumpOpts.ShowForm = ShowForm; DumpOpts.SummarizeTypes = SummarizeTypes; DumpOpts.Verbose = Verbose; + DumpOpts.RecoverableErrorHandler = C.getRecoverableErrorHandler(); // In -verify mode, print DIEs without children in error messages. if (Verify) return DumpOpts.noImplicitRecursion(); @@ -294,6 +295,7 @@ using HandlerFn = std::function<bool(ObjectFile &, DWARFContext &DICtx, /// Print only DIEs that have a certain name. static bool filterByName(const StringSet<> &Names, DWARFDie Die, StringRef NameRef, raw_ostream &OS) { + DIDumpOptions DumpOpts = getDumpOpts(Die.getDwarfUnit()->getContext()); std::string Name = (IgnoreCase && !UseRegex) ? NameRef.lower() : NameRef.str(); if (UseRegex) { @@ -306,13 +308,13 @@ static bool filterByName(const StringSet<> &Names, DWARFDie Die, exit(1); } if (RE.match(Name)) { - Die.dump(OS, 0, getDumpOpts()); + Die.dump(OS, 0, DumpOpts); return true; } } } else if (Names.count(Name)) { // Match full text. - Die.dump(OS, 0, getDumpOpts()); + Die.dump(OS, 0, DumpOpts); return true; } return false; @@ -385,8 +387,9 @@ static void filterByAccelName(ArrayRef<std::string> Names, DWARFContext &DICtx, llvm::sort(Dies); Dies.erase(std::unique(Dies.begin(), Dies.end()), Dies.end()); + DIDumpOptions DumpOpts = getDumpOpts(DICtx); for (DWARFDie Die : Dies) - Die.dump(OS, 0, getDumpOpts()); + Die.dump(OS, 0, DumpOpts); } /// Handle the --lookup option and dump the DIEs and line info for the given @@ -402,7 +405,7 @@ static bool lookup(ObjectFile &Obj, DWARFContext &DICtx, uint64_t Address, if (!DIEsForAddr) return false; - DIDumpOptions DumpOpts = getDumpOpts(); + DIDumpOptions DumpOpts = getDumpOpts(DICtx); DumpOpts.ChildRecurseDepth = 0; DIEsForAddr.CompileUnit->dump(OS, DumpOpts); if (DIEsForAddr.FunctionDIE) { @@ -450,7 +453,7 @@ static bool dumpObjectFile(ObjectFile &Obj, DWARFContext &DICtx, } // Dump the complete DWARF structure. - DICtx.dump(OS, getDumpOpts(), DumpOffsets); + DICtx.dump(OS, getDumpOpts(DICtx), DumpOffsets); return true; } @@ -461,7 +464,7 @@ static bool verifyObjectFile(ObjectFile &Obj, DWARFContext &DICtx, raw_ostream &stream = Quiet ? nulls() : OS; stream << "Verifying " << Filename.str() << ":\tfile format " << Obj.getFileFormatName() << "\n"; - bool Result = DICtx.verify(stream, getDumpOpts()); + bool Result = DICtx.verify(stream, getDumpOpts(DICtx)); if (Result) stream << "No errors.\n"; else |