LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
PDB/Function.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_FUNCTION_H
16#define LIEF_PDB_FUNCTION_H
17#include <memory>
18#include <string>
19#include <ostream>
20
21#include "LIEF/visibility.h"
22#include "LIEF/debug_loc.hpp"
23
24namespace LIEF {
25namespace pdb {
26
27namespace details {
28class Function;
29class FunctionIt;
30}
31
33 public:
35 public:
36 using iterator_category = std::forward_iterator_tag;
37 using value_type = std::unique_ptr<Function>;
38 using difference_type = std::ptrdiff_t;
39 using pointer = Function*;
41 using implementation = details::FunctionIt;
42
43 class LIEF_API PointerProxy {
44 // Inspired from LLVM's iterator_facade_base
45 friend class Iterator;
46
47 public:
49 return R.get();
50 }
51
52 private:
53 value_type R;
54
55 template<typename RefT>
56 PointerProxy(RefT&& R) :
57 R(std::forward<RefT>(R)) {
58 } // NOLINT(bugprone-forwarding-reference-overload)
59 };
60
63 Iterator(std::unique_ptr<details::FunctionIt> impl);
65
66 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
67 friend LIEF_API bool operator!=(const Iterator& LHS, const Iterator& RHS) {
68 return !(LHS == RHS);
69 }
70
72
74 Iterator tmp = *static_cast<Iterator*>(this);
75 ++*static_cast<Iterator*>(this);
76 return tmp;
77 }
78
79 std::unique_ptr<Function> operator*() const;
80
82 return static_cast<const Iterator*>(this)->operator*();
83 }
84
85 private:
86 std::unique_ptr<details::FunctionIt> impl_;
87 };
88 Function(std::unique_ptr<details::Function> impl);
90
92 std::string name() const;
93
95 uint32_t RVA() const;
96
98 uint32_t code_size() const;
99
101 std::string section_name() const;
102
105
106 std::string to_string() const;
107
108 LIEF_API friend std::ostream& operator<<(std::ostream& os, const Function& F) {
109 os << F.to_string();
110 return os;
111 }
112
113 private:
114 std::unique_ptr<details::Function> impl_;
115};
116
117}
118}
119#endif
Definition PDB/Function.hpp:43
pointer operator->() const
Definition PDB/Function.hpp:48
friend class Iterator
Definition PDB/Function.hpp:45
std::unique_ptr< Function > value_type
Definition PDB/Function.hpp:37
Iterator operator++(int)
Definition PDB/Function.hpp:73
friend bool operator==(const Iterator &LHS, const Iterator &RHS)
std::forward_iterator_tag iterator_category
Definition PDB/Function.hpp:36
details::FunctionIt implementation
Definition PDB/Function.hpp:41
Function & reference
Definition PDB/Function.hpp:40
Iterator(const Iterator &)
std::unique_ptr< Function > operator*() const
PointerProxy operator->() const
Definition PDB/Function.hpp:81
std::ptrdiff_t difference_type
Definition PDB/Function.hpp:38
Function * pointer
Definition PDB/Function.hpp:39
friend bool operator!=(const Iterator &LHS, const Iterator &RHS)
Definition PDB/Function.hpp:67
Iterator(std::unique_ptr< details::FunctionIt > impl)
std::string section_name() const
The name of the section in which this function is defined.
friend std::ostream & operator<<(std::ostream &os, const Function &F)
Definition PDB/Function.hpp:108
uint32_t code_size() const
The size of the function.
Function(std::unique_ptr< details::Function > impl)
std::string name() const
The name of the function (this name is usually demangled).
debug_location_t debug_location() const
Original source code location.
uint32_t RVA() const
The Relative Virtual Address of the function.
std::string to_string() const
Definition BuildMetadata.hpp:26
Definition BuildMetadata.hpp:24
LIEF namespace.
Definition Abstract/Binary.hpp:40
Definition string.h:155
This structure holds a debug location (source filename & line).
Definition debug_loc.hpp:23
#define LIEF_API
Definition visibility.h:43