LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
Parameter.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_PARAMETER_H
16#define LIEF_DWARF_PARAMETER_H
17
20#include "LIEF/visibility.h"
21
22#include <string_view>
23#include <cstdint>
24#include <memory>
25#include <vector>
26
27
28namespace LIEF::dwarf {
29
30class Type;
31
32namespace details {
33class Parameter;
34}
35
41 public:
42 enum class KIND {
43 UNKNOWN = 0,
44 TEMPLATE_TYPE,
45 TEMPLATE_VALUE,
46 FORMAL,
47 };
48
51
54
58
59 Parameter() = delete;
60 Parameter(Parameter&& other) noexcept;
61 Parameter& operator=(Parameter&& other) noexcept;
62 Parameter& operator=(const Parameter&) = delete;
63 Parameter(const Parameter&) = delete;
64
65
66 KIND kind() const;
67
69 std::string_view name() const LIEF_LIFETIMEBOUND;
70
72 std::unique_ptr<Type> type() const LIEF_LIFETIMEBOUND;
73
76 std::unique_ptr<Location> location() const;
77
80 std::unique_ptr<Location> location(uint64_t pc) const;
81
83 std::vector<LocationEntry> locations() const;
84
85 template<class T>
86 const T* as() const {
87 if (T::classof(this)) {
88 return static_cast<const T*>(this);
89 }
90 return nullptr;
91 }
92
93 virtual ~Parameter();
94
95 LIEF_LOCAL static std::unique_ptr<Parameter>
96 create(std::unique_ptr<details::Parameter> impl);
97
98 protected:
99 Parameter(std::unique_ptr<details::Parameter> impl);
100 std::unique_ptr<details::Parameter> impl_;
101};
102
103namespace parameters {
104
118class LIEF_API Formal : public Parameter {
119 public:
121 static bool classof(const Parameter* P) {
122 return P->kind() == Parameter::KIND::FORMAL;
123 }
124
125 ~Formal() override = default;
126};
127
128
140 public:
142 static bool classof(const Parameter* P) {
143 return P->kind() == Parameter::KIND::TEMPLATE_VALUE;
144 }
145
146 ~TemplateValue() override = default;
147};
148
160 public:
162 static bool classof(const Parameter* P) {
163 return P->kind() == Parameter::KIND::TEMPLATE_TYPE;
164 }
165
166 ~TemplateType() override = default;
167};
168
169}
170
171}
172
173#endif
The value is split into several pieces (DW_OP_piece/DW_OP_bit_piece), each one with its own location.
Definition Location.hpp:204
This class represents where the value of a variable or a parameter lives. It interfaces the DWARF loc...
Definition Location.hpp:33
dwarf::RegisterLoc RegisterLoc
Register location of a parameter (see: dwarf::RegisterLoc).
Definition Parameter.hpp:53
std::vector< LocationEntry > locations() const
All the location entries of this parameter.
Parameter(Parameter &&other) noexcept
dwarf::CompositeLocation CompositeLocation
Location of a parameter split across several pieces (see: dwarf::CompositeLocation).
Definition Parameter.hpp:57
KIND
Definition Parameter.hpp:42
@ TEMPLATE_VALUE
DW_TAG_template_value_parameter.
Definition Parameter.hpp:45
@ TEMPLATE_TYPE
DW_TAG_template_type_parameter.
Definition Parameter.hpp:44
@ FORMAL
DW_TAG_formal_parameter.
Definition Parameter.hpp:46
dwarf::Location Location
Location of a parameter (see: dwarf::Location).
Definition Parameter.hpp:50
static std::unique_ptr< Parameter > create(std::unique_ptr< details::Parameter > impl)
std::unique_ptr< Type > type() const
Type of this parameter.
Parameter(const Parameter &)=delete
Parameter & operator=(Parameter &&other) noexcept
std::unique_ptr< Location > location() const
Location of this parameter. For instance it can be a specific register that is not following the call...
std::string_view name() const
Name of the parameter.
const T * as() const
Definition Parameter.hpp:86
Parameter & operator=(const Parameter &)=delete
The value is associated to a register (e.g. DW_OP_reg5).
Definition Location.hpp:90
This class represents a DWARF Type which includes:
Definition DWARF/Type.hpp:68
This class represents a regular function parameter.
Definition Parameter.hpp:118
static bool classof(const Parameter *P)
Definition Parameter.hpp:121
This class represents a template type parameter.
Definition Parameter.hpp:159
static bool classof(const Parameter *P)
Definition Parameter.hpp:162
This class represents a template value parameter.
Definition Parameter.hpp:139
static bool classof(const Parameter *P)
Definition Parameter.hpp:142
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition DWARF/CompilationUnit.hpp:33
Definition Parameter.hpp:103
Namespace for the DWARF debug format.
Definition DWARF/CompilationUnit.hpp:31
Location associated with the range of addresses where it is valid.
Definition Location.hpp:250
#define LIEF_API
Definition visibility.h:45
#define LIEF_LOCAL
Definition visibility.h:46