LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
DWARF/DebugInfo.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_INFO_H
16#define LIEF_DWARF_INFO_H
17#include <memory>
18#include <string>
19
21#include "LIEF/iterators.hpp"
24
25#include "LIEF/visibility.h"
26
27namespace LIEF {
29namespace dwarf {
30class Function;
31class Variable;
32
38 public:
40
41 static std::unique_ptr<DebugInfo> from_file(const std::string& path);
42
45
57 std::unique_ptr<Function>
58 find_function(const std::string& name) const LIEF_LIFETIMEBOUND;
59
61 std::unique_ptr<Function> find_function(uint64_t addr) const LIEF_LIFETIMEBOUND;
62
65 std::unique_ptr<Variable>
66 find_variable(const std::string& name) const LIEF_LIFETIMEBOUND;
67
69 std::unique_ptr<Variable> find_variable(uint64_t addr) const LIEF_LIFETIMEBOUND;
70
72 std::unique_ptr<Type>
73 find_type(const std::string& name) const LIEF_LIFETIMEBOUND;
74
77
79 optional<uint64_t> find_function_address(const std::string& name) const override;
80
81 FORMAT format() const override {
83 }
84
85 static bool classof(const LIEF::DebugInfo* info) {
86 return info->format() == LIEF::DebugInfo::FORMAT::DWARF;
87 }
88
89 ~DebugInfo() override = default;
90};
91
92
94inline std::unique_ptr<DebugInfo> load(const std::string& dwarf_path) {
95 return DebugInfo::from_file(dwarf_path);
96}
97
98}
99}
100#endif
This class provides a generic interface for accessing debug information from different formats such a...
Definition Abstract/DebugInfo.hpp:38
DebugInfo(std::unique_ptr< details::DebugInfo > impl)
FORMAT
Definition Abstract/DebugInfo.hpp:41
@ DWARF
Definition Abstract/DebugInfo.hpp:43
DebugInfo(std::unique_ptr< details::DebugInfo > impl)
optional< uint64_t > find_function_address(const std::string &name) const override
Attempt to resolve the address of the function specified by name.
static std::unique_ptr< DebugInfo > from_file(const std::string &path)
compilation_units_it compilation_units() const
Iterator on the CompilationUnit embedded in this dwarf.
FORMAT format() const override
Definition DWARF/DebugInfo.hpp:81
std::unique_ptr< Type > find_type(const std::string &name) const
Try to find the type with the given name.
std::unique_ptr< Function > find_function(uint64_t addr) const
Try to find the function at the given virtual address.
std::unique_ptr< Function > find_function(const std::string &name) const
Try to find the function with the given name (mangled or not).
iterator_range< CompilationUnit::Iterator > compilation_units_it
Iterator over the CompilationUnit.
Definition DWARF/DebugInfo.hpp:44
static bool classof(const LIEF::DebugInfo *info)
Definition DWARF/DebugInfo.hpp:85
std::unique_ptr< Variable > find_variable(const std::string &name) const
Try to find the variable with the given name. This name can be mangled or not.
std::unique_ptr< Variable > find_variable(uint64_t addr) const
Try to find the variable at the given virtual address.
~DebugInfo() override=default
This class represents a DWARF function which can be associated with either: DW_TAG_subprogram or DW_T...
Definition DWARF/Function.hpp:45
This class represents a DWARF variable which can be owned by a dwarf::Function or a dwarf::Compilatio...
Definition Variable.hpp:38
Definition iterators.hpp:601
Definition optional.hpp:23
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Namespace for the DWARF debug format.
Definition DWARF/CompilationUnit.hpp:30
std::unique_ptr< DebugInfo > load(const std::string &dwarf_path)
Load DWARF file from the given path.
Definition DWARF/DebugInfo.hpp:94
LIEF namespace.
Definition Abstract/Binary.hpp:41
#define LIEF_API
Definition visibility.h:45