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),
41 PrintFunctions(PrintFunctions),
42 PrintInlining(PrintInlining),
43 Demangle(Demangle) { }
46 LLVMSymbolizer(const Options &Opts = Options()) : Opts(Opts) { }
48 // Returns the result of symbolization for module name/offset as
49 // a string (possibly containing newlines).
50 std::string symbolizeCode(const std::string &ModuleName,
51 uint64_t ModuleOffset);
52 std::string symbolizeData(const std::string &ModuleName,
53 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[];
66 OwningPtr<ObjectFile> Module;
67 OwningPtr<DIContext> DebugInfoContext;
69 ModuleInfo(ObjectFile *Obj, DIContext *DICtx)
70 : Module(Obj), DebugInfoContext(DICtx) {}
72 DILineInfo symbolizeCode(
73 uint64_t ModuleOffset, const LLVMSymbolizer::Options& Opts) const;
74 DIInliningInfo symbolizeInlinedCode(
75 uint64_t ModuleOffset, const LLVMSymbolizer::Options& Opts) const;
76 bool symbolizeData(uint64_t ModuleOffset, std::string &Name,
77 uint64_t &Start, uint64_t &Size) const;
80 bool getNameFromSymbolTable(SymbolRef::Type Type, uint64_t Address,
81 std::string &Name, uint64_t &Addr,
82 uint64_t &Size) const;
85 } // namespace symbolize
88 #endif // LLVM_SYMBOLIZE_H