diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2024-01-24 19:17:23 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2024-04-19 21:24:44 +0000 |
commit | ab50317e96e57dee5b3ff4ad3f16f205b2a3359e (patch) | |
tree | 4b1f388eb6a07e574417aaacecd3ec4a83550718 /contrib/llvm-project/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp | |
parent | 412542983a5ba62902141a8a7e155cceb9196a66 (diff) |
Diffstat (limited to 'contrib/llvm-project/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/contrib/llvm-project/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/contrib/llvm-project/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp index 8180ad2138f4..941df4eb1844 100644 --- a/contrib/llvm-project/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ b/contrib/llvm-project/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; |