LIEF: Library to Instrument Executable Formats Version 1.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 <memory>
18#include <string>
19
20#include "LIEF/visibility.h"
22
27
28namespace LIEF {
29namespace dwarf {
30namespace editor {
31class Function;
32class Variable;
33class Type;
34class EnumType;
35class TypeDef;
36class ArrayType;
37
38namespace details {
39class CompilationUnit;
40}
41
44 public:
45 CompilationUnit() = delete;
46 CompilationUnit(std::unique_ptr<details::CompilationUnit> impl);
47
52 CompilationUnit& set_producer(const std::string& producer) LIEF_LIFETIMEBOUND;
53
55 std::unique_ptr<Function>
56 create_function(const std::string& name) LIEF_LIFETIMEBOUND;
57
59 std::unique_ptr<Variable>
60 create_variable(const std::string& name) LIEF_LIFETIMEBOUND;
61
63 std::unique_ptr<Type>
64 create_generic_type(const std::string& name) LIEF_LIFETIMEBOUND;
65
67 std::unique_ptr<EnumType>
68 create_enum(const std::string& name) LIEF_LIFETIMEBOUND;
69
72 std::unique_ptr<TypeDef> create_typedef(const std::string& name,
73 const Type& type) LIEF_LIFETIMEBOUND;
74
76 std::unique_ptr<StructType> create_structure(
77 const std::string& name, StructType::TYPE kind = StructType::TYPE::STRUCT
79
81 std::unique_ptr<BaseType> create_base_type(
82 const std::string& name, size_t size,
85
87 std::unique_ptr<FunctionType>
88 create_function_type(const std::string& name) LIEF_LIFETIMEBOUND;
89
91 std::unique_ptr<PointerType>
93 return ty.pointer_to();
94 }
95
97 std::unique_ptr<Type> create_void_type() LIEF_LIFETIMEBOUND;
98
100 std::unique_ptr<ArrayType> create_array(const std::string& name,
101 const Type& type,
102 size_t count) LIEF_LIFETIMEBOUND;
103
105
106 private:
107 std::unique_ptr<details::CompilationUnit> impl_;
108};
109
110}
111}
112}
113#endif
This class represents an array type (DW_TAG_array_type).
Definition ArrayType.hpp:26
ENCODING
Definition BaseType.hpp:35
@ NONE
Definition BaseType.hpp:36
This class represents an editable DWARF compilation unit.
Definition DWARF/editor/CompilationUnit.hpp:43
std::unique_ptr< Function > create_function(const std::string &name)
Create a new function owned by this compilation unit.
std::unique_ptr< TypeDef > create_typedef(const std::string &name, const Type &type)
Create a typedef with the name provided in the first parameter which aliases the type provided in the...
CompilationUnit(std::unique_ptr< details::CompilationUnit > impl)
std::unique_ptr< PointerType > create_pointer_type(const Type &ty)
Create a pointer on the provided type.
Definition DWARF/editor/CompilationUnit.hpp:92
std::unique_ptr< Type > create_generic_type(const std::string &name)
Create a DW_TAG_unspecified_type type with the given name.
std::unique_ptr< FunctionType > create_function_type(const std::string &name)
Create a function type with the given name.
std::unique_ptr< Variable > create_variable(const std::string &name)
Create a new global variable owned by this compilation unit.
std::unique_ptr< StructType > create_structure(const std::string &name, StructType::TYPE kind=StructType::TYPE::STRUCT)
Create a struct-like type (struct, class, union) with the given name.
CompilationUnit & set_producer(const std::string &producer)
Set the DW_AT_producer producer attribute.
std::unique_ptr< Type > create_void_type()
Create a void type.
std::unique_ptr< BaseType > create_base_type(const std::string &name, size_t size, BaseType::ENCODING encoding=BaseType::ENCODING::NONE)
Create a primitive type with the given name and size.
std::unique_ptr< EnumType > create_enum(const std::string &name)
Create an enum type (DW_TAG_enumeration_type).
std::unique_ptr< ArrayType > create_array(const std::string &name, const Type &type, size_t count)
Create an array type with the given name, type and size.
This class represents an editable enum type (DW_TAG_enumeration_type).
Definition EnumType.hpp:33
This class represents an editable DWARF function (DW_TAG_subprogram).
Definition DWARF/editor/Function.hpp:39
TYPE
Definition StructType.hpp:46
@ STRUCT
Discriminant for DW_TAG_class_type.
Definition StructType.hpp:48
This class represents a typedef (DW_TAG_typedef).
Definition TypeDef.hpp:26
This class is the base class for any types created when editing DWARF debug info.
Definition DWARF/editor/Type.hpp:37
This class represents an editable DWARF variable which can be scoped by a function or a compilation u...
Definition editor/Variable.hpp:35
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition DWARF/editor/CompilationUnit.hpp:38
Definition Editor.hpp:32
Namespace for the DWARF debug format.
Definition DWARF/CompilationUnit.hpp:30
LIEF namespace.
Definition Abstract/Binary.hpp:41
#define LIEF_API
Definition visibility.h:45