Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
z
Enumerations
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
z
Classes
Class List
Class Hierarchy
Class Members
All
:
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
Enumerations
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
Properties
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Related Functions
:
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
grpc
third_party
bloaty
src
dwarf
dwarf_util.cc
Go to the documentation of this file.
1
// Copyright 2016 Google Inc. All Rights Reserved.
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
#include "
dwarf/dwarf_util.h
"
16
17
using
string_view
=
absl::string_view
;
18
19
namespace
bloaty
{
20
namespace
dwarf {
21
22
// uint64/32 max is a tombstone value added by https://reviews.llvm.org/D81784.
23
bool
IsValidDwarfAddress
(
uint64_t
addr
,
uint8_t
address_size) {
24
if
(
addr
== 0)
25
return
false
;
26
if
(address_size == 4 &&
addr
==
std::numeric_limits<uint32_t>::max
())
27
return
false
;
28
if
(address_size == 8 &&
addr
==
std::numeric_limits<uint64_t>::max
())
29
return
false
;
30
return
true
;
31
}
32
33
uint64_t
ReadLEB128Internal
(
bool
is_signed,
string_view
*
data
) {
34
uint64_t
ret
= 0;
35
int
shift = 0;
36
int
maxshift = 70;
37
const
char
*
ptr
=
data
->data();
38
const
char
* limit =
ptr
+
data
->size();
39
40
while
(
ptr
< limit && shift < maxshift) {
41
char
byte
= *(
ptr
++);
42
ret
|=
static_cast<
uint64_t
>
(
byte
& 0x7f) << shift;
43
shift += 7;
44
if
((
byte
& 0x80) == 0) {
45
data
->remove_prefix(
ptr
-
data
->data());
46
if
(is_signed && shift < 64 && (
byte
& 0x40)) {
47
ret
|= -(1
ULL
<< shift);
48
}
49
return
ret
;
50
}
51
}
52
53
THROW
(
"corrupt DWARF data, unterminated LEB128"
);
54
}
55
56
void
SkipLEB128
(
string_view
*
data
) {
57
size_t
limit =
58
std::min
(
static_cast<
size_t
>
(
data
->size()),
static_cast<
size_t
>
(10));
59
for
(
size_t
i
= 0;
i
< limit;
i
++) {
60
if
(((*
data
)[
i
] & 0x80) == 0) {
61
data
->remove_prefix(
i
+ 1);
62
return
;
63
}
64
}
65
66
THROW
(
"corrupt DWARF data, unterminated LEB128"
);
67
}
68
69
absl::string_view
ReadDebugStrEntry
(
absl::string_view
debug_str,
size_t
ofs) {
70
SkipBytes
(ofs, &debug_str);
71
return
ReadNullTerminated
(&debug_str);
72
}
73
74
}
// namespace dwarf
75
}
// namespace bloaty
ptr
char * ptr
Definition:
abseil-cpp/absl/base/internal/low_level_alloc_test.cc:45
bloaty
Definition:
bloaty.cc:69
bloaty::dwarf::ReadLEB128Internal
uint64_t ReadLEB128Internal(bool is_signed, string_view *data)
Definition:
dwarf_util.cc:33
absl::string_view
Definition:
abseil-cpp/absl/strings/string_view.h:167
uint8_t
unsigned char uint8_t
Definition:
stdint-msvc2008.h:78
ULL
#define ULL(x)
Definition:
bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc:57
bloaty::SkipBytes
void SkipBytes(size_t bytes, absl::string_view *data)
Definition:
bloaty/src/util.h:174
THROW
#define THROW(msg)
Definition:
bloaty/src/util.h:45
max
int max
Definition:
bloaty/third_party/zlib/examples/enough.c:170
dwarf_util.h
uint64_t
unsigned __int64 uint64_t
Definition:
stdint-msvc2008.h:90
data
char data[kBufferLength]
Definition:
abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
min
#define min(a, b)
Definition:
qsort.h:83
string_view
absl::string_view string_view
Definition:
dwarf_util.cc:17
bloaty::dwarf::SkipLEB128
void SkipLEB128(string_view *data)
Definition:
dwarf_util.cc:56
bloaty::dwarf::IsValidDwarfAddress
bool IsValidDwarfAddress(uint64_t addr, uint8_t address_size)
Definition:
dwarf_util.cc:23
ret
UniquePtr< SSL_SESSION > ret
Definition:
ssl_x509.cc:1029
bloaty::ReadNullTerminated
absl::string_view ReadNullTerminated(absl::string_view *data)
Definition:
third_party/bloaty/src/util.cc:26
addr
struct sockaddr_in addr
Definition:
libuv/docs/code/tcp-echo-server/main.c:10
i
uint64_t i
Definition:
abseil-cpp/absl/container/btree_benchmark.cc:230
bloaty::dwarf::ReadDebugStrEntry
absl::string_view ReadDebugStrEntry(absl::string_view debug_str, size_t ofs)
Definition:
dwarf_util.cc:69
grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:59:13