LLVM 20.0.0git
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_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEOBJECTFILE_H
13#define LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEOBJECTFILE_H
14
15#include "llvm/ADT/StringRef.h"
18#include "llvm/Support/Error.h"
19#include <cstdint>
20#include <memory>
21#include <string>
22#include <utility>
23#include <vector>
24
25namespace llvm {
26
27class DataExtractor;
28
29namespace symbolize {
30
32public:
34 create(const object::ObjectFile *Obj, std::unique_ptr<DIContext> DICtx,
35 bool UntagAddresses);
36
38 DILineInfoSpecifier LineInfoSpecifier,
39 bool UseSymbolTable) const override;
41 DILineInfoSpecifier LineInfoSpecifier,
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 std::vector<object::SectionedAddress>
47 findSymbol(StringRef Symbol, uint64_t Offset) const override;
48
49 // Return true if this is a 32-bit x86 PE COFF module.
50 bool isWin32Module() const override;
51
52 // Returns the preferred base of the module, i.e. where the loader would place
53 // it in memory assuming there were no conflicts.
54 uint64_t getModulePreferredBase() const override;
55
56private:
57 bool shouldOverrideWithSymbolTable(FunctionNameKind FNKind,
58 bool UseSymbolTable) const;
59
60 bool getNameFromSymbolTable(uint64_t Address, std::string &Name,
62 std::string &FileName) const;
63 // For big-endian PowerPC64 ELF, OpdAddress is the address of the .opd
64 // (function descriptor) section and OpdExtractor refers to its contents.
65 Error addSymbol(const object::SymbolRef &Symbol, uint64_t SymbolSize,
66 DataExtractor *OpdExtractor = nullptr,
67 uint64_t OpdAddress = 0);
68 Error addCoffExportSymbols(const object::COFFObjectFile *CoffObj);
69
70 /// Search for the first occurence of specified Address in ObjectFile.
71 uint64_t getModuleSectionIndexForAddress(uint64_t Address) const;
72
74 std::unique_ptr<DIContext> DebugInfoContext;
75 bool UntagAddresses;
76
77 struct SymbolDesc {
79 // If size is 0, assume that symbol occupies the whole memory range up to
80 // the following symbol.
81 uint64_t Size;
82
83 StringRef Name;
84 // Non-zero if this is an ELF local symbol. See the comment in
85 // getNameFromSymbolTable.
86 uint32_t ELFLocalSymIdx;
87
88 bool operator<(const SymbolDesc &RHS) const {
89 return Addr != RHS.Addr ? Addr < RHS.Addr : Size < RHS.Size;
90 }
91 };
92 std::vector<SymbolDesc> Symbols;
93 // (index, filename) pairs of ELF STT_FILE symbols.
94 std::vector<std::pair<uint32_t, StringRef>> FileSymbols;
95
97 std::unique_ptr<DIContext> DICtx,
98 bool UntagAddresses);
99};
100
101} // end namespace symbolize
102
103} // end namespace llvm
104
105#endif // LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEOBJECTFILE_H
uint64_t Addr
std::string Name
uint64_t Size
Value * RHS
A format-neutral container for inlined code description.
Definition: DIContext.h:94
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
Tagged union holding either a T or a Error.
Definition: Error.h:481
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
This class is the base class for all object file types.
Definition: ObjectFile.h:229
This is a value type class that represents a single symbol in the list of symbols in the object file.
Definition: ObjectFile.h:168
DIGlobal symbolizeData(object::SectionedAddress ModuleOffset) const override
DILineInfo symbolizeCode(object::SectionedAddress ModuleOffset, DILineInfoSpecifier LineInfoSpecifier, bool UseSymbolTable) const override
static Expected< std::unique_ptr< SymbolizableObjectFile > > create(const object::ObjectFile *Obj, std::unique_ptr< DIContext > DICtx, bool UntagAddresses)
std::vector< object::SectionedAddress > findSymbol(StringRef Symbol, uint64_t Offset) const override
std::vector< DILocal > symbolizeFrame(object::SectionedAddress ModuleOffset) const override
DIInliningInfo symbolizeInlinedCode(object::SectionedAddress ModuleOffset, DILineInfoSpecifier LineInfoSpecifier, bool UseSymbolTable) const override
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:480
bool operator<(int64_t V1, const APSInt &V2)
Definition: APSInt.h:361
DINameKind
A DINameKind is passed to name search methods to specify a preference regarding the type of name reso...
Definition: DIContext.h:142
Container for description of a global variable.
Definition: DIContext.h:120
Controls which fields of DILineInfo container should be filled with data.
Definition: DIContext.h:146
A format-neutral container for source line information.
Definition: DIContext.h:32