LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
DWARF/types/ClassLike.hpp
Go to the documentation of this file.
1/* Copyright 2022 - 2024 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}
29class LIEF_API ClassLike : public Type {
33 public:
34 using Type::Type;
35 class Member {
38 public:
39 Member(std::unique_ptr<details::Member> impl);
40 Member(Member&& other) noexcept;
41 Member& operator=(Member&& other) noexcept;
42 std::string name() const;
45 result<uint64_t> offset() const;
50 result<uint64_t> bit_offset() const;
67 std::unique_ptr<Type> type() const;
70
71
72
73 bool is_external() const;
74
75 bool is_declaration() const;
76
78 private:
79 std::unique_ptr<details::Member> impl_;
80 };
81
82 using functions_it = iterator_range<Function::Iterator>;
83
84 static bool classof(const Type* type) {
85 const auto kind = type->kind();
86 return kind == Type::KIND::CLASS || kind == Type::KIND::STRUCT || kind == Type::KIND::UNION;
87 }
88 std::vector<Member> members() const;
91 std::unique_ptr<Member> find_member(uint64_t offset) const;
94 functions_it functions() const;
97
98 ~ClassLike() override;
99};
100class LIEF_API Structure : public ClassLike {
103 public:
104 using ClassLike::ClassLike;
105
106 static bool classof(const Type* type) {
107 return type->kind() == Type::KIND::STRUCT;
108 }
109
110 ~Structure() override;
111};
112class LIEF_API Class : public ClassLike {
115 public:
116 using ClassLike::ClassLike;
117
118 static bool classof(const Type* type) {
119 return type->kind() == Type::KIND::CLASS;
120 }
121
122 ~Class() override;
123};
124class LIEF_API Union : public ClassLike {
127 public:
128 using ClassLike::ClassLike;
129
130 static bool classof(const Type* type) {
131 return type->kind() == Type::KIND::UNION;
132 }
133
134 ~Union() override;
135};
136class LIEF_API Packed : public ClassLike {
139 public:
140 using ClassLike::ClassLike;
141
142 static bool classof(const Type* type) {
143 return type->kind() == Type::KIND::PACKED;
144 }
145
146 ~Packed() override;
147};
148
149}
150}
151}
152#endif
153
154
Function.hpp
Type.hpp
LIEF::dwarf::Type::kind
KIND kind() const
LIEF::dwarf::types::ClassLike::Member::Member
Member(std::unique_ptr< details::Member > impl)
LIEF::dwarf::types::ClassLike::Member::~Member
~Member()
LIEF::dwarf::types::ClassLike::Member::type
std::unique_ptr< Type > type() const
Type of the current member.
LIEF::dwarf::types::ClassLike::Member::operator=
Member & operator=(Member &&other) noexcept
LIEF::dwarf::types::ClassLike::Member::is_external
bool is_external() const
LIEF::dwarf::types::ClassLike::Member::Member
Member(Member &&other) noexcept
LIEF::dwarf::types::ClassLike::Member::name
std::string name() const
Name of the member.
LIEF::dwarf::types::ClassLike::Member::is_declaration
bool is_declaration() const
LIEF::dwarf::types::ClassLike::Member::offset
result< uint64_t > offset() const
Offset of the current member in the struct/union/class.
LIEF::dwarf::types::ClassLike::Member::bit_offset
result< uint64_t > bit_offset() const
Offset of the current member in bits the struct/union/class.
LIEF::dwarf::types::ClassLike
This class abstracts a DWARF aggregate: DW_TAG_structure_type, DW_TAG_class_type, DW_TAG_union_type.
Definition DWARF/types/ClassLike.hpp:32
LIEF::dwarf::types::ClassLike::functions
functions_it functions() const
Iterator over the functions defined by the class-like.
LIEF::dwarf::types::ClassLike::members
std::vector< Member > members() const
Return the list of all the attributes defined in this class-like type.
LIEF::dwarf::types::ClassLike::find_member
std::unique_ptr< Member > find_member(uint64_t offset) const
Try to find the attribute at the given offset.
LIEF::dwarf::types::ClassLike::~ClassLike
~ClassLike() override
LIEF::dwarf::types::ClassLike::classof
static bool classof(const Type *type)
Definition DWARF/types/ClassLike.hpp:84
LIEF::dwarf::types::Class
This class represents a DWARF class type (DW_TAG_class_type)
Definition DWARF/types/ClassLike.hpp:114
LIEF::dwarf::types::Class::~Class
~Class() override
LIEF::dwarf::types::Class::classof
static bool classof(const Type *type)
Definition DWARF/types/ClassLike.hpp:118
LIEF::dwarf::types::Packed
This class represents a DWARF packed type (DW_TAG_packed_type)
Definition DWARF/types/ClassLike.hpp:138
LIEF::dwarf::types::Packed::classof
static bool classof(const Type *type)
Definition DWARF/types/ClassLike.hpp:142
LIEF::dwarf::types::Packed::~Packed
~Packed() override
LIEF::dwarf::types::Structure
This class represents a DWARF struct type (DW_TAG_structure_type)
Definition DWARF/types/ClassLike.hpp:102
LIEF::dwarf::types::Structure::~Structure
~Structure() override
LIEF::dwarf::types::Structure::classof
static bool classof(const Type *type)
Definition DWARF/types/ClassLike.hpp:106
LIEF::dwarf::types::Union
This class represents a DWARF class type (DW_TAG_union_type)
Definition DWARF/types/ClassLike.hpp:126
LIEF::dwarf::types::Union::~Union
~Union() override
LIEF::dwarf::types::Union::classof
static bool classof(const Type *type)
Definition DWARF/types/ClassLike.hpp:130
LIEF::dwarf::types::details
Definition DWARF/types/ClassLike.hpp:26
LIEF::dwarf::types
Definition DWARF/types/Array.hpp:23
LIEF::dwarf
Namespace for the DWARF debug format.
Definition DWARF/CompilationUnit.hpp:28
LIEF
LIEF namespace.
Definition Abstract/Binary.hpp:36
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41