19Expected<std::shared_ptr<SymbolTableDumpPlugin>>
22 auto P = std::make_shared<SymbolTableDumpPlugin>(Path, EC);
30 : OutputStream(Path, EC) {}
37 std::scoped_lock<std::mutex> Lock(DumpMutex);
39 OutputStream <<
"\"" <<
G.getName() <<
"\"\n";
40 for (
auto &Sec :
G.sections()) {
50 for (
auto *Sym : Sec.symbols()) {
52 OutputStream <<
formatv(
"{0:x}", Sym->getAddress().getValue()) <<
" "
53 << Sym->getName() <<
"\n";
67 return DumpedSymbolTable(std::move(*MB));
70DumpedSymbolTable::DumpedSymbolTable(std::unique_ptr<MemoryBuffer> SymtabBuffer)
71 : SymtabBuffer(
std::
move(SymtabBuffer)) {
75void DumpedSymbolTable::parseBuffer() {
78 SymtabBuffer->getBuffer().split(Rows,
'\n');
81 for (
auto Row : Rows) {
87 if (Row.starts_with(
"\"") && Row.ends_with(
"\"")) {
88 CurGraph = Row.
trim(
'"');
93 size_t SpacePos = Row.find(
' ');
97 StringRef AddrStr = Row.substr(0, SpacePos);
98 StringRef SymName = Row.substr(SpacePos + 1);
101 if (AddrStr.starts_with(
"0x"))
102 AddrStr = AddrStr.drop_front(2);
103 if (AddrStr.getAsInteger(16, Addr))
106 SymbolInfos[Addr] = {SymName, CurGraph};
113 Backtrace.
split(BacktraceRows,
'\n');
117 for (
auto Row : BacktraceRows) {
121 auto [RowStart, AddrCol] = Row.rtrim().rsplit(
' ');
122 auto AddrStr = AddrCol.starts_with(
"0x") ? AddrCol.drop_front(2) : AddrCol;
125 if (AddrStr.empty() || AddrStr.getAsInteger(16, Addr)) {
131 auto I = SymbolInfos.upper_bound(Addr);
134 if (
I == SymbolInfos.begin() || (Addr - std::prev(
I)->first >= 1U << 31)) {
140 auto &[SymAddr,
SymInfo] = *std::prev(
I);
141 Out << RowStart <<
" " << AddrCol <<
" " <<
SymInfo.SymName;
142 if (
auto Delta = Addr - SymAddr)
143 Out <<
" + " <<
formatv(
"{0}", Delta);
144 Out <<
" (" <<
SymInfo.GraphName <<
")\n";
This file defines the StringMap class.
This file defines the DenseMap class.
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.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
static constexpr size_t npos
StringRef trim(char Char) const
Return string with consecutive Char characters starting from the left and right removed.
LLVM_ABI std::string symbolicate(StringRef Backtrace)
Given a backtrace, try to symbolicate any unsymbolicated lines using the symbol addresses in the dump...
static Expected< DumpedSymbolTable > Create(StringRef Path)
Create a DumpedSymbolTable from the given path.
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
void modifyPassConfig(MaterializationResponsibility &MR, jitlink::LinkGraph &G, jitlink::PassConfiguration &Config) override
SymbolTableDumpPlugin(StringRef Path, std::error_code &EC)
Create a SymbolTableDumpPlugin.
static Expected< std::shared_ptr< SymbolTableDumpPlugin > > Create(StringRef Path)
Create a SymbolTableDumpPlugin that will append symbol information to the file at the given path.
A raw_ostream that writes to an std::string.
@ NoAlloc
NoAlloc memory should not be allocated by the JITLinkMemoryManager at all.
Error createFileError(const Twine &F, Error E)
Concatenate a source file path and/or name with an Error.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
SymInfo contains information about symbol: it's address and section index which is -1LL for absolute ...
An LinkGraph pass configuration, consisting of a list of pre-prune, post-prune, and post-fixup passes...
LinkGraphPassList PostAllocationPasses
Post-allocation passes.