Coverage Report

Created: 2026-09-28 06:34

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
76.4M
{
26
76.4M
  const uint8_t *orig_p = p;
27
76.4M
  uint64_t Value = 0;
28
76.4M
  unsigned Shift = 0;
29
86.1M
  do {
30
86.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
86.1M
    Shift += 7;
32
86.1M
  } while (*p++ >= 128);
33
76.4M
  if (n)
34
76.4M
    *n = (unsigned)(p - orig_p);
35
76.4M
  return Value;
36
76.4M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.19M
{
26
1.19M
  const uint8_t *orig_p = p;
27
1.19M
  uint64_t Value = 0;
28
1.19M
  unsigned Shift = 0;
29
1.31M
  do {
30
1.31M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.31M
    Shift += 7;
32
1.31M
  } while (*p++ >= 128);
33
1.19M
  if (n)
34
1.19M
    *n = (unsigned)(p - orig_p);
35
1.19M
  return Value;
36
1.19M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.43M
{
26
1.43M
  const uint8_t *orig_p = p;
27
1.43M
  uint64_t Value = 0;
28
1.43M
  unsigned Shift = 0;
29
1.46M
  do {
30
1.46M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.46M
    Shift += 7;
32
1.46M
  } while (*p++ >= 128);
33
1.43M
  if (n)
34
1.43M
    *n = (unsigned)(p - orig_p);
35
1.43M
  return Value;
36
1.43M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.77M
{
26
3.77M
  const uint8_t *orig_p = p;
27
3.77M
  uint64_t Value = 0;
28
3.77M
  unsigned Shift = 0;
29
3.92M
  do {
30
3.92M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.92M
    Shift += 7;
32
3.92M
  } while (*p++ >= 128);
33
3.77M
  if (n)
34
3.77M
    *n = (unsigned)(p - orig_p);
35
3.77M
  return Value;
36
3.77M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
33.6M
{
26
33.6M
  const uint8_t *orig_p = p;
27
33.6M
  uint64_t Value = 0;
28
33.6M
  unsigned Shift = 0;
29
37.2M
  do {
30
37.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
37.2M
    Shift += 7;
32
37.2M
  } while (*p++ >= 128);
33
33.6M
  if (n)
34
33.6M
    *n = (unsigned)(p - orig_p);
35
33.6M
  return Value;
36
33.6M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
9.16M
{
26
9.16M
  const uint8_t *orig_p = p;
27
9.16M
  uint64_t Value = 0;
28
9.16M
  unsigned Shift = 0;
29
10.0M
  do {
30
10.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.0M
    Shift += 7;
32
10.0M
  } while (*p++ >= 128);
33
9.16M
  if (n)
34
9.16M
    *n = (unsigned)(p - orig_p);
35
9.16M
  return Value;
36
9.16M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
6.66M
{
26
6.66M
  const uint8_t *orig_p = p;
27
6.66M
  uint64_t Value = 0;
28
6.66M
  unsigned Shift = 0;
29
6.94M
  do {
30
6.94M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.94M
    Shift += 7;
32
6.94M
  } while (*p++ >= 128);
33
6.66M
  if (n)
34
6.66M
    *n = (unsigned)(p - orig_p);
35
6.66M
  return Value;
36
6.66M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
6.97M
{
26
6.97M
  const uint8_t *orig_p = p;
27
6.97M
  uint64_t Value = 0;
28
6.97M
  unsigned Shift = 0;
29
7.24M
  do {
30
7.24M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.24M
    Shift += 7;
32
7.24M
  } while (*p++ >= 128);
33
6.97M
  if (n)
34
6.97M
    *n = (unsigned)(p - orig_p);
35
6.97M
  return Value;
36
6.97M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.34M
{
26
2.34M
  const uint8_t *orig_p = p;
27
2.34M
  uint64_t Value = 0;
28
2.34M
  unsigned Shift = 0;
29
2.42M
  do {
30
2.42M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.42M
    Shift += 7;
32
2.42M
  } while (*p++ >= 128);
33
2.34M
  if (n)
34
2.34M
    *n = (unsigned)(p - orig_p);
35
2.34M
  return Value;
36
2.34M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
10.7M
{
26
10.7M
  const uint8_t *orig_p = p;
27
10.7M
  uint64_t Value = 0;
28
10.7M
  unsigned Shift = 0;
29
14.8M
  do {
30
14.8M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
14.8M
    Shift += 7;
32
14.8M
  } while (*p++ >= 128);
33
10.7M
  if (n)
34
10.7M
    *n = (unsigned)(p - orig_p);
35
10.7M
  return Value;
36
10.7M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
516k
{
26
516k
  const uint8_t *orig_p = p;
27
516k
  uint64_t Value = 0;
28
516k
  unsigned Shift = 0;
29
555k
  do {
30
555k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
555k
    Shift += 7;
32
555k
  } while (*p++ >= 128);
33
516k
  if (n)
34
516k
    *n = (unsigned)(p - orig_p);
35
516k
  return Value;
36
516k
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H