LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
Abstract/DebugInfo.hpp
Go to the documentation of this file.
1/* Copyright 2022 - 2025 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 {
44 };
45 DebugInfo(std::unique_ptr<details::DebugInfo> impl);
46
47 virtual ~DebugInfo();
48
49 virtual FORMAT format() const {
50 return FORMAT::UNKNOWN;
51 }
52
61 template<class T>
62 const T* as() const {
63 static_assert(std::is_base_of<DebugInfo, T>::value,
64 "Require Instruction inheritance");
65 if (T::classof(this)) {
66 return static_cast<const T*>(this);
67 }
68 return nullptr;
69 }
70
72 virtual optional<uint64_t> find_function_address(const std::string& name) const = 0;
73
74 protected:
75 std::unique_ptr<details::DebugInfo> impl_;
76};
77
78}
79#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
@ PDB
Definition Abstract/DebugInfo.hpp:43
@ UNKNOWN
Definition Abstract/DebugInfo.hpp:42
@ DWARF
Definition Abstract/DebugInfo.hpp:43
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:62
virtual FORMAT format() const
Definition Abstract/DebugInfo.hpp:49
Definition optional.hpp:23
Definition Abstract/DebugInfo.hpp:27
LIEF namespace.
Definition Abstract/Binary.hpp:40
#define LIEF_API
Definition visibility.h:41