Coverage Report

Created: 2026-11-12 06:22

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
55.8M
{
26
55.8M
  const uint8_t *orig_p = p;
27
55.8M
  uint64_t Value = 0;
28
55.8M
  unsigned Shift = 0;
29
62.7M
  do {
30
62.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
62.7M
    Shift += 7;
32
62.7M
  } while (*p++ >= 128);
33
55.8M
  if (n)
34
55.8M
    *n = (unsigned)(p - orig_p);
35
55.8M
  return Value;
36
55.8M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
17.5M
{
26
17.5M
  const uint8_t *orig_p = p;
27
17.5M
  uint64_t Value = 0;
28
17.5M
  unsigned Shift = 0;
29
19.2M
  do {
30
19.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
19.2M
    Shift += 7;
32
19.2M
  } while (*p++ >= 128);
33
17.5M
  if (n)
34
17.5M
    *n = (unsigned)(p - orig_p);
35
17.5M
  return Value;
36
17.5M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
9.77M
{
26
9.77M
  const uint8_t *orig_p = p;
27
9.77M
  uint64_t Value = 0;
28
9.77M
  unsigned Shift = 0;
29
10.6M
  do {
30
10.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.6M
    Shift += 7;
32
10.6M
  } while (*p++ >= 128);
33
9.77M
  if (n)
34
9.77M
    *n = (unsigned)(p - orig_p);
35
9.77M
  return Value;
36
9.77M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
4.24M
{
26
4.24M
  const uint8_t *orig_p = p;
27
4.24M
  uint64_t Value = 0;
28
4.24M
  unsigned Shift = 0;
29
4.39M
  do {
30
4.39M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.39M
    Shift += 7;
32
4.39M
  } while (*p++ >= 128);
33
4.24M
  if (n)
34
4.24M
    *n = (unsigned)(p - orig_p);
35
4.24M
  return Value;
36
4.24M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
7.00M
{
26
7.00M
  const uint8_t *orig_p = p;
27
7.00M
  uint64_t Value = 0;
28
7.00M
  unsigned Shift = 0;
29
7.26M
  do {
30
7.26M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.26M
    Shift += 7;
32
7.26M
  } while (*p++ >= 128);
33
7.00M
  if (n)
34
7.00M
    *n = (unsigned)(p - orig_p);
35
7.00M
  return Value;
36
7.00M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.52M
{
26
2.52M
  const uint8_t *orig_p = p;
27
2.52M
  uint64_t Value = 0;
28
2.52M
  unsigned Shift = 0;
29
2.57M
  do {
30
2.57M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.57M
    Shift += 7;
32
2.57M
  } while (*p++ >= 128);
33
2.52M
  if (n)
34
2.52M
    *n = (unsigned)(p - orig_p);
35
2.52M
  return Value;
36
2.52M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
9.09M
{
26
9.09M
  const uint8_t *orig_p = p;
27
9.09M
  uint64_t Value = 0;
28
9.09M
  unsigned Shift = 0;
29
12.7M
  do {
30
12.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
12.7M
    Shift += 7;
32
12.7M
  } while (*p++ >= 128);
33
9.09M
  if (n)
34
9.09M
    *n = (unsigned)(p - orig_p);
35
9.09M
  return Value;
36
9.09M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
734k
{
26
734k
  const uint8_t *orig_p = p;
27
734k
  uint64_t Value = 0;
28
734k
  unsigned Shift = 0;
29
793k
  do {
30
793k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
793k
    Shift += 7;
32
793k
  } while (*p++ >= 128);
33
734k
  if (n)
34
734k
    *n = (unsigned)(p - orig_p);
35
734k
  return Value;
36
734k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
940k
{
26
940k
  const uint8_t *orig_p = p;
27
940k
  uint64_t Value = 0;
28
940k
  unsigned Shift = 0;
29
961k
  do {
30
961k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
961k
    Shift += 7;
32
961k
  } while (*p++ >= 128);
33
940k
  if (n)
34
940k
    *n = (unsigned)(p - orig_p);
35
940k
  return Value;
36
940k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.90M
{
26
3.90M
  const uint8_t *orig_p = p;
27
3.90M
  uint64_t Value = 0;
28
3.90M
  unsigned Shift = 0;
29
4.07M
  do {
30
4.07M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.07M
    Shift += 7;
32
4.07M
  } while (*p++ >= 128);
33
3.90M
  if (n)
34
3.90M
    *n = (unsigned)(p - orig_p);
35
3.90M
  return Value;
36
3.90M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H