MCPcopy Create free account
hub / github.com/Overload-Technologies/Overload / read_sleb128

Function read_sleb128

Dependencies/tracy/libbacktrace/dwarf.cpp:995–1029  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

993/* Read a signed LEB128 number. */
994
995static int64_t
996read_sleb128 (struct dwarf_buf *buf)
997{
998 uint64_t val;
999 unsigned int shift;
1000 int overflow;
1001 unsigned char b;
1002
1003 val = 0;
1004 shift = 0;
1005 overflow = 0;
1006 do
1007 {
1008 const unsigned char *p;
1009
1010 p = buf->buf;
1011 if (!advance (buf, 1))
1012 return 0;
1013 b = *p;
1014 if (shift < 64)
1015 val |= ((uint64_t) (b & 0x7f)) << shift;
1016 else if (!overflow)
1017 {
1018 dwarf_buf_error (buf, "signed LEB128 overflows uint64_t", 0);
1019 overflow = 1;
1020 }
1021 shift += 7;
1022 }
1023 while ((b & 0x80) != 0);
1024
1025 if ((b & 0x40) != 0 && shift < 64)
1026 val |= ((uint64_t) -1) << shift;
1027
1028 return (int64_t) val;
1029}
1030
1031/* Return the length of an LEB128 number. */
1032

Callers 3

read_attributeFunction · 0.85
read_abbrevsFunction · 0.85
read_line_programFunction · 0.85

Calls 2

dwarf_buf_errorFunction · 0.85
advanceFunction · 0.70

Tested by

no test coverage detected