diff options
author | Serge Pavlov <sepavloff@gmail.com> | 2023-04-03 23:28:50 +0700 |
---|---|---|
committer | Serge Pavlov <sepavloff@gmail.com> | 2023-11-01 14:41:39 +0700 |
commit | e144ae54dcb96838a6176fd9eef21028935ccd4f (patch) | |
tree | 4ec2f2a6a5ee9020f88961853c6c88cf420e7564 /llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp | |
parent | fd8be1ef598da48897f396296c03a576bf391378 (diff) | |
download | llvm-e144ae54dcb96838a6176fd9eef21028935ccd4f.zip llvm-e144ae54dcb96838a6176fd9eef21028935ccd4f.tar.gz llvm-e144ae54dcb96838a6176fd9eef21028935ccd4f.tar.bz2 |
[symbolizer] Support symbol lookup
Recent versions of GNU binutils starting from 2.39 support symbol+offset
lookup in addition to the usual numeric address lookup. This change adds
symbol lookup to llvm-symbolize and llvm-addr2line.
Now llvm-symbolize behaves closer to GNU addr2line, - if the value specified
as address in command line or input stream is not a number, it is treated as
a symbol name. For example:
llvm-symbolize --obj=abc.so func_22
llvm-symbolize --obj=abc.so "CODE func_22"
This lookup is now supported only for functions. Specification with
offset is not supported yet.
This is a recommit of 2b27948783e4bbc1132d3220d8517ef62607b558, reverted
in 39fec5457c0925bd39f67f63fe17391584e08258 because the test
llvm/test/Support/interrupts.test started failing on Windows. The test was
changed in 18f036d0105589c3175bb51a518c5d272dae61e2 and is also updated in
this commit.
Differential Revision: https://reviews.llvm.org/D149759
Diffstat (limited to 'llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp index 6b8068a..6973030 100644 --- a/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp +++ b/llvm/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp @@ -351,6 +351,19 @@ std::vector<DILocal> SymbolizableObjectFile::symbolizeFrame( return DebugInfoContext->getLocalsForAddress(ModuleOffset); } +std::vector<object::SectionedAddress> +SymbolizableObjectFile::findSymbol(StringRef Symbol) const { + std::vector<object::SectionedAddress> Result; + for (const SymbolDesc &Sym : Symbols) { + if (Sym.Name.equals(Symbol)) { + object::SectionedAddress A{Sym.Addr, + getModuleSectionIndexForAddress(Sym.Addr)}; + Result.push_back(A); + } + } + return Result; +} + /// Search for the first occurence of specified Address in ObjectFile. uint64_t SymbolizableObjectFile::getModuleSectionIndexForAddress( uint64_t Address) const { |