LIEF: Library to Instrument Executable Formats
Version 2.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
lief-install
x86_64
static
include
LIEF
DWARF
LexicalBlock.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_DWARF_LEXICAL_BLOCK_H
16
#define LIEF_DWARF_LEXICAL_BLOCK_H
17
18
#include "
LIEF/compiler_attributes.hpp
"
19
#include "
LIEF/iterators.hpp
"
20
#include "
LIEF/range.hpp
"
21
#include "
LIEF/visibility.h
"
22
#include <optional>
23
24
#include <cstdint>
25
#include <memory>
26
#include <string>
27
28
29
namespace
LIEF::dwarf
{
30
31
namespace
details
{
32
class
LexicalBlock;
33
class
LexicalBlockIt;
34
}
35
37
class
LIEF_API
LexicalBlock
{
38
public
:
39
class
Iterator
final
40
:
public
iterator_facade_base<Iterator, std::bidirectional_iterator_tag,
41
LexicalBlock, std::ptrdiff_t,
42
const LexicalBlock*, const LexicalBlock&> {
43
public
:
44
using
implementation
= details::LexicalBlockIt;
45
using
iterator_facade_base::operator++;
46
using
iterator_facade_base::operator--;
47
48
LIEF_API
Iterator
();
49
50
LIEF_API
Iterator
(std::unique_ptr<details::LexicalBlockIt> impl);
51
52
LIEF_API
Iterator
(
const
Iterator
&);
53
LIEF_API
Iterator
&
operator=
(
const
Iterator
&);
54
55
LIEF_API
Iterator
(
Iterator
&&) noexcept;
56
LIEF_API
Iterator
& operator=(
Iterator
&&) noexcept;
57
58
LIEF_API
~
Iterator
();
59
60
friend
LIEF_API
bool
operator==(const
Iterator
& LHS, const
Iterator
& RHS);
61
friend
bool
operator!=(const
Iterator
& LHS, const
Iterator
& RHS) {
62
return
!(LHS == RHS);
63
}
64
65
// NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
66
LIEF_API
Iterator
&
operator++
();
67
68
// NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
69
LIEF_API
Iterator
&
operator--
();
70
71
LIEF_API
const
LexicalBlock
&
operator*
() const
LIEF_LIFETIMEBOUND
;
72
73
// NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
74
LIEF_API
const
LexicalBlock
* operator->() const
LIEF_LIFETIMEBOUND
;
75
78
LIEF_API
std::unique_ptr<
LexicalBlock
>
yield
();
79
80
private:
81
void
load() const;
82
83
std::unique_ptr<
details
::LexicalBlockIt> impl_;
84
mutable std::unique_ptr<
LexicalBlock
> cached_;
85
};
86
87
using
sub_blocks_it
=
iterator_range
<
Iterator
>;
88
89
LexicalBlock
(std::unique_ptr<
details
::
LexicalBlock
> impl);
90
LexicalBlock
() = delete;
91
LexicalBlock
& operator=(const
LexicalBlock
&) = delete;
92
LexicalBlock
(const
LexicalBlock
&) = delete;
93
96
std::
string
name
() const;
97
100
std::
string
description
() const;
101
103
sub_blocks_it
sub_blocks
() const
LIEF_LIFETIMEBOUND
;
104
106
std::optional<uint64_t>
addr
() const;
107
110
uint64_t
size
() const;
111
113
std::optional<uint64_t>
low_pc
() const;
114
116
std::optional<uint64_t>
high_pc
() const;
117
122
std::vector<
range_t
>
ranges
() const;
123
124
~
LexicalBlock
();
125
126
LIEF_LOCAL
static std::unique_ptr<
LexicalBlock
>
127
create
(std::unique_ptr<
details
::
LexicalBlock
> impl);
128
129
protected:
130
std::unique_ptr<
details
::
LexicalBlock
> impl_;
131
};
132
133
}
134
135
#endif
LIEF::dwarf::LexicalBlock::Iterator
Definition
LexicalBlock.hpp:42
LIEF::dwarf::LexicalBlock::Iterator::implementation
details::LexicalBlockIt implementation
Definition
LexicalBlock.hpp:44
LIEF::dwarf::LexicalBlock::Iterator::Iterator
Iterator()
LIEF::dwarf::LexicalBlock::Iterator::Iterator
Iterator(const Iterator &)
LIEF::dwarf::LexicalBlock::Iterator::operator*
const LexicalBlock & operator*() const
LIEF::dwarf::LexicalBlock::Iterator::operator--
Iterator & operator--()
LIEF::dwarf::LexicalBlock::Iterator::operator++
Iterator & operator++()
LIEF::dwarf::LexicalBlock::Iterator::yield
std::unique_ptr< LexicalBlock > yield()
Transfer ownership of the lexical block at the current position to the caller. Returns nullptr if the...
LIEF::dwarf::LexicalBlock::Iterator::operator=
Iterator & operator=(const Iterator &)
LIEF::dwarf::LexicalBlock::Iterator::Iterator
Iterator(Iterator &&) noexcept
LIEF::dwarf::LexicalBlock::Iterator::Iterator
Iterator(std::unique_ptr< details::LexicalBlockIt > impl)
LIEF::dwarf::LexicalBlock::LexicalBlock
LexicalBlock(std::unique_ptr< details::LexicalBlock > impl)
LIEF::dwarf::LexicalBlock::ranges
std::vector< range_t > ranges() const
Return a list of address ranges owned by this block.
LIEF::dwarf::LexicalBlock::high_pc
std::optional< uint64_t > high_pc() const
Return the highest virtual address owned by this block.
LIEF::dwarf::LexicalBlock::sub_blocks
sub_blocks_it sub_blocks() const
Return an iterator over the sub-LexicalBlock owned by this block.
LIEF::dwarf::LexicalBlock::size
uint64_t size() const
Return the size of this block as the difference of the highest address and the lowest address.
LIEF::dwarf::LexicalBlock::sub_blocks_it
iterator_range< Iterator > sub_blocks_it
Definition
LexicalBlock.hpp:87
LIEF::dwarf::LexicalBlock::low_pc
std::optional< uint64_t > low_pc() const
Return the lowest virtual address owned by this block.
LIEF::dwarf::LexicalBlock::addr
std::optional< uint64_t > addr() const
Return the start address of this block.
LIEF::dwarf::LexicalBlock::create
static std::unique_ptr< LexicalBlock > create(std::unique_ptr< details::LexicalBlock > impl)
LIEF::dwarf::LexicalBlock::description
std::string description() const
Return the description associated with this lexical block or an empty string.
LIEF::dwarf::LexicalBlock::name
std::string name() const
Return the name associated with this lexical block or an empty string.
LIEF::iterator_range
Definition
iterators.hpp:595
compiler_attributes.hpp
LIEF_LIFETIMEBOUND
#define LIEF_LIFETIMEBOUND
Definition
compiler_attributes.hpp:72
iterators.hpp
LIEF::dwarf::details
Definition
DWARF/CompilationUnit.hpp:32
LIEF::dwarf
Namespace for the DWARF debug format.
Definition
DWARF/CompilationUnit.hpp:30
range.hpp
LIEF::range_t
Definition
range.hpp:23
visibility.h
LIEF_API
#define LIEF_API
Definition
visibility.h:45
LIEF_LOCAL
#define LIEF_LOCAL
Definition
visibility.h:46
Generated by
1.18.0