1 //===-- LLVMSymbolize.h ----------------------------------------- C++ -----===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Header for LLVM symbolization library.
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_SYMBOLIZE_H
14 #define LLVM_SYMBOLIZE_H
16 #include "llvm/ADT/OwningPtr.h"
17 #include "llvm/DebugInfo/DIContext.h"
18 #include "llvm/Object/ObjectFile.h"
19 #include "llvm/Support/MemoryBuffer.h"
25 using namespace object;
31 class LLVMSymbolizer {
34 bool UseSymbolTable : 1;
35 bool PrintFunctions : 1;
36 bool PrintInlining : 1;
38 Options(bool UseSymbolTable = true, bool PrintFunctions = true,
39 bool PrintInlining = true, bool Demangle = true)
40 : UseSymbolTable(UseSymbolTable), PrintFunctions(PrintFunctions),
41 PrintInlining(PrintInlining), Demangle(Demangle) {
45 LLVMSymbolizer(const Options &Opts = Options()) : Opts(Opts) {}
47 // Returns the result of symbolization for module name/offset as
48 // a string (possibly containing newlines).
50 symbolizeCode(const std::string &ModuleName, uint64_t ModuleOffset);
52 symbolizeData(const std::string &ModuleName, uint64_t ModuleOffset);
55 ModuleInfo *getOrCreateModuleInfo(const std::string &ModuleName);
56 std::string printDILineInfo(DILineInfo LineInfo) const;
57 void DemangleName(std::string &Name) const;
59 typedef std::map<std::string, ModuleInfo *> ModuleMapTy;
62 static const char kBadString[];
67 ModuleInfo(ObjectFile *Obj, DIContext *DICtx);
69 DILineInfo symbolizeCode(uint64_t ModuleOffset,
70 const LLVMSymbolizer::Options &Opts) const;
71 DIInliningInfo symbolizeInlinedCode(
72 uint64_t ModuleOffset, const LLVMSymbolizer::Options &Opts) const;
73 bool symbolizeData(uint64_t ModuleOffset, std::string &Name, uint64_t &Start,
74 uint64_t &Size) const;
77 bool getNameFromSymbolTable(SymbolRef::Type Type, uint64_t Address,
78 std::string &Name, uint64_t &Addr,
79 uint64_t &Size) const;
80 OwningPtr<ObjectFile> Module;
81 OwningPtr<DIContext> DebugInfoContext;
86 friend bool operator<(const SymbolDesc &s1, const SymbolDesc &s2) {
87 return s1.Addr < s2.Addr;
90 typedef std::map<SymbolDesc, StringRef> SymbolMapTy;
91 SymbolMapTy Functions;
95 } // namespace symbolize
98 #endif // LLVM_SYMBOLIZE_H