Coverage Report

Created: 2026-06-15 06:41

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
58.3M
{
26
58.3M
  const uint8_t *orig_p = p;
27
58.3M
  uint64_t Value = 0;
28
58.3M
  unsigned Shift = 0;
29
65.3M
  do {
30
65.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
65.3M
    Shift += 7;
32
65.3M
  } while (*p++ >= 128);
33
58.3M
  if (n)
34
58.3M
    *n = (unsigned)(p - orig_p);
35
58.3M
  return Value;
36
58.3M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
23.7M
{
26
23.7M
  const uint8_t *orig_p = p;
27
23.7M
  uint64_t Value = 0;
28
23.7M
  unsigned Shift = 0;
29
26.2M
  do {
30
26.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
26.2M
    Shift += 7;
32
26.2M
  } while (*p++ >= 128);
33
23.7M
  if (n)
34
23.7M
    *n = (unsigned)(p - orig_p);
35
23.7M
  return Value;
36
23.7M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
8.84M
{
26
8.84M
  const uint8_t *orig_p = p;
27
8.84M
  uint64_t Value = 0;
28
8.84M
  unsigned Shift = 0;
29
9.69M
  do {
30
9.69M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.69M
    Shift += 7;
32
9.69M
  } while (*p++ >= 128);
33
8.84M
  if (n)
34
8.84M
    *n = (unsigned)(p - orig_p);
35
8.84M
  return Value;
36
8.84M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
4.20M
{
26
4.20M
  const uint8_t *orig_p = p;
27
4.20M
  uint64_t Value = 0;
28
4.20M
  unsigned Shift = 0;
29
4.35M
  do {
30
4.35M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.35M
    Shift += 7;
32
4.35M
  } while (*p++ >= 128);
33
4.20M
  if (n)
34
4.20M
    *n = (unsigned)(p - orig_p);
35
4.20M
  return Value;
36
4.20M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
6.38M
{
26
6.38M
  const uint8_t *orig_p = p;
27
6.38M
  uint64_t Value = 0;
28
6.38M
  unsigned Shift = 0;
29
6.63M
  do {
30
6.63M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.63M
    Shift += 7;
32
6.63M
  } while (*p++ >= 128);
33
6.38M
  if (n)
34
6.38M
    *n = (unsigned)(p - orig_p);
35
6.38M
  return Value;
36
6.38M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.28M
{
26
2.28M
  const uint8_t *orig_p = p;
27
2.28M
  uint64_t Value = 0;
28
2.28M
  unsigned Shift = 0;
29
2.34M
  do {
30
2.34M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.34M
    Shift += 7;
32
2.34M
  } while (*p++ >= 128);
33
2.28M
  if (n)
34
2.28M
    *n = (unsigned)(p - orig_p);
35
2.28M
  return Value;
36
2.28M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
7.55M
{
26
7.55M
  const uint8_t *orig_p = p;
27
7.55M
  uint64_t Value = 0;
28
7.55M
  unsigned Shift = 0;
29
10.4M
  do {
30
10.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.4M
    Shift += 7;
32
10.4M
  } while (*p++ >= 128);
33
7.55M
  if (n)
34
7.55M
    *n = (unsigned)(p - orig_p);
35
7.55M
  return Value;
36
7.55M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
793k
{
26
793k
  const uint8_t *orig_p = p;
27
793k
  uint64_t Value = 0;
28
793k
  unsigned Shift = 0;
29
877k
  do {
30
877k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
877k
    Shift += 7;
32
877k
  } while (*p++ >= 128);
33
793k
  if (n)
34
793k
    *n = (unsigned)(p - orig_p);
35
793k
  return Value;
36
793k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.12M
{
26
1.12M
  const uint8_t *orig_p = p;
27
1.12M
  uint64_t Value = 0;
28
1.12M
  unsigned Shift = 0;
29
1.15M
  do {
30
1.15M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.15M
    Shift += 7;
32
1.15M
  } while (*p++ >= 128);
33
1.12M
  if (n)
34
1.12M
    *n = (unsigned)(p - orig_p);
35
1.12M
  return Value;
36
1.12M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.37M
{
26
3.37M
  const uint8_t *orig_p = p;
27
3.37M
  uint64_t Value = 0;
28
3.37M
  unsigned Shift = 0;
29
3.51M
  do {
30
3.51M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.51M
    Shift += 7;
32
3.51M
  } while (*p++ >= 128);
33
3.37M
  if (n)
34
3.37M
    *n = (unsigned)(p - orig_p);
35
3.37M
  return Value;
36
3.37M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H