dwarf_util.h
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 #ifndef BLOATY_DWARF_UTIL_H_
16 #define BLOATY_DWARF_UTIL_H_
17 
18 #include <cstdint>
19 #include <type_traits>
20 
21 #include "absl/strings/string_view.h"
22 #include "util.h"
23 
24 namespace bloaty {
25 namespace dwarf {
26 
28 
29 // Reads a DWARF LEB128 varint, where high bits indicate continuation.
30 template <typename T>
33  uint64_t>::type Int64Type;
35  if (val > std::numeric_limits<T>::max() ||
37  THROW("DWARF data contained larger LEB128 than we were expecting");
38  }
39  return static_cast<T>(val);
40 }
41 
43 
44 bool IsValidDwarfAddress(uint64_t addr, uint8_t address_size);
45 
46 inline int DivRoundUp(int n, int d) {
47  return (n + (d - 1)) / d;
48 }
49 
51 
52 } // namepsace dwarf
53 } // namepsace bloaty
54 
55 #endif // BLOATY_DWARF_UTIL_H_
bloaty
Definition: bloaty.cc:69
bloaty::dwarf::DivRoundUp
int DivRoundUp(int n, int d)
Definition: dwarf_util.h:46
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
T
#define T(upbtypeconst, upbtype, ctype, default_value)
int64_t
signed __int64 int64_t
Definition: stdint-msvc2008.h:89
THROW
#define THROW(msg)
Definition: bloaty/src/util.h:45
max
int max
Definition: bloaty/third_party/zlib/examples/enough.c:170
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
bloaty::dwarf::SkipLEB128
void SkipLEB128(string_view *data)
Definition: dwarf_util.cc:56
n
int n
Definition: abseil-cpp/absl/container/btree_test.cc:1080
value
const char * value
Definition: hpack_parser_table.cc:165
bloaty::dwarf::IsValidDwarfAddress
bool IsValidDwarfAddress(uint64_t addr, uint8_t address_size)
Definition: dwarf_util.cc:23
bloaty::dwarf::ReadLEB128
T ReadLEB128(absl::string_view *data)
Definition: dwarf_util.h:31
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
addr
struct sockaddr_in addr
Definition: libuv/docs/code/tcp-echo-server/main.c:10
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