diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:50:12 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:50:12 +0000 |
| commit | e6d1592492a3a379186bfb02bd0f4eda0669c0d5 (patch) | |
| tree | 599ab169a01f1c86eda9adc774edaedde2f2db5b /include/llvm/DebugInfo/Symbolize | |
| parent | 1a56a5ead7a2e84bee8240f5f6b033b5f1707154 (diff) | |
Notes
Diffstat (limited to 'include/llvm/DebugInfo/Symbolize')
| -rw-r--r-- | include/llvm/DebugInfo/Symbolize/DIPrinter.h | 20 | ||||
| -rw-r--r-- | include/llvm/DebugInfo/Symbolize/SymbolizableModule.h | 20 | ||||
| -rw-r--r-- | include/llvm/DebugInfo/Symbolize/Symbolize.h | 56 |
3 files changed, 57 insertions, 39 deletions
diff --git a/include/llvm/DebugInfo/Symbolize/DIPrinter.h b/include/llvm/DebugInfo/Symbolize/DIPrinter.h index ab82be3706d8..db7a61a8f160 100644 --- a/include/llvm/DebugInfo/Symbolize/DIPrinter.h +++ b/include/llvm/DebugInfo/Symbolize/DIPrinter.h @@ -1,9 +1,8 @@ //===- llvm/DebugInfo/Symbolize/DIPrinter.h ---------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -21,15 +20,22 @@ namespace llvm { struct DILineInfo; class DIInliningInfo; struct DIGlobal; +struct DILocal; namespace symbolize { class DIPrinter { +public: + enum class OutputStyle { LLVM, GNU }; + +private: raw_ostream &OS; bool PrintFunctionNames; bool PrintPretty; int PrintSourceContext; bool Verbose; + bool Basenames; + OutputStyle Style; void print(const DILineInfo &Info, bool Inlined); void printContext(const std::string &FileName, int64_t Line); @@ -37,14 +43,16 @@ class DIPrinter { public: DIPrinter(raw_ostream &OS, bool PrintFunctionNames = true, bool PrintPretty = false, int PrintSourceContext = 0, - bool Verbose = false) + bool Verbose = false, bool Basenames = false, + OutputStyle Style = OutputStyle::LLVM) : OS(OS), PrintFunctionNames(PrintFunctionNames), PrintPretty(PrintPretty), PrintSourceContext(PrintSourceContext), - Verbose(Verbose) {} + Verbose(Verbose), Basenames(Basenames), Style(Style) {} DIPrinter &operator<<(const DILineInfo &Info); DIPrinter &operator<<(const DIInliningInfo &Info); DIPrinter &operator<<(const DIGlobal &Global); + DIPrinter &operator<<(const DILocal &Local); }; } } diff --git a/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h b/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h index e576a91e887c..506ecc424b4c 100644 --- a/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h +++ b/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h @@ -1,9 +1,8 @@ //===- SymbolizableModule.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -25,13 +24,16 @@ class SymbolizableModule { public: virtual ~SymbolizableModule() = default; - virtual DILineInfo symbolizeCode(uint64_t ModuleOffset, + virtual DILineInfo symbolizeCode(object::SectionedAddress ModuleOffset, FunctionNameKind FNKind, bool UseSymbolTable) const = 0; - virtual DIInliningInfo symbolizeInlinedCode(uint64_t ModuleOffset, - FunctionNameKind FNKind, - bool UseSymbolTable) const = 0; - virtual DIGlobal symbolizeData(uint64_t ModuleOffset) const = 0; + virtual DIInliningInfo + symbolizeInlinedCode(object::SectionedAddress ModuleOffset, + FunctionNameKind FNKind, bool UseSymbolTable) const = 0; + virtual DIGlobal + symbolizeData(object::SectionedAddress ModuleOffset) const = 0; + virtual std::vector<DILocal> + symbolizeFrame(object::SectionedAddress ModuleOffset) const = 0; // Return true if this is a 32-bit x86 PE COFF module. virtual bool isWin32Module() const = 0; diff --git a/include/llvm/DebugInfo/Symbolize/Symbolize.h b/include/llvm/DebugInfo/Symbolize/Symbolize.h index 289148f569db..d3da28ca0b7b 100644 --- a/include/llvm/DebugInfo/Symbolize/Symbolize.h +++ b/include/llvm/DebugInfo/Symbolize/Symbolize.h @@ -1,9 +1,8 @@ //===- Symbolize.h ----------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -36,35 +35,35 @@ using FunctionNameKind = DILineInfoSpecifier::FunctionNameKind; class LLVMSymbolizer { public: struct Options { - FunctionNameKind PrintFunctions; - bool UseSymbolTable : 1; - bool Demangle : 1; - bool RelativeAddresses : 1; + FunctionNameKind PrintFunctions = FunctionNameKind::LinkageName; + bool UseSymbolTable = true; + bool Demangle = true; + bool RelativeAddresses = false; std::string DefaultArch; std::vector<std::string> DsymHints; - - Options(FunctionNameKind PrintFunctions = FunctionNameKind::LinkageName, - bool UseSymbolTable = true, bool Demangle = true, - bool RelativeAddresses = false, std::string DefaultArch = "") - : PrintFunctions(PrintFunctions), UseSymbolTable(UseSymbolTable), - Demangle(Demangle), RelativeAddresses(RelativeAddresses), - DefaultArch(std::move(DefaultArch)) {} + std::string FallbackDebugPath; + std::string DWPName; }; - LLVMSymbolizer(const Options &Opts = Options()) : Opts(Opts) {} + LLVMSymbolizer() = default; + LLVMSymbolizer(const Options &Opts) : Opts(Opts) {} ~LLVMSymbolizer() { flush(); } + Expected<DILineInfo> symbolizeCode(const ObjectFile &Obj, + object::SectionedAddress ModuleOffset); Expected<DILineInfo> symbolizeCode(const std::string &ModuleName, - uint64_t ModuleOffset, - StringRef DWPName = ""); - Expected<DIInliningInfo> symbolizeInlinedCode(const std::string &ModuleName, - uint64_t ModuleOffset, - StringRef DWPName = ""); + object::SectionedAddress ModuleOffset); + Expected<DIInliningInfo> + symbolizeInlinedCode(const std::string &ModuleName, + object::SectionedAddress ModuleOffset); Expected<DIGlobal> symbolizeData(const std::string &ModuleName, - uint64_t ModuleOffset); + object::SectionedAddress ModuleOffset); + Expected<std::vector<DILocal>> + symbolizeFrame(const std::string &ModuleName, + object::SectionedAddress ModuleOffset); void flush(); static std::string @@ -74,14 +73,23 @@ public: private: // Bundles together object file with code/data and object file with // corresponding debug info. These objects can be the same. - using ObjectPair = std::pair<ObjectFile *, ObjectFile *>; + using ObjectPair = std::pair<const ObjectFile *, const ObjectFile *>; + + Expected<DILineInfo> + symbolizeCodeCommon(SymbolizableModule *Info, + object::SectionedAddress ModuleOffset); /// Returns a SymbolizableModule or an error if loading debug info failed. /// Only one attempt is made to load a module, and errors during loading are /// only reported once. Subsequent calls to get module info for a module that /// failed to load will return nullptr. Expected<SymbolizableModule *> - getOrCreateModuleInfo(const std::string &ModuleName, StringRef DWPName = ""); + getOrCreateModuleInfo(const std::string &ModuleName); + + Expected<SymbolizableModule *> + createModuleInfo(const ObjectFile *Obj, + std::unique_ptr<DIContext> Context, + StringRef ModuleName); ObjectFile *lookUpDsymFile(const std::string &Path, const MachOObjectFile *ExeObj, |
