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
22#include "LIEF/iterators.hpp"
23#include "LIEF/visibility.h"
24#include "LIEF/debug_loc.hpp"
25#include "LIEF/DebugDeclOpt.hpp"
26
27namespace LIEF {
28namespace pdb {
29
30namespace details {
31class Function;
32class FunctionIt;
33}
34
36 public:
37 class Iterator final
38 : public iterator_facade_base<Iterator, std::forward_iterator_tag, Function,
39 std::ptrdiff_t, const Function*,
40 const Function&> {
41 public:
42 using implementation = details::FunctionIt;
43 using iterator_facade_base::operator++;
44
46
47 LIEF_API Iterator(std::unique_ptr<details::FunctionIt> impl);
48
51
53 LIEF_API Iterator& operator=(Iterator&&) noexcept;
54
56
57 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
58 friend bool operator!=(const Iterator& LHS, const Iterator& RHS) {
59 return !(LHS == RHS);
60 }
61
62 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
64
66
67 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
68 LIEF_API const Function* operator->() const LIEF_LIFETIMEBOUND;
69
72 LIEF_API std::unique_ptr<Function> yield();
73
74 private:
75 void load() const;
76
77 std::unique_ptr<details::FunctionIt> impl_;
78 mutable std::unique_ptr<Function> cached_;
79 };
80 Function(std::unique_ptr<details::Function> impl);
82
84 std::string name() const;
85
87 uint32_t RVA() const;
88
90 uint32_t code_size() const;
91
93 std::string section_name() const;
94
97
99 std::string to_decl(const DeclOpt& opt = DeclOpt()) const;
100
101 std::string to_string() const;
102
103 LIEF_API friend std::ostream& operator<<(std::ostream& os, const Function& F) {
104 os << F.to_string();
105 return os;
106 }
107
108 private:
109 std::unique_ptr<details::Function> impl_;
110};
111
112}
113}
114#endif
Configuration options for generated code from debug info.
Definition DebugDeclOpt.hpp:36
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition iterators.hpp:729
Iterator(Iterator &&) noexcept
std::unique_ptr< Function > yield()
Transfer ownership of the function at the current position to the caller. Returns nullptr if the iter...
details::FunctionIt implementation
Definition PDB/Function.hpp:42
Iterator(const Iterator &)
const Function & operator*() const
Iterator & operator=(const Iterator &)
Iterator(std::unique_ptr< details::FunctionIt > impl)
std::string section_name() const
The name of the section in which this function is defined.
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_decl(const DeclOpt &opt=DeclOpt()) const
Generate a C/C++ definition for this function.
std::string to_string() const
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition BuildMetadata.hpp:27
Definition BuildMetadata.hpp:25
LIEF namespace.
Definition Abstract/Binary.hpp:41
This structure holds a debug location (source filename & line).
Definition debug_loc.hpp:23
#define LIEF_API
Definition visibility.h:45