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