LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
Abstract/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_DEBUGINFO_H
16#define LIEF_DEBUGINFO_H
17#include <memory>
18#include <cstdint>
19#include <string>
20
21#include "LIEF/visibility.h"
22#include "LIEF/optional.hpp"
23namespace LIEF {
24
25class Binary;
26
27namespace details {
28class DebugInfo;
29}
30
39 public:
40 friend class Binary;
41 enum class FORMAT {
42 UNKNOWN = 0,
43 DWARF,
44 PDB,
45 };
46 DebugInfo(std::unique_ptr<details::DebugInfo> impl);
47
48 virtual ~DebugInfo();
49
50 virtual FORMAT format() const {
51 return FORMAT::UNKNOWN;
52 }
53
62 template<class T>
63 const T* as() const {
64 static_assert(std::is_base_of<DebugInfo, T>::value,
65 "Require Instruction inheritance");
66 if (T::classof(this)) {
67 return static_cast<const T*>(this);
68 }
69 return nullptr;
70 }
71
73 virtual optional<uint64_t>
74 find_function_address(const std::string& name) const = 0;
75
76 protected:
77 std::unique_ptr<details::DebugInfo> impl_;
78};
79
80}
81#endif
Generic interface representing a binary executable.
Definition Abstract/Binary.hpp:59
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)
virtual ~DebugInfo()
virtual optional< uint64_t > find_function_address(const std::string &name) const =0
Attempt to resolve the address of the function specified by name.
FORMAT
Definition Abstract/DebugInfo.hpp:41
@ UNKNOWN
Definition Abstract/DebugInfo.hpp:42
friend class Binary
Definition Abstract/DebugInfo.hpp:40
const T * as() const
This function can be used to down cast a DebugInfo instance:
Definition Abstract/DebugInfo.hpp:63
virtual FORMAT format() const
Definition Abstract/DebugInfo.hpp:50
Definition optional.hpp:23
Definition Abstract/DebugInfo.hpp:27
LIEF namespace.
Definition Abstract/Binary.hpp:40
#define LIEF_API
Definition visibility.h:43