mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-25 12:50:00 +00:00
[LLVMSymbolize] Don't use LLVMSymbolizer::Options in ModuleInfo. NFC.
LLVMSymbolizer::Options is mostly used in LLVMSymbolizer class anyway. Let's keep their usage restricted to that class, especially given that it's worth to move ModuleInfo to a different header, independent from the symbolizer class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251363 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3fdc848a44
commit
4a86a8b614
@ -104,10 +104,11 @@ class ModuleInfo {
|
||||
public:
|
||||
ModuleInfo(ObjectFile *Obj, std::unique_ptr<DIContext> DICtx);
|
||||
|
||||
DILineInfo symbolizeCode(uint64_t ModuleOffset,
|
||||
const LLVMSymbolizer::Options &Opts) const;
|
||||
DIInliningInfo symbolizeInlinedCode(
|
||||
uint64_t ModuleOffset, const LLVMSymbolizer::Options &Opts) const;
|
||||
DILineInfo symbolizeCode(uint64_t ModuleOffset, FunctionNameKind FNKind,
|
||||
bool UseSymbolTable) const;
|
||||
DIInliningInfo symbolizeInlinedCode(uint64_t ModuleOffset,
|
||||
FunctionNameKind FNKind,
|
||||
bool UseSymbolTable) const;
|
||||
bool symbolizeData(uint64_t ModuleOffset, std::string &Name, uint64_t &Start,
|
||||
uint64_t &Size) const;
|
||||
|
||||
|
@ -55,10 +55,9 @@ static bool error(std::error_code ec) {
|
||||
}
|
||||
|
||||
static DILineInfoSpecifier
|
||||
getDILineInfoSpecifier(const LLVMSymbolizer::Options &Opts) {
|
||||
getDILineInfoSpecifier(FunctionNameKind FNKind) {
|
||||
return DILineInfoSpecifier(
|
||||
DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath,
|
||||
Opts.PrintFunctions);
|
||||
DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath, FNKind);
|
||||
}
|
||||
|
||||
ModuleInfo::ModuleInfo(ObjectFile *Obj, std::unique_ptr<DIContext> DICtx)
|
||||
@ -201,16 +200,16 @@ bool ModuleInfo::getNameFromSymbolTable(SymbolRef::Type Type, uint64_t Address,
|
||||
return true;
|
||||
}
|
||||
|
||||
DILineInfo ModuleInfo::symbolizeCode(
|
||||
uint64_t ModuleOffset, const LLVMSymbolizer::Options &Opts) const {
|
||||
DILineInfo ModuleInfo::symbolizeCode(uint64_t ModuleOffset,
|
||||
FunctionNameKind FNKind,
|
||||
bool UseSymbolTable) const {
|
||||
DILineInfo LineInfo;
|
||||
if (DebugInfoContext) {
|
||||
LineInfo = DebugInfoContext->getLineInfoForAddress(
|
||||
ModuleOffset, getDILineInfoSpecifier(Opts));
|
||||
ModuleOffset, getDILineInfoSpecifier(FNKind));
|
||||
}
|
||||
// Override function name from symbol table if necessary.
|
||||
if (Opts.PrintFunctions == FunctionNameKind::LinkageName &&
|
||||
Opts.UseSymbolTable) {
|
||||
if (FNKind == FunctionNameKind::LinkageName && UseSymbolTable) {
|
||||
std::string FunctionName;
|
||||
uint64_t Start, Size;
|
||||
if (getNameFromSymbolTable(SymbolRef::ST_Function, ModuleOffset,
|
||||
@ -221,21 +220,21 @@ DILineInfo ModuleInfo::symbolizeCode(
|
||||
return LineInfo;
|
||||
}
|
||||
|
||||
DIInliningInfo ModuleInfo::symbolizeInlinedCode(
|
||||
uint64_t ModuleOffset, const LLVMSymbolizer::Options &Opts) const {
|
||||
DIInliningInfo ModuleInfo::symbolizeInlinedCode(uint64_t ModuleOffset,
|
||||
FunctionNameKind FNKind,
|
||||
bool UseSymbolTable) const {
|
||||
DIInliningInfo InlinedContext;
|
||||
|
||||
if (DebugInfoContext) {
|
||||
InlinedContext = DebugInfoContext->getInliningInfoForAddress(
|
||||
ModuleOffset, getDILineInfoSpecifier(Opts));
|
||||
ModuleOffset, getDILineInfoSpecifier(FNKind));
|
||||
}
|
||||
// Make sure there is at least one frame in context.
|
||||
if (InlinedContext.getNumberOfFrames() == 0) {
|
||||
InlinedContext.addFrame(DILineInfo());
|
||||
}
|
||||
// Override the function name in lower frame with name from symbol table.
|
||||
if (Opts.PrintFunctions == FunctionNameKind::LinkageName &&
|
||||
Opts.UseSymbolTable) {
|
||||
if (FNKind == FunctionNameKind::LinkageName && UseSymbolTable) {
|
||||
DIInliningInfo PatchedInlinedContext;
|
||||
for (uint32_t i = 0, n = InlinedContext.getNumberOfFrames(); i < n; i++) {
|
||||
DILineInfo LineInfo = InlinedContext.getFrame(i);
|
||||
@ -274,8 +273,8 @@ std::string LLVMSymbolizer::symbolizeCode(const std::string &ModuleName,
|
||||
ModuleOffset += Info->getModulePreferredBase();
|
||||
|
||||
if (Opts.PrintInlining) {
|
||||
DIInliningInfo InlinedContext =
|
||||
Info->symbolizeInlinedCode(ModuleOffset, Opts);
|
||||
DIInliningInfo InlinedContext = Info->symbolizeInlinedCode(
|
||||
ModuleOffset, Opts.PrintFunctions, Opts.UseSymbolTable);
|
||||
uint32_t FramesNum = InlinedContext.getNumberOfFrames();
|
||||
assert(FramesNum > 0);
|
||||
std::string Result;
|
||||
@ -285,7 +284,8 @@ std::string LLVMSymbolizer::symbolizeCode(const std::string &ModuleName,
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
DILineInfo LineInfo = Info->symbolizeCode(ModuleOffset, Opts);
|
||||
DILineInfo LineInfo = Info->symbolizeCode(ModuleOffset, Opts.PrintFunctions,
|
||||
Opts.UseSymbolTable);
|
||||
return printDILineInfo(LineInfo, Info);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user