aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools
diff options
context:
space:
mode:
authorShubham Sandeep Rastogi <srastogi22@apple.com>2022-12-14 18:31:11 -0800
committerShubham Sandeep Rastogi <srastogi22@apple.com>2022-12-14 18:32:18 -0800
commit4283cfdc1116725d951660a01104cf4cd98e8453 (patch)
tree9dfec75d8a755c69290bf5069a4108811438d13c /llvm/tools
parent10041de960622091ce9d0fdd7013a35c1a4ea196 (diff)
downloadllvm-4283cfdc1116725d951660a01104cf4cd98e8453.zip
llvm-4283cfdc1116725d951660a01104cf4cd98e8453.tar.gz
llvm-4283cfdc1116725d951660a01104cf4cd98e8453.tar.bz2
Revert "Remove the dependency between lib/DebugInfoDWARF and MC."
This reverts commit 7dde94251e1c9e4634f5d51d41f2d4a191258fb3. Because of test failures: lldb-shell :: SymbolFile/DWARF/x86/DW_AT_loclists_base.s lldb-shell :: SymbolFile/DWARF/x86/debug_loc.s lldb-shell :: SymbolFile/DWARF/x86/debug_loc_and_loclists.s lldb-shell :: SymbolFile/DWARF/x86/debug_loclists-dwo.s lldb-shell :: SymbolFile/DWARF/x86/debug_loclists-dwp.s lldb-shell :: SymbolFile/DWARF/x86/dwp.s lldb-shell :: SymbolFile/DWARF/x86/unused-inlined-params.test lldb-shell :: SymbolFile/NativePDB/inline_sites.test lldb-shell :: SymbolFile/NativePDB/local-variables-registers.s lldb-shell :: SymbolFile/NativePDB/nested-blocks-same-address.s
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp70
-rw-r--r--llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp1
-rw-r--r--llvm/tools/llvm-objdump/SourcePrinter.cpp12
-rw-r--r--llvm/tools/llvm-objdump/SourcePrinter.h1
-rw-r--r--llvm/tools/llvm-readobj/DwarfCFIEHPrinter.h5
5 files changed, 19 insertions, 70 deletions
diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
index c151129..59e7361 100644
--- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
+++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
@@ -18,8 +18,6 @@
#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
#include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
-#include "llvm/MC/MCRegisterInfo.h"
-#include "llvm/MC/TargetRegistry.h"
#include "llvm/Object/Archive.h"
#include "llvm/Object/MachOUniversal.h"
#include "llvm/Object/ObjectFile.h"
@@ -342,11 +340,9 @@ using HandlerFn = std::function<bool(ObjectFile &, DWARFContext &DICtx,
const Twine &, raw_ostream &)>;
/// Print only DIEs that have a certain name.
-static bool filterByName(
- const StringSet<> &Names, DWARFDie Die, StringRef NameRef, raw_ostream &OS,
- std::function<StringRef(uint64_t RegNum, bool IsEH)> GetNameForDWARFReg) {
+static bool filterByName(const StringSet<> &Names, DWARFDie Die,
+ StringRef NameRef, raw_ostream &OS) {
DIDumpOptions DumpOpts = getDumpOpts(Die.getDwarfUnit()->getContext());
- DumpOpts.GetNameForDWARFReg = GetNameForDWARFReg;
std::string Name =
(IgnoreCase && !UseRegex) ? NameRef.lower() : NameRef.str();
if (UseRegex) {
@@ -372,18 +368,17 @@ static bool filterByName(
}
/// Print only DIEs that have a certain name.
-static void filterByName(
- const StringSet<> &Names, DWARFContext::unit_iterator_range CUs,
- raw_ostream &OS,
- std::function<StringRef(uint64_t RegNum, bool IsEH)> GetNameForDWARFReg) {
+static void filterByName(const StringSet<> &Names,
+ DWARFContext::unit_iterator_range CUs,
+ raw_ostream &OS) {
for (const auto &CU : CUs)
for (const auto &Entry : CU->dies()) {
DWARFDie Die = {CU.get(), &Entry};
if (const char *Name = Die.getName(DINameKind::ShortName))
- if (filterByName(Names, Die, Name, OS, GetNameForDWARFReg))
+ if (filterByName(Names, Die, Name, OS))
continue;
if (const char *Name = Die.getName(DINameKind::LinkageName))
- filterByName(Names, Die, Name, OS, GetNameForDWARFReg);
+ filterByName(Names, Die, Name, OS);
}
}
@@ -427,9 +422,8 @@ static void getDies(DWARFContext &DICtx, const DWARFDebugNames &Accel,
}
/// Print only DIEs that have a certain name.
-static void filterByAccelName(
- ArrayRef<std::string> Names, DWARFContext &DICtx, raw_ostream &OS,
- std::function<StringRef(uint64_t RegNum, bool IsEH)> GetNameForDWARFReg) {
+static void filterByAccelName(ArrayRef<std::string> Names, DWARFContext &DICtx,
+ raw_ostream &OS) {
SmallVector<DWARFDie, 4> Dies;
for (const auto &Name : Names) {
getDies(DICtx, DICtx.getAppleNames(), Name, Dies);
@@ -441,7 +435,6 @@ static void filterByAccelName(
Dies.erase(std::unique(Dies.begin(), Dies.end()), Dies.end());
DIDumpOptions DumpOpts = getDumpOpts(DICtx);
- DumpOpts.GetNameForDWARFReg = GetNameForDWARFReg;
for (DWARFDie Die : Dies)
Die.dump(OS, 0, DumpOpts);
}
@@ -558,41 +551,10 @@ static bool collectObjectSources(ObjectFile &Obj, DWARFContext &DICtx,
return Result;
}
-static std::unique_ptr<MCRegisterInfo>
-createRegInfo(const object::ObjectFile &Obj) {
- std::unique_ptr<MCRegisterInfo> MCRegInfo;
- Triple TT;
- TT.setArch(Triple::ArchType(Obj.getArch()));
- TT.setVendor(Triple::UnknownVendor);
- TT.setOS(Triple::UnknownOS);
- std::string TargetLookupError;
- const Target *TheTarget =
- TargetRegistry::lookupTarget(TT.str(), TargetLookupError);
- if (!TargetLookupError.empty())
- return nullptr;
- MCRegInfo.reset(TheTarget->createMCRegInfo(TT.str()));
- return MCRegInfo;
-}
-
static bool dumpObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
const Twine &Filename, raw_ostream &OS) {
-
- auto MCRegInfo = createRegInfo(Obj);
- if (!MCRegInfo)
- logAllUnhandledErrors(createStringError(inconvertibleErrorCode(),
- "Error in creating MCRegInfo"),
- errs(), Filename.str() + ": ");
-
- auto GetRegName = [&MCRegInfo](uint64_t DwarfRegNum, bool IsEH) -> StringRef {
- if (!MCRegInfo)
- return {};
- if (std::optional<unsigned> LLVMRegNum =
- MCRegInfo->getLLVMRegNum(DwarfRegNum, IsEH))
- if (const char *RegName = MCRegInfo->getName(*LLVMRegNum))
- return StringRef(RegName);
- return {};
- };
-
+ logAllUnhandledErrors(DICtx.loadRegisterInfo(Obj), errs(),
+ Filename.str() + ": ");
// The UUID dump already contains all the same information.
if (!(DumpType & DIDT_UUID) || DumpType == DIDT_All)
OS << Filename << ":\tfile format " << Obj.getFileFormatName() << '\n';
@@ -607,21 +569,19 @@ static bool dumpObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
for (auto name : Name)
Names.insert((IgnoreCase && !UseRegex) ? StringRef(name).lower() : name);
- filterByName(Names, DICtx.normal_units(), OS, GetRegName);
- filterByName(Names, DICtx.dwo_units(), OS, GetRegName);
+ filterByName(Names, DICtx.normal_units(), OS);
+ filterByName(Names, DICtx.dwo_units(), OS);
return true;
}
// Handle the --find option and lower it to --debug-info=<offset>.
if (!Find.empty()) {
- filterByAccelName(Find, DICtx, OS, GetRegName);
+ filterByAccelName(Find, DICtx, OS);
return true;
}
// Dump the complete DWARF structure.
- auto DumpOpts = getDumpOpts(DICtx);
- DumpOpts.GetNameForDWARFReg = GetRegName;
- DICtx.dump(OS, DumpOpts, DumpOffsets);
+ DICtx.dump(OS, getDumpOpts(DICtx), DumpOffsets);
return true;
}
diff --git a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
index 943c056..ac16ae8 100644
--- a/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
+++ b/llvm/tools/llvm-gsymutil/llvm-gsymutil.cpp
@@ -286,6 +286,7 @@ static llvm::Error handleObjectFile(ObjectFile &Obj,
if (!DICtx)
return createStringError(std::errc::invalid_argument,
"unable to create DWARF context");
+ logAllUnhandledErrors(DICtx->loadRegisterInfo(Obj), OS, "DwarfTransformer: ");
// Make a DWARF transformer object and populate the ranges of the code
// so we don't end up adding invalid functions to GSYM data.
diff --git a/llvm/tools/llvm-objdump/SourcePrinter.cpp b/llvm/tools/llvm-objdump/SourcePrinter.cpp
index 6736cbc..d0b80fd 100644
--- a/llvm/tools/llvm-objdump/SourcePrinter.cpp
+++ b/llvm/tools/llvm-objdump/SourcePrinter.cpp
@@ -42,17 +42,7 @@ void LiveVariable::print(raw_ostream &OS, const MCRegisterInfo &MRI) const {
DataExtractor Data({LocExpr.Expr.data(), LocExpr.Expr.size()},
Unit->getContext().isLittleEndian(), 0);
DWARFExpression Expression(Data, Unit->getAddressByteSize());
-
- auto GetRegName = [&MRI, &OS](uint64_t DwarfRegNum, bool IsEH) -> StringRef {
- if (std::optional<unsigned> LLVMRegNum =
- MRI.getLLVMRegNum(DwarfRegNum, IsEH))
- if (const char *RegName = MRI.getName(*LLVMRegNum))
- return StringRef(RegName);
- OS << "<unknown register " << DwarfRegNum << ">";
- return {};
- };
-
- Expression.printCompact(OS, GetRegName);
+ Expression.printCompact(OS, MRI);
}
void LiveVariablePrinter::addVariable(DWARFDie FuncDie, DWARFDie VarDie) {
diff --git a/llvm/tools/llvm-objdump/SourcePrinter.h b/llvm/tools/llvm-objdump/SourcePrinter.h
index 6209bb0..29ef19c 100644
--- a/llvm/tools/llvm-objdump/SourcePrinter.h
+++ b/llvm/tools/llvm-objdump/SourcePrinter.h
@@ -13,7 +13,6 @@
#include "llvm/ADT/StringSet.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/DebugInfo/Symbolize/Symbolize.h"
-#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/Support/FormattedStream.h"
#include <unordered_map>
diff --git a/llvm/tools/llvm-readobj/DwarfCFIEHPrinter.h b/llvm/tools/llvm-readobj/DwarfCFIEHPrinter.h
index 365a598..5dc947e 100644
--- a/llvm/tools/llvm-readobj/DwarfCFIEHPrinter.h
+++ b/llvm/tools/llvm-readobj/DwarfCFIEHPrinter.h
@@ -226,9 +226,8 @@ void PrinterContext<ELFT>::printEHFrame(const Elf_Shdr *EHFrameShdr) const {
W.getOStream() << "\n";
W.startLine() << "Program:\n";
W.indent();
- auto DumpOpts = DIDumpOptions();
- DumpOpts.IsEH = true;
- Entry.cfis().dump(W.getOStream(), DumpOpts, W.getIndentLevel());
+ Entry.cfis().dump(W.getOStream(), DIDumpOptions(), nullptr,
+ W.getIndentLevel());
W.unindent();
W.unindent();
W.getOStream() << "\n";