Coverage Report

Created: 2026-08-31 06:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/capstonenext/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
72.0M
{
26
72.0M
  const uint8_t *orig_p = p;
27
72.0M
  uint64_t Value = 0;
28
72.0M
  unsigned Shift = 0;
29
81.0M
  do {
30
81.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
81.0M
    Shift += 7;
32
81.0M
  } while (*p++ >= 128);
33
72.0M
  if (n)
34
72.0M
    *n = (unsigned)(p - orig_p);
35
72.0M
  return Value;
36
72.0M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
860k
{
26
860k
  const uint8_t *orig_p = p;
27
860k
  uint64_t Value = 0;
28
860k
  unsigned Shift = 0;
29
955k
  do {
30
955k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
955k
    Shift += 7;
32
955k
  } while (*p++ >= 128);
33
860k
  if (n)
34
860k
    *n = (unsigned)(p - orig_p);
35
860k
  return Value;
36
860k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.15M
{
26
1.15M
  const uint8_t *orig_p = p;
27
1.15M
  uint64_t Value = 0;
28
1.15M
  unsigned Shift = 0;
29
1.18M
  do {
30
1.18M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.18M
    Shift += 7;
32
1.18M
  } while (*p++ >= 128);
33
1.15M
  if (n)
34
1.15M
    *n = (unsigned)(p - orig_p);
35
1.15M
  return Value;
36
1.15M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.62M
{
26
2.62M
  const uint8_t *orig_p = p;
27
2.62M
  uint64_t Value = 0;
28
2.62M
  unsigned Shift = 0;
29
2.71M
  do {
30
2.71M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.71M
    Shift += 7;
32
2.71M
  } while (*p++ >= 128);
33
2.62M
  if (n)
34
2.62M
    *n = (unsigned)(p - orig_p);
35
2.62M
  return Value;
36
2.62M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
36.1M
{
26
36.1M
  const uint8_t *orig_p = p;
27
36.1M
  uint64_t Value = 0;
28
36.1M
  unsigned Shift = 0;
29
40.0M
  do {
30
40.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
40.0M
    Shift += 7;
32
40.0M
  } while (*p++ >= 128);
33
36.1M
  if (n)
34
36.1M
    *n = (unsigned)(p - orig_p);
35
36.1M
  return Value;
36
36.1M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
7.13M
{
26
7.13M
  const uint8_t *orig_p = p;
27
7.13M
  uint64_t Value = 0;
28
7.13M
  unsigned Shift = 0;
29
7.89M
  do {
30
7.89M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.89M
    Shift += 7;
32
7.89M
  } while (*p++ >= 128);
33
7.13M
  if (n)
34
7.13M
    *n = (unsigned)(p - orig_p);
35
7.13M
  return Value;
36
7.13M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
6.69M
{
26
6.69M
  const uint8_t *orig_p = p;
27
6.69M
  uint64_t Value = 0;
28
6.69M
  unsigned Shift = 0;
29
6.99M
  do {
30
6.99M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.99M
    Shift += 7;
32
6.99M
  } while (*p++ >= 128);
33
6.69M
  if (n)
34
6.69M
    *n = (unsigned)(p - orig_p);
35
6.69M
  return Value;
36
6.69M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
5.45M
{
26
5.45M
  const uint8_t *orig_p = p;
27
5.45M
  uint64_t Value = 0;
28
5.45M
  unsigned Shift = 0;
29
5.66M
  do {
30
5.66M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.66M
    Shift += 7;
32
5.66M
  } while (*p++ >= 128);
33
5.45M
  if (n)
34
5.45M
    *n = (unsigned)(p - orig_p);
35
5.45M
  return Value;
36
5.45M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.98M
{
26
1.98M
  const uint8_t *orig_p = p;
27
1.98M
  uint64_t Value = 0;
28
1.98M
  unsigned Shift = 0;
29
2.05M
  do {
30
2.05M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.05M
    Shift += 7;
32
2.05M
  } while (*p++ >= 128);
33
1.98M
  if (n)
34
1.98M
    *n = (unsigned)(p - orig_p);
35
1.98M
  return Value;
36
1.98M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
9.00M
{
26
9.00M
  const uint8_t *orig_p = p;
27
9.00M
  uint64_t Value = 0;
28
9.00M
  unsigned Shift = 0;
29
12.4M
  do {
30
12.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
12.4M
    Shift += 7;
32
12.4M
  } while (*p++ >= 128);
33
9.00M
  if (n)
34
9.00M
    *n = (unsigned)(p - orig_p);
35
9.00M
  return Value;
36
9.00M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
1.01M
{
26
1.01M
  const uint8_t *orig_p = p;
27
1.01M
  uint64_t Value = 0;
28
1.01M
  unsigned Shift = 0;
29
1.09M
  do {
30
1.09M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.09M
    Shift += 7;
32
1.09M
  } while (*p++ >= 128);
33
1.01M
  if (n)
34
1.01M
    *n = (unsigned)(p - orig_p);
35
1.01M
  return Value;
36
1.01M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H