LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
DWARF/types/ClassLike.hpp
Go to the documentation of this file.
1/* Copyright 2022 - 2026 R. Thomas
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#ifndef LIEF_DWARF_TYPE_STRUCTURE_H
16#define LIEF_DWARF_TYPE_STRUCTURE_H
17
18#include "LIEF/visibility.h"
19#include "LIEF/DWARF/Type.hpp"
21
22namespace LIEF {
23namespace dwarf {
24namespace types {
25
26namespace details {
27class Member;
28}
29
32class LIEF_API ClassLike : public Type {
33 public:
34 using Type::Type;
35
38 public:
39 Member(std::unique_ptr<details::Member> impl);
40 Member(Member&& other) noexcept;
41 Member& operator=(Member&& other) noexcept;
42
44 std::string name() const;
45
50
67
71
73 std::unique_ptr<Type> type() const;
74
75 bool is_external() const;
76
77 bool is_declaration() const;
78
80 private:
81 std::unique_ptr<details::Member> impl_;
82 };
83
85
86 static bool classof(const Type* type) {
87 const auto kind = type->kind();
89 }
90
92 std::vector<Member> members() const;
93
95 std::unique_ptr<Member> find_member(uint64_t offset) const;
96
99
100 ~ClassLike() override;
101};
102
105 public:
106 using ClassLike::ClassLike;
107
108 static bool classof(const Type* type) {
109 return type->kind() == Type::KIND::STRUCT;
110 }
111
112 ~Structure() override;
113};
114
116class LIEF_API Class : public ClassLike {
117 public:
118 using ClassLike::ClassLike;
119
120 static bool classof(const Type* type) {
121 return type->kind() == Type::KIND::CLASS;
122 }
123
124 ~Class() override;
125};
126
128class LIEF_API Union : public ClassLike {
129 public:
130 using ClassLike::ClassLike;
131
132 static bool classof(const Type* type) {
133 return type->kind() == Type::KIND::UNION;
134 }
135
136 ~Union() override;
137};
138
140class LIEF_API Packed : public ClassLike {
141 public:
142 using ClassLike::ClassLike;
143
144 static bool classof(const Type* type) {
145 return type->kind() == Type::KIND::PACKED;
146 }
147
148 ~Packed() override;
149};
150
151}
152}
153}
154#endif
155
156
KIND kind() const
@ PACKED
Definition DWARF/Type.hpp:141
@ STRUCT
Definition DWARF/Type.hpp:133
@ CLASS
Definition DWARF/Type.hpp:130
@ UNION
Definition DWARF/Type.hpp:134
result< uint64_t > bit_size() const
If the current member is a bit-field, this function returns its size in bits.
Member(std::unique_ptr< details::Member > impl)
std::unique_ptr< Type > type() const
Type of the current member.
Member & operator=(Member &&other) noexcept
Member(Member &&other) noexcept
std::string name() const
Name of the member.
result< uint64_t > offset() const
Offset of the current member in the struct/union/class.
result< uint64_t > bit_offset() const
Offset of the current member in bits the struct/union/class.
This class abstracts a DWARF aggregate: DW_TAG_structure_type, DW_TAG_class_type, DW_TAG_union_type.
Definition DWARF/types/ClassLike.hpp:32
iterator_range< Function::Iterator > functions_it
Definition DWARF/types/ClassLike.hpp:84
functions_it functions() const
Iterator over the functions defined by the class-like.
std::vector< Member > members() const
Return the list of all the attributes defined in this class-like type.
std::unique_ptr< Member > find_member(uint64_t offset) const
Try to find the attribute at the given offset.
static bool classof(const Type *type)
Definition DWARF/types/ClassLike.hpp:86
This class represents a DWARF class type (DW_TAG_class_type).
Definition DWARF/types/ClassLike.hpp:116
static bool classof(const Type *type)
Definition DWARF/types/ClassLike.hpp:120
This class represents a DWARF packed type (DW_TAG_packed_type).
Definition DWARF/types/ClassLike.hpp:140
static bool classof(const Type *type)
Definition DWARF/types/ClassLike.hpp:144
This class represents a DWARF struct type (DW_TAG_structure_type).
Definition DWARF/types/ClassLike.hpp:104
static bool classof(const Type *type)
Definition DWARF/types/ClassLike.hpp:108
This class represents a DWARF class type (DW_TAG_union_type).
Definition DWARF/types/ClassLike.hpp:128
static bool classof(const Type *type)
Definition DWARF/types/ClassLike.hpp:132
Definition iterators.hpp:486
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:75
Definition DWARF/types/ClassLike.hpp:26
Definition DWARF/types/Array.hpp:23
Namespace for the DWARF debug format.
Definition DWARF/CompilationUnit.hpp:28
LIEF namespace.
Definition Abstract/Binary.hpp:40
#define LIEF_API
Definition visibility.h:41