LLVM  10.0.0svn
SymbolizableObjectFile.h
Go to the documentation of this file.
1 //===- SymbolizableObjectFile.h ---------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares the SymbolizableObjectFile class.
10 //
11 //===----------------------------------------------------------------------===//
12 #ifndef LLVM_LIB_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEOBJECTFILE_H
13 #define LLVM_LIB_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEOBJECTFILE_H
14 
15 #include "llvm/ADT/StringRef.h"
18 #include "llvm/Support/ErrorOr.h"
19 #include <cstdint>
20 #include <map>
21 #include <memory>
22 #include <string>
23 #include <system_error>
24 
25 namespace llvm {
26 
27 class DataExtractor;
28 
29 namespace symbolize {
30 
32 public:
34  create(const object::ObjectFile *Obj, std::unique_ptr<DIContext> DICtx,
35  bool UntagAddresses);
36 
38  FunctionNameKind FNKind,
39  bool UseSymbolTable) const override;
41  FunctionNameKind FNKind,
42  bool UseSymbolTable) const override;
43  DIGlobal symbolizeData(object::SectionedAddress ModuleOffset) const override;
44  std::vector<DILocal>
45  symbolizeFrame(object::SectionedAddress ModuleOffset) const override;
46 
47  // Return true if this is a 32-bit x86 PE COFF module.
48  bool isWin32Module() const override;
49 
50  // Returns the preferred base of the module, i.e. where the loader would place
51  // it in memory assuming there were no conflicts.
52  uint64_t getModulePreferredBase() const override;
53 
54 private:
55  bool shouldOverrideWithSymbolTable(FunctionNameKind FNKind,
56  bool UseSymbolTable) const;
57 
58  bool getNameFromSymbolTable(object::SymbolRef::Type Type, uint64_t Address,
59  std::string &Name, uint64_t &Addr,
60  uint64_t &Size) const;
61  // For big-endian PowerPC64 ELF, OpdAddress is the address of the .opd
62  // (function descriptor) section and OpdExtractor refers to its contents.
63  std::error_code addSymbol(const object::SymbolRef &Symbol,
64  uint64_t SymbolSize,
65  DataExtractor *OpdExtractor = nullptr,
66  uint64_t OpdAddress = 0);
67  std::error_code addCoffExportSymbols(const object::COFFObjectFile *CoffObj);
68 
69  /// Search for the first occurence of specified Address in ObjectFile.
70  uint64_t getModuleSectionIndexForAddress(uint64_t Address) const;
71 
73  std::unique_ptr<DIContext> DebugInfoContext;
74  bool UntagAddresses;
75 
76  struct SymbolDesc {
77  uint64_t Addr;
78  // If size is 0, assume that symbol occupies the whole memory range up to
79  // the following symbol.
80  uint64_t Size;
81 
82  bool operator<(const SymbolDesc &RHS) const {
83  return Addr != RHS.Addr ? Addr < RHS.Addr : Size < RHS.Size;
84  }
85  };
86  std::vector<std::pair<SymbolDesc, StringRef>> Functions;
87  std::vector<std::pair<SymbolDesc, StringRef>> Objects;
88 
90  std::unique_ptr<DIContext> DICtx,
91  bool UntagAddresses);
92 };
93 
94 } // end namespace symbolize
95 
96 } // end namespace llvm
97 
98 #endif // LLVM_LIB_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEOBJECTFILE_H
Represents either an error or a value T.
Definition: ErrorOr.h:56
This class represents lattice values for constants.
Definition: AllocatorList.h:23
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:66
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
This class is the base class for all object file types.
Definition: ObjectFile.h:221
DINameKind
A DINameKind is passed to name search methods to specify a preference regarding the type of name reso...
Definition: DIContext.h:131
A format-neutral container for source line information.
Definition: DIContext.h:30
DIInliningInfo symbolizeInlinedCode(object::SectionedAddress ModuleOffset, FunctionNameKind FNKind, bool UseSymbolTable) const override
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
A format-neutral container for inlined code description.
Definition: DIContext.h:81
std::vector< DILocal > symbolizeFrame(object::SectionedAddress ModuleOffset) const override
This is a value type class that represents a single symbol in the list of symbols in the object file...
Definition: ObjectFile.h:160
DILineInfo symbolizeCode(object::SectionedAddress ModuleOffset, FunctionNameKind FNKind, bool UseSymbolTable) const override
uint32_t Size
Definition: Profile.cpp:46
Provides ErrorOr<T> smart pointer.
bool operator<(int64_t V1, const APSInt &V2)
Definition: APSInt.h:343
static ErrorOr< std::unique_ptr< SymbolizableObjectFile > > create(const object::ObjectFile *Obj, std::unique_ptr< DIContext > DICtx, bool UntagAddresses)
DIGlobal symbolizeData(object::SectionedAddress ModuleOffset) const override
Container for description of a global variable.
Definition: DIContext.h:111