LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
PDB/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_PDB_INFO_H
16#define LIEF_PDB_INFO_H
17#include <memory>
18#include <string>
19#include <ostream>
20
21#include "LIEF/iterators.hpp"
23
26#include "LIEF/PDB/Type.hpp"
27
28#include "LIEF/visibility.h"
29
30namespace LIEF {
31namespace pdb {
32class Function;
33
38 public:
40
43
46
49
52 static std::unique_ptr<DebugInfo> from_file(const std::string& pdb_path);
53
54 FORMAT format() const override {
56 }
57
58 static bool classof(const LIEF::DebugInfo* info) {
59 return info->format() == LIEF::DebugInfo::FORMAT::PDB;
60 }
61
65
68
70 types_it types() const;
71
73 std::unique_ptr<Type> find_type(const std::string& name) const;
74
76 std::unique_ptr<Type> find_type(uint32_t index) const;
77
88 std::unique_ptr<PublicSymbol> find_public_symbol(const std::string& name) const;
89
91 optional<uint64_t> find_function_address(const std::string& name) const override;
92
94 uint32_t age() const;
95
97 std::string guid() const;
98
100 std::string to_string() const;
101
102 friend LIEF_API
103 std::ostream& operator<<(std::ostream& os, const DebugInfo& dbg)
104 {
105 os << dbg.to_string();
106 return os;
107 }
108
109 ~DebugInfo() override = default;
110};
111
112
114inline std::unique_ptr<DebugInfo> load(const std::string& pdb_path) {
115 return DebugInfo::from_file(pdb_path);
116}
117
118}
119}
120#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
@ PDB
Definition Abstract/DebugInfo.hpp:43
Definition iterators.hpp:486
Definition optional.hpp:23
std::string to_string() const
Pretty representation.
uint32_t age() const
The number of times the PDB file has been written.
iterator_range< Type::Iterator > types_it
Iterator over the PDB's types.
Definition PDB/DebugInfo.hpp:48
DebugInfo(std::unique_ptr< details::DebugInfo > impl)
iterator_range< PublicSymbol::Iterator > public_symbols_it
Iterator over the symbols located in the PDB public symbol stream.
Definition PDB/DebugInfo.hpp:45
compilation_units_it compilation_units() const
Iterator over the CompilationUnit from the PDB's DBI stream. CompilationUnit are also named "Module" ...
~DebugInfo() override=default
static bool classof(const LIEF::DebugInfo *info)
Definition PDB/DebugInfo.hpp:58
iterator_range< CompilationUnit::Iterator > compilation_units_it
Iterator over the CompilationUnit.
Definition PDB/DebugInfo.hpp:42
FORMAT format() const override
Definition PDB/DebugInfo.hpp:54
friend std::ostream & operator<<(std::ostream &os, const DebugInfo &dbg)
Definition PDB/DebugInfo.hpp:103
public_symbols_it public_symbols() const
Return an iterator over the public symbol stream.
std::unique_ptr< Type > find_type(const std::string &name) const
Find the type with the given name.
optional< uint64_t > find_function_address(const std::string &name) const override
Attempt to resolve the address of the function specified by name.
std::unique_ptr< PublicSymbol > find_public_symbol(const std::string &name) const
Try to find the PublicSymbol from the given name (based on the public symbol stream).
static std::unique_ptr< DebugInfo > from_file(const std::string &pdb_path)
Instantiate this class from the given PDB file. It returns a nullptr if the PDB can't be processed.
types_it types() const
Return an iterator over the different types registered in this PDB.
std::string guid() const
Unique identifier of the PDB file.
std::unique_ptr< Type > find_type(uint32_t index) const
Find the type with at the given index.
Definition PDB/Function.hpp:32
Definition BuildMetadata.hpp:24
std::unique_ptr< DebugInfo > load(const std::string &pdb_path)
Load the PDB file from the given path.
Definition PDB/DebugInfo.hpp:114
LIEF namespace.
Definition Abstract/Binary.hpp:40
#define LIEF_API
Definition visibility.h:41