LLVM  4.0.0
SymbolizableObjectFile.h
Go to the documentation of this file.
1 //===-- SymbolizableObjectFile.h -------------------------------- C++ -----===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the SymbolizableObjectFile class.
11 //
12 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEOBJECTFILE_H
14 #define LLVM_LIB_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEOBJECTFILE_H
15 
17 #include <map>
18 
19 namespace llvm {
20 class DataExtractor;
21 }
22 
23 namespace llvm {
24 namespace symbolize {
25 
27 public:
29  create(object::ObjectFile *Obj, std::unique_ptr<DIContext> DICtx);
30 
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;
37 
38  // Return true if this is a 32-bit x86 PE COFF module.
39  bool isWin32Module() const override;
40 
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;
44 
45 private:
46  bool shouldOverrideWithSymbolTable(FunctionNameKind FNKind,
47  bool UseSymbolTable) const;
48 
49  bool getNameFromSymbolTable(object::SymbolRef::Type Type, uint64_t Address,
50  std::string &Name, uint64_t &Addr,
51  uint64_t &Size) const;
52  // For big-endian PowerPC64 ELF, OpdAddress is the address of the .opd
53  // (function descriptor) section and OpdExtractor refers to its contents.
54  std::error_code addSymbol(const object::SymbolRef &Symbol,
55  uint64_t SymbolSize,
56  DataExtractor *OpdExtractor = nullptr,
57  uint64_t OpdAddress = 0);
58  std::error_code addCoffExportSymbols(const object::COFFObjectFile *CoffObj);
59 
61  std::unique_ptr<DIContext> DebugInfoContext;
62 
63  struct SymbolDesc {
64  uint64_t Addr;
65  // If size is 0, assume that symbol occupies the whole memory range up to
66  // the following symbol.
67  uint64_t Size;
68  friend bool operator<(const SymbolDesc &s1, const SymbolDesc &s2) {
69  return s1.Addr < s2.Addr;
70  }
71  };
72  std::map<SymbolDesc, StringRef> Functions;
73  std::map<SymbolDesc, StringRef> Objects;
74 
76  std::unique_ptr<DIContext> DICtx);
77 };
78 
79 } // namespace symbolize
80 } // namespace llvm
81 
82 #endif // LLVM_LIB_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEOBJECTFILE_H
Represents either an error or a value T.
Definition: ErrorOr.h:68
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:52
static ErrorOr< std::unique_ptr< SymbolizableObjectFile > > create(object::ObjectFile *Obj, std::unique_ptr< DIContext > DICtx)
This class is the base class for all object file types.
Definition: ObjectFile.h:178
DINameKind
A DINameKind is passed to name search methods to specify a preference regarding the type of name reso...
Definition: DIContext.h:97
DILineInfo - a format-neutral container for source line information.
Definition: DIContext.h:32
DIInliningInfo symbolizeInlinedCode(uint64_t ModuleOffset, FunctionNameKind FNKind, bool UseSymbolTable) const override
DIGlobal symbolizeData(uint64_t ModuleOffset) const override
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
DIInliningInfo - a format-neutral container for inlined code description.
Definition: DIContext.h:61
This is a value type class that represents a single symbol in the list of symbols in the object file...
Definition: ObjectFile.h:116
bool operator<(int64_t V1, const APSInt &V2)
Definition: APSInt.h:326
DILineInfo symbolizeCode(uint64_t ModuleOffset, FunctionNameKind FNKind, bool UseSymbolTable) const override
DIGlobal - container for description of a global variable.
Definition: DIContext.h:87