Coverage Report

Created: 2026-10-17 07:17

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/capstonev5/LEB128.h
Line
Count
Source
1
//===- llvm/Support/LEB128.h - [SU]LEB128 utility functions -----*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file declares some utility functions for encoding SLEB128 and
11
// ULEB128 values.
12
//
13
//===----------------------------------------------------------------------===//
14
15
/* Capstone Disassembly Engine */
16
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2019 */
17
18
#ifndef CS_LLVM_SUPPORT_LEB128_H
19
#define CS_LLVM_SUPPORT_LEB128_H
20
21
#include "include/capstone/capstone.h"
22
23
/// Utility function to decode a ULEB128 value.
24
static inline uint64_t decodeULEB128(const uint8_t *p, unsigned *n)
25
57.8M
{
26
57.8M
  const uint8_t *orig_p = p;
27
57.8M
  uint64_t Value = 0;
28
57.8M
  unsigned Shift = 0;
29
64.9M
  do {
30
64.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
64.9M
    Shift += 7;
32
64.9M
  } while (*p++ >= 128);
33
57.8M
  if (n)
34
57.8M
    *n = (unsigned)(p - orig_p);
35
57.8M
  return Value;
36
57.8M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
20.7M
{
26
20.7M
  const uint8_t *orig_p = p;
27
20.7M
  uint64_t Value = 0;
28
20.7M
  unsigned Shift = 0;
29
22.9M
  do {
30
22.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
22.9M
    Shift += 7;
32
22.9M
  } while (*p++ >= 128);
33
20.7M
  if (n)
34
20.7M
    *n = (unsigned)(p - orig_p);
35
20.7M
  return Value;
36
20.7M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
9.83M
{
26
9.83M
  const uint8_t *orig_p = p;
27
9.83M
  uint64_t Value = 0;
28
9.83M
  unsigned Shift = 0;
29
10.7M
  do {
30
10.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.7M
    Shift += 7;
32
10.7M
  } while (*p++ >= 128);
33
9.83M
  if (n)
34
9.83M
    *n = (unsigned)(p - orig_p);
35
9.83M
  return Value;
36
9.83M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
4.25M
{
26
4.25M
  const uint8_t *orig_p = p;
27
4.25M
  uint64_t Value = 0;
28
4.25M
  unsigned Shift = 0;
29
4.40M
  do {
30
4.40M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.40M
    Shift += 7;
32
4.40M
  } while (*p++ >= 128);
33
4.25M
  if (n)
34
4.25M
    *n = (unsigned)(p - orig_p);
35
4.25M
  return Value;
36
4.25M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
6.70M
{
26
6.70M
  const uint8_t *orig_p = p;
27
6.70M
  uint64_t Value = 0;
28
6.70M
  unsigned Shift = 0;
29
6.96M
  do {
30
6.96M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.96M
    Shift += 7;
32
6.96M
  } while (*p++ >= 128);
33
6.70M
  if (n)
34
6.70M
    *n = (unsigned)(p - orig_p);
35
6.70M
  return Value;
36
6.70M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.40M
{
26
2.40M
  const uint8_t *orig_p = p;
27
2.40M
  uint64_t Value = 0;
28
2.40M
  unsigned Shift = 0;
29
2.47M
  do {
30
2.47M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.47M
    Shift += 7;
32
2.47M
  } while (*p++ >= 128);
33
2.40M
  if (n)
34
2.40M
    *n = (unsigned)(p - orig_p);
35
2.40M
  return Value;
36
2.40M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
8.38M
{
26
8.38M
  const uint8_t *orig_p = p;
27
8.38M
  uint64_t Value = 0;
28
8.38M
  unsigned Shift = 0;
29
11.6M
  do {
30
11.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
11.6M
    Shift += 7;
32
11.6M
  } while (*p++ >= 128);
33
8.38M
  if (n)
34
8.38M
    *n = (unsigned)(p - orig_p);
35
8.38M
  return Value;
36
8.38M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
741k
{
26
741k
  const uint8_t *orig_p = p;
27
741k
  uint64_t Value = 0;
28
741k
  unsigned Shift = 0;
29
803k
  do {
30
803k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
803k
    Shift += 7;
32
803k
  } while (*p++ >= 128);
33
741k
  if (n)
34
741k
    *n = (unsigned)(p - orig_p);
35
741k
  return Value;
36
741k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
987k
{
26
987k
  const uint8_t *orig_p = p;
27
987k
  uint64_t Value = 0;
28
987k
  unsigned Shift = 0;
29
1.00M
  do {
30
1.00M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.00M
    Shift += 7;
32
1.00M
  } while (*p++ >= 128);
33
987k
  if (n)
34
987k
    *n = (unsigned)(p - orig_p);
35
987k
  return Value;
36
987k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.81M
{
26
3.81M
  const uint8_t *orig_p = p;
27
3.81M
  uint64_t Value = 0;
28
3.81M
  unsigned Shift = 0;
29
3.97M
  do {
30
3.97M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.97M
    Shift += 7;
32
3.97M
  } while (*p++ >= 128);
33
3.81M
  if (n)
34
3.81M
    *n = (unsigned)(p - orig_p);
35
3.81M
  return Value;
36
3.81M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H