LLVM  13.0.0git
DWARFObject.h
Go to the documentation of this file.
1 //===- DWARFObject.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 #ifndef LLVM_DEBUGINFO_DWARF_DWARFOBJECT_H
10 #define LLVM_DEBUGINFO_DWARF_DWARFOBJECT_H
11 
14 #include "llvm/Object/ObjectFile.h"
15 
16 namespace llvm {
17 // This is responsible for low level access to the object file. It
18 // knows how to find the required sections and compute relocated
19 // values.
20 // The default implementations of the get<Section> methods return dummy values.
21 // This is to allow clients that only need some of those to implement just the
22 // ones they need. We can't use unreachable for as many cases because the parser
23 // implementation is eager and will call some of these methods even if the
24 // result is not used.
25 class DWARFObject {
26  DWARFSection Dummy;
27 
28 public:
29  virtual ~DWARFObject() = default;
30  virtual StringRef getFileName() const { llvm_unreachable("unimplemented"); }
31  virtual const object::ObjectFile *getFile() const { return nullptr; }
32  virtual ArrayRef<SectionName> getSectionNames() const { return {}; }
33  virtual bool isLittleEndian() const = 0;
34  virtual uint8_t getAddressSize() const { llvm_unreachable("unimplemented"); }
35  virtual void
37  virtual void
39  virtual StringRef getAbbrevSection() const { return ""; }
40  virtual const DWARFSection &getLocSection() const { return Dummy; }
41  virtual const DWARFSection &getLoclistsSection() const { return Dummy; }
42  virtual StringRef getArangesSection() const { return ""; }
43  virtual const DWARFSection &getFrameSection() const { return Dummy; }
44  virtual const DWARFSection &getEHFrameSection() const { return Dummy; }
45  virtual const DWARFSection &getLineSection() const { return Dummy; }
46  virtual StringRef getLineStrSection() const { return ""; }
47  virtual StringRef getStrSection() const { return ""; }
48  virtual const DWARFSection &getRangesSection() const { return Dummy; }
49  virtual const DWARFSection &getRnglistsSection() const { return Dummy; }
50  virtual const DWARFSection &getMacroSection() const { return Dummy; }
51  virtual StringRef getMacroDWOSection() const { return ""; }
52  virtual StringRef getMacinfoSection() const { return ""; }
53  virtual StringRef getMacinfoDWOSection() const { return ""; }
54  virtual const DWARFSection &getPubnamesSection() const { return Dummy; }
55  virtual const DWARFSection &getPubtypesSection() const { return Dummy; }
56  virtual const DWARFSection &getGnuPubnamesSection() const { return Dummy; }
57  virtual const DWARFSection &getGnuPubtypesSection() const { return Dummy; }
58  virtual const DWARFSection &getStrOffsetsSection() const { return Dummy; }
59  virtual void
61  virtual void
63  virtual StringRef getAbbrevDWOSection() const { return ""; }
64  virtual const DWARFSection &getLineDWOSection() const { return Dummy; }
65  virtual const DWARFSection &getLocDWOSection() const { return Dummy; }
66  virtual const DWARFSection &getLoclistsDWOSection() const { return Dummy; }
67  virtual StringRef getStrDWOSection() const { return ""; }
68  virtual const DWARFSection &getStrOffsetsDWOSection() const {
69  return Dummy;
70  }
71  virtual const DWARFSection &getRangesDWOSection() const { return Dummy; }
72  virtual const DWARFSection &getRnglistsDWOSection() const { return Dummy; }
73  virtual const DWARFSection &getAddrSection() const { return Dummy; }
74  virtual const DWARFSection &getAppleNamesSection() const { return Dummy; }
75  virtual const DWARFSection &getAppleTypesSection() const { return Dummy; }
76  virtual const DWARFSection &getAppleNamespacesSection() const {
77  return Dummy;
78  }
79  virtual const DWARFSection &getNamesSection() const { return Dummy; }
80  virtual const DWARFSection &getAppleObjCSection() const { return Dummy; }
81  virtual StringRef getCUIndexSection() const { return ""; }
82  virtual StringRef getGdbIndexSection() const { return ""; }
83  virtual StringRef getTUIndexSection() const { return ""; }
84  virtual Optional<RelocAddrEntry> find(const DWARFSection &Sec,
85  uint64_t Pos) const = 0;
86 };
87 
88 } // namespace llvm
89 #endif
llvm::DWARFSection
Definition: DWARFSection.h:16
llvm::DWARFObject::getLineStrSection
virtual StringRef getLineStrSection() const
Definition: DWARFObject.h:46
llvm::DWARFObject::getAddrSection
virtual const DWARFSection & getAddrSection() const
Definition: DWARFObject.h:73
llvm::DWARFObject::getFileName
virtual StringRef getFileName() const
Definition: DWARFObject.h:30
llvm
Definition: AllocatorList.h:23
llvm::DWARFObject::getStrOffsetsSection
virtual const DWARFSection & getStrOffsetsSection() const
Definition: DWARFObject.h:58
llvm::DWARFObject::getArangesSection
virtual StringRef getArangesSection() const
Definition: DWARFObject.h:42
llvm::DWARFObject::getRangesDWOSection
virtual const DWARFSection & getRangesDWOSection() const
Definition: DWARFObject.h:71
llvm::DWARFObject::getAppleObjCSection
virtual const DWARFSection & getAppleObjCSection() const
Definition: DWARFObject.h:80
llvm::DWARFObject::getFile
virtual const object::ObjectFile * getFile() const
Definition: DWARFObject.h:31
DWARFRelocMap.h
llvm::DWARFObject::getLineDWOSection
virtual const DWARFSection & getLineDWOSection() const
Definition: DWARFObject.h:64
llvm::DWARFObject::forEachInfoSections
virtual void forEachInfoSections(function_ref< void(const DWARFSection &)> F) const
Definition: DWARFObject.h:36
llvm::Optional
Definition: APInt.h:33
llvm::DWARFObject::getRnglistsDWOSection
virtual const DWARFSection & getRnglistsDWOSection() const
Definition: DWARFObject.h:72
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::DWARFObject::forEachTypesSections
virtual void forEachTypesSections(function_ref< void(const DWARFSection &)> F) const
Definition: DWARFObject.h:38
llvm::DWARFObject::getLoclistsSection
virtual const DWARFSection & getLoclistsSection() const
Definition: DWARFObject.h:41
llvm::DWARFObject::getAppleTypesSection
virtual const DWARFSection & getAppleTypesSection() const
Definition: DWARFObject.h:75
llvm::DWARFObject::getSectionNames
virtual ArrayRef< SectionName > getSectionNames() const
Definition: DWARFObject.h:32
llvm::DWARFObject::forEachTypesDWOSections
virtual void forEachTypesDWOSections(function_ref< void(const DWARFSection &)> F) const
Definition: DWARFObject.h:62
DWARFSection.h
llvm::DWARFObject::getGnuPubnamesSection
virtual const DWARFSection & getGnuPubnamesSection() const
Definition: DWARFObject.h:56
llvm::DWARFObject::getAddressSize
virtual uint8_t getAddressSize() const
Definition: DWARFObject.h:34
llvm::DWARFObject::getLocSection
virtual const DWARFSection & getLocSection() const
Definition: DWARFObject.h:40
llvm::DWARFObject
Definition: DWARFObject.h:25
llvm::DWARFObject::getRangesSection
virtual const DWARFSection & getRangesSection() const
Definition: DWARFObject.h:48
llvm::DWARFObject::getStrOffsetsDWOSection
virtual const DWARFSection & getStrOffsetsDWOSection() const
Definition: DWARFObject.h:68
llvm::DWARFObject::getStrDWOSection
virtual StringRef getStrDWOSection() const
Definition: DWARFObject.h:67
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:168
llvm::DWARFObject::getAbbrevSection
virtual StringRef getAbbrevSection() const
Definition: DWARFObject.h:39
llvm::DWARFObject::getPubtypesSection
virtual const DWARFSection & getPubtypesSection() const
Definition: DWARFObject.h:55
llvm::DWARFObject::getFrameSection
virtual const DWARFSection & getFrameSection() const
Definition: DWARFObject.h:43
llvm::DWARFObject::getNamesSection
virtual const DWARFSection & getNamesSection() const
Definition: DWARFObject.h:79
llvm::DWARFObject::getAppleNamesSection
virtual const DWARFSection & getAppleNamesSection() const
Definition: DWARFObject.h:74
llvm::DWARFObject::~DWARFObject
virtual ~DWARFObject()=default
ObjectFile.h
llvm::DWARFObject::getLocDWOSection
virtual const DWARFSection & getLocDWOSection() const
Definition: DWARFObject.h:65
llvm::DWARFObject::getMacroDWOSection
virtual StringRef getMacroDWOSection() const
Definition: DWARFObject.h:51
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
llvm::object::ObjectFile
This class is the base class for all object file types.
Definition: ObjectFile.h:225
llvm::DWARFObject::getStrSection
virtual StringRef getStrSection() const
Definition: DWARFObject.h:47
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
llvm::DWARFObject::find
virtual Optional< RelocAddrEntry > find(const DWARFSection &Sec, uint64_t Pos) const =0
llvm::DWARFObject::getAbbrevDWOSection
virtual StringRef getAbbrevDWOSection() const
Definition: DWARFObject.h:63
llvm::DWARFObject::getMacinfoDWOSection
virtual StringRef getMacinfoDWOSection() const
Definition: DWARFObject.h:53
llvm::DWARFObject::getCUIndexSection
virtual StringRef getCUIndexSection() const
Definition: DWARFObject.h:81
llvm::DWARFObject::getGnuPubtypesSection
virtual const DWARFSection & getGnuPubtypesSection() const
Definition: DWARFObject.h:57
llvm::DWARFObject::getMacinfoSection
virtual StringRef getMacinfoSection() const
Definition: DWARFObject.h:52
llvm::DWARFObject::getAppleNamespacesSection
virtual const DWARFSection & getAppleNamespacesSection() const
Definition: DWARFObject.h:76
llvm::DWARFObject::getLoclistsDWOSection
virtual const DWARFSection & getLoclistsDWOSection() const
Definition: DWARFObject.h:66
llvm::DWARFObject::getMacroSection
virtual const DWARFSection & getMacroSection() const
Definition: DWARFObject.h:50
llvm::DWARFObject::getRnglistsSection
virtual const DWARFSection & getRnglistsSection() const
Definition: DWARFObject.h:49
llvm::DWARFObject::forEachInfoDWOSections
virtual void forEachInfoDWOSections(function_ref< void(const DWARFSection &)> F) const
Definition: DWARFObject.h:60
llvm::DWARFObject::isLittleEndian
virtual bool isLittleEndian() const =0
llvm::DWARFObject::getPubnamesSection
virtual const DWARFSection & getPubnamesSection() const
Definition: DWARFObject.h:54
llvm::DWARFObject::getEHFrameSection
virtual const DWARFSection & getEHFrameSection() const
Definition: DWARFObject.h:44
llvm::DWARFObject::getTUIndexSection
virtual StringRef getTUIndexSection() const
Definition: DWARFObject.h:83
llvm::DWARFObject::getLineSection
virtual const DWARFSection & getLineSection() const
Definition: DWARFObject.h:45
llvm::DWARFObject::getGdbIndexSection
virtual StringRef getGdbIndexSection() const
Definition: DWARFObject.h:82