From 4a86a8b61415fe09a7f00a66cbfbee0f5dcf0468 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Mon, 26 Oct 2015 22:34:56 +0000 Subject: [PATCH] [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 --- include/llvm/DebugInfo/Symbolize/Symbolize.h | 9 +++--- lib/DebugInfo/Symbolize/Symbolize.cpp | 32 ++++++++++---------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/include/llvm/DebugInfo/Symbolize/Symbolize.h b/include/llvm/DebugInfo/Symbolize/Symbolize.h index eaa63348fad..1e3f37aaae9 100644 --- a/include/llvm/DebugInfo/Symbolize/Symbolize.h +++ b/include/llvm/DebugInfo/Symbolize/Symbolize.h @@ -104,10 +104,11 @@ class ModuleInfo { public: ModuleInfo(ObjectFile *Obj, std::unique_ptr 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; diff --git a/lib/DebugInfo/Symbolize/Symbolize.cpp b/lib/DebugInfo/Symbolize/Symbolize.cpp index ecdb089cd77..5a72410decf 100644 --- a/lib/DebugInfo/Symbolize/Symbolize.cpp +++ b/lib/DebugInfo/Symbolize/Symbolize.cpp @@ -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 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); }