LLVM: lib/ExecutionEngine/Orc/Debugging/DebugInfoSupport.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
14
16
17#define DEBUG_TYPE "orc"
18
19using namespace llvm;
22
23namespace {
25#define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME, OPTION) \
26 StringRef(ELF_NAME),
27#include "llvm/BinaryFormat/Dwarf.def"
28#undef HANDLE_DWARF_SECTION
29};
30
31
32
35 for (auto Sym : Sec.symbols()) {
36 auto [It, Inserted] = Preserved.try_emplace(&Sym->getBlock());
37 if (Inserted || Sym->isLive())
38 It->second = Sym;
39 }
41 auto &PSym = Preserved[Block];
42 if (!PSym)
43 PSym = &G.addAnonymousSymbol(*Block, 0, 0, false, true);
44 else if (!PSym->isLive())
45 PSym->setLive(true);
46 }
47}
48
53 return LHS->getAddress() < RHS->getAddress();
54 });
55
56
57
58
59 for (auto *Block : SecBlocks) {
61 SecData.resize(SecData.size() + Block->getSize(), 0);
62 else
64 }
65 return SecData;
66}
67
68static void dumpDWARFContext(DWARFContext &DC) {
71 options.DumpType &= ~(1 << DIDT_ID_DebugFrame);
73}
74
75}
76
78 if (.getTargetTriple().isOSBinFormatELF()) {
80 "preserveDebugSections only supports ELF LinkGraphs!",
82 }
83 for (auto &Sec : G.sections()) {
84 if (DWARFSectionNames.count(Sec.getName())) {
85 LLVM_DEBUG(dbgs() << "Preserving DWARF section " << Sec.getName()
86 << "\n");
87 preserveDWARFSection(G, Sec);
88 }
89 }
91}
92
96 if (.getTargetTriple().isOSBinFormatELF()) {
98 "createDWARFContext only supports ELF LinkGraphs!",
100 }
102 for (auto &Sec : G.sections()) {
103 if (DWARFSectionNames.count(Sec.getName())) {
104 auto SecData = getSectionData(Sec);
105 auto Name = Sec.getName();
106
107 Name.consume_front(".");
108 LLVM_DEBUG(dbgs() << "Creating DWARFContext section " << Name
109 << " with size " << SecData.size() << "\n");
110 DWARFSectionData[Name] =
111 std::make_unique(std::move(SecData));
112 }
113 }
114 auto Ctx =
117 dumpDWARFContext(*Ctx);
118 return std::make_pair(std::move(Ctx), std::move(DWARFSectionData));
119}
DWARFContext This data structure is the top level entity that deals with dwarf debug information pars...
void dump(raw_ostream &OS, DIDumpOptions DumpOpts, std::array< std::optional< uint64_t >, DIDT_ID_Count > DumpOffsets)
Dump a textual representation to OS.
static std::unique_ptr< DWARFContext > create(const object::ObjectFile &Obj, ProcessDebugRelocations RelocAction=ProcessDebugRelocations::Process, const LoadedObjectInfo *L=nullptr, std::string DWPName="", std::function< void(Error)> RecoverableErrorHandler=WithColor::defaultErrorHandler, std::function< void(Error)> WarningHandler=WithColor::defaultWarningHandler, bool ThreadSafe=false)
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
Implements a dense probed hash-table based set.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
An Addressable with content and edges.
ArrayRef< char > getContent() const
Get the content for this block. Block must not be a zero-fill block.
bool isZeroFill() const
Returns true if this is a zero-fill block.
size_t getSize() const
Returns the size of this defined addressable.
Represents an object file section.
iterator_range< symbol_iterator > symbols()
Returns an iterator over the symbols defined in this section.
iterator_range< block_iterator > blocks()
Returns an iterator over the blocks defined in this section.
LLVM_ABI Error preserveDebugSections(jitlink::LinkGraph &G)
Definition DebugInfoSupport.cpp:77
LLVM_ABI Expected< std::pair< std::unique_ptr< DWARFContext >, StringMap< std::unique_ptr< MemoryBuffer > > > > createDWARFContext(jitlink::LinkGraph &G)
Definition DebugInfoSupport.cpp:95
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
Container for dump options that control which debug information will be dumped.