diff options
author | Greg Clayton <gclayton@fb.com> | 2024-01-12 13:31:55 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-12 13:31:55 -0800 |
commit | 4618ef8cf5d8fa406c34ce2770c304cac95310b6 (patch) | |
tree | 208b0387ce0dc78ce1846049595b5bf60b88511d /llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp | |
parent | e27561fc7de0231f2efdb750f2092c3ac807c1a3 (diff) | |
download | llvm-4618ef8cf5d8fa406c34ce2770c304cac95310b6.zip llvm-4618ef8cf5d8fa406c34ce2770c304cac95310b6.tar.gz llvm-4618ef8cf5d8fa406c34ce2770c304cac95310b6.tar.bz2 |
Allow the dumping of .dwo files contents to show up when dumping an executable with split DWARF. (#66726)
Allow the dumping of .dwo files contents to show up when dumping an
executable with split DWARF.
Currently if you run llvm-dwarfdump on a binary that has skeleton
compile units, you only see the skeleton compile units. Since the main
binary has the linked addresses it would be nice to be able to dump
DWARF from the .dwo files and how the resolved addresses instead of
showing the address index and "<unresolved>" in the output. This patch
adds an option that can be specified to dump the non skeleton DIEs named
--dwo.
Added the ability to use the following options with split dwarf as well:
--name <name>
--lookup <addr>
--debug-info <die-offset>
Diffstat (limited to 'llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp')
-rw-r--r-- | llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp index 8180ad2..941df4e 100644 --- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -181,6 +181,13 @@ static opt<bool> FindAllApple( static opt<bool> IgnoreCase("ignore-case", desc("Ignore case distinctions when using --name."), value_desc("i"), cat(DwarfDumpCategory)); +static opt<bool> DumpNonSkeleton( + "dwo", + desc("Dump the non skeleton DIE in the .dwo or .dwp file after dumping the " + "skeleton DIE from the main executable. This allows dumping the .dwo " + "files with resolved addresses."), + value_desc("d"), cat(DwarfDumpCategory)); + static alias IgnoreCaseAlias("i", desc("Alias for --ignore-case."), aliasopt(IgnoreCase), cl::NotHidden); static list<std::string> Name( @@ -315,6 +322,7 @@ static DIDumpOptions getDumpOpts(DWARFContext &C) { DumpOpts.ShowForm = ShowForm; DumpOpts.SummarizeTypes = SummarizeTypes; DumpOpts.Verbose = Verbose; + DumpOpts.DumpNonSkeleton = DumpNonSkeleton; DumpOpts.RecoverableErrorHandler = C.getRecoverableErrorHandler(); // In -verify mode, print DIEs without children in error messages. if (Verify) { @@ -390,15 +398,27 @@ static void filterByName( const StringSet<> &Names, DWARFContext::unit_iterator_range CUs, raw_ostream &OS, std::function<StringRef(uint64_t RegNum, bool IsEH)> GetNameForDWARFReg) { - for (const auto &CU : CUs) - for (const auto &Entry : CU->dies()) { - DWARFDie Die = {CU.get(), &Entry}; + auto filterDieNames = [&](DWARFUnit *Unit) { + for (const auto &Entry : Unit->dies()) { + DWARFDie Die = {Unit, &Entry}; if (const char *Name = Die.getName(DINameKind::ShortName)) if (filterByName(Names, Die, Name, OS, GetNameForDWARFReg)) continue; if (const char *Name = Die.getName(DINameKind::LinkageName)) filterByName(Names, Die, Name, OS, GetNameForDWARFReg); } + }; + for (const auto &CU : CUs) { + filterDieNames(CU.get()); + if (DumpNonSkeleton) { + // If we have split DWARF, then recurse down into the .dwo files as well. + DWARFDie CUDie = CU->getUnitDIE(false); + DWARFDie CUNonSkeletonDie = CU->getNonSkeletonUnitDIE(false); + // If we have a DWO file, we need to search it as well + if (CUNonSkeletonDie && CUDie != CUNonSkeletonDie) + filterDieNames(CUNonSkeletonDie.getDwarfUnit()); + } + } } static void getDies(DWARFContext &DICtx, const AppleAcceleratorTable &Accel, @@ -499,7 +519,7 @@ static void findAllApple( /// information or probably display all matched entries, or something else... static bool lookup(ObjectFile &Obj, DWARFContext &DICtx, uint64_t Address, raw_ostream &OS) { - auto DIEsForAddr = DICtx.getDIEsForAddress(Lookup); + auto DIEsForAddr = DICtx.getDIEsForAddress(Lookup, DumpNonSkeleton); if (!DIEsForAddr) return false; |