LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
DWARF/editor/CompilationUnit.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_EDITOR_COMPILATION_UNIT_H
16#define LIEF_DWARF_EDITOR_COMPILATION_UNIT_H
17#include <string_view>
18#include <memory>
19
21#include "LIEF/visibility.h"
22
27
28
29namespace LIEF::dwarf::editor {
30class Function;
31class Variable;
32class Type;
33class EnumType;
34class TypeDef;
35class ArrayType;
36
37namespace details {
38class CompilationUnit;
39}
40
43 public:
44 CompilationUnit() = delete;
45 CompilationUnit(std::unique_ptr<details::CompilationUnit> impl);
46
51 CompilationUnit& set_producer(std::string_view producer) LIEF_LIFETIMEBOUND;
52
54 std::unique_ptr<Function>
55 create_function(std::string_view name) LIEF_LIFETIMEBOUND;
56
58 std::unique_ptr<Variable>
59 create_variable(std::string_view name) LIEF_LIFETIMEBOUND;
60
62 std::unique_ptr<Type>
64
66 std::unique_ptr<EnumType> create_enum(std::string_view name) LIEF_LIFETIMEBOUND;
67
70 std::unique_ptr<TypeDef> create_typedef(std::string_view name,
71 const Type& type) LIEF_LIFETIMEBOUND;
72
74 std::unique_ptr<StructType> create_structure(
75 std::string_view name, StructType::TYPE kind = StructType::TYPE::STRUCT
77
79 std::unique_ptr<BaseType> create_base_type(
80 std::string_view name, size_t size,
83
85 std::unique_ptr<FunctionType>
87
89 std::unique_ptr<PointerType>
91 return ty.pointer_to();
92 }
93
98 std::unique_ptr<Type> create_const_type(const Type& ty) LIEF_LIFETIMEBOUND;
99
104 std::unique_ptr<Type> create_volatile_type(const Type& ty) LIEF_LIFETIMEBOUND;
105
107 std::unique_ptr<Type> create_void_type() LIEF_LIFETIMEBOUND;
108
110 std::unique_ptr<ArrayType> create_array(std::string_view name, const Type& type,
111 size_t count) LIEF_LIFETIMEBOUND;
112
114
115 private:
116 std::unique_ptr<details::CompilationUnit> impl_;
117};
118
119}
120
121
122#endif
This class represents an array type (DW_TAG_array_type).
Definition ArrayType.hpp:25
ENCODING
Definition BaseType.hpp:33
@ NONE
Definition BaseType.hpp:34
This class represents an editable DWARF compilation unit.
Definition DWARF/editor/CompilationUnit.hpp:42
std::unique_ptr< Variable > create_variable(std::string_view name)
Create a new global variable owned by this compilation unit.
std::unique_ptr< ArrayType > create_array(std::string_view name, const Type &type, size_t count)
Create an array type with the given name, type and size.
CompilationUnit(std::unique_ptr< details::CompilationUnit > impl)
std::unique_ptr< TypeDef > create_typedef(std::string_view name, const Type &type)
Create a typedef with the name provided in the first parameter which aliases the type provided in the...
std::unique_ptr< PointerType > create_pointer_type(const Type &ty)
Create a pointer on the provided type.
Definition DWARF/editor/CompilationUnit.hpp:90
std::unique_ptr< StructType > create_structure(std::string_view name, StructType::TYPE kind=StructType::TYPE::STRUCT)
Create a struct-like type (struct, class, union) with the given name.
std::unique_ptr< BaseType > create_base_type(std::string_view name, size_t size, BaseType::ENCODING encoding=BaseType::ENCODING::NONE)
Create a primitive type with the given name and size.
CompilationUnit & set_producer(std::string_view producer)
Set the DW_AT_producer producer attribute.
std::unique_ptr< Type > create_generic_type(std::string_view name)
Create a DW_TAG_unspecified_type type with the given name.
std::unique_ptr< FunctionType > create_function_type(std::string_view name)
Create a function type with the given name.
std::unique_ptr< EnumType > create_enum(std::string_view name)
Create an enum type (DW_TAG_enumeration_type).
std::unique_ptr< Type > create_volatile_type(const Type &ty)
Create a volatile-qualified version of the provided type (DW_TAG_volatile_type).
std::unique_ptr< Type > create_void_type()
Create a void type.
std::unique_ptr< Function > create_function(std::string_view name)
Create a new function owned by this compilation unit.
std::unique_ptr< Type > create_const_type(const Type &ty)
Create a const-qualified version of the provided type (DW_TAG_const_type).
This class represents an editable enum type (DW_TAG_enumeration_type).
Definition EnumType.hpp:32
This class represents an editable DWARF function (DW_TAG_subprogram).
Definition DWARF/editor/Function.hpp:42
TYPE
Definition StructType.hpp:44
@ STRUCT
Discriminant for DW_TAG_class_type.
Definition StructType.hpp:46
This class represents a typedef (DW_TAG_typedef).
Definition TypeDef.hpp:25
This class is the base class for any types created when editing DWARF debug info.
Definition DWARF/editor/Type.hpp:36
This class represents an editable DWARF variable which can be scoped by a function or a compilation u...
Definition editor/Variable.hpp:38
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition DWARF/editor/CompilationUnit.hpp:37
Definition Editor.hpp:32
#define LIEF_API
Definition visibility.h:45