1 //===-- SymbolizableObjectFile.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 // This file declares the SymbolizableObjectFile class.
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEOBJECTFILE_H
14 #define LLVM_LIB_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEOBJECTFILE_H
16 #include "llvm/DebugInfo/Symbolize/SymbolizableModule.h"
26 class SymbolizableObjectFile : public SymbolizableModule {
28 static ErrorOr<std::unique_ptr<SymbolizableObjectFile>>
29 create(object::ObjectFile *Obj, std::unique_ptr<DIContext> DICtx);
31 DILineInfo symbolizeCode(uint64_t ModuleOffset, FunctionNameKind FNKind,
32 bool UseSymbolTable) const override;
33 DIInliningInfo symbolizeInlinedCode(uint64_t ModuleOffset,
34 FunctionNameKind FNKind,
35 bool UseSymbolTable) const override;
36 DIGlobal symbolizeData(uint64_t ModuleOffset) const override;
38 // Return true if this is a 32-bit x86 PE COFF module.
39 bool isWin32Module() const override;
41 // Returns the preferred base of the module, i.e. where the loader would place
42 // it in memory assuming there were no conflicts.
43 uint64_t getModulePreferredBase() const override;
46 bool getNameFromSymbolTable(object::SymbolRef::Type Type, uint64_t Address,
47 std::string &Name, uint64_t &Addr,
48 uint64_t &Size) const;
49 // For big-endian PowerPC64 ELF, OpdAddress is the address of the .opd
50 // (function descriptor) section and OpdExtractor refers to its contents.
51 std::error_code addSymbol(const object::SymbolRef &Symbol,
53 DataExtractor *OpdExtractor = nullptr,
54 uint64_t OpdAddress = 0);
55 std::error_code addCoffExportSymbols(const object::COFFObjectFile *CoffObj);
57 object::ObjectFile *Module;
58 std::unique_ptr<DIContext> DebugInfoContext;
62 // If size is 0, assume that symbol occupies the whole memory range up to
63 // the following symbol.
65 friend bool operator<(const SymbolDesc &s1, const SymbolDesc &s2) {
66 return s1.Addr < s2.Addr;
69 std::map<SymbolDesc, StringRef> Functions;
70 std::map<SymbolDesc, StringRef> Objects;
72 SymbolizableObjectFile(object::ObjectFile *Obj,
73 std::unique_ptr<DIContext> DICtx);
76 } // namespace symbolize
79 #endif // LLVM_LIB_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEOBJECTFILE_H