Coverage Report

Created: 2026-08-14 06:51

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
53.6M
{
26
53.6M
  const uint8_t *orig_p = p;
27
53.6M
  uint64_t Value = 0;
28
53.6M
  unsigned Shift = 0;
29
60.6M
  do {
30
60.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
60.6M
    Shift += 7;
32
60.6M
  } while (*p++ >= 128);
33
53.6M
  if (n)
34
53.6M
    *n = (unsigned)(p - orig_p);
35
53.6M
  return Value;
36
53.6M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
675k
{
26
675k
  const uint8_t *orig_p = p;
27
675k
  uint64_t Value = 0;
28
675k
  unsigned Shift = 0;
29
742k
  do {
30
742k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
742k
    Shift += 7;
32
742k
  } while (*p++ >= 128);
33
675k
  if (n)
34
675k
    *n = (unsigned)(p - orig_p);
35
675k
  return Value;
36
675k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
762k
{
26
762k
  const uint8_t *orig_p = p;
27
762k
  uint64_t Value = 0;
28
762k
  unsigned Shift = 0;
29
781k
  do {
30
781k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
781k
    Shift += 7;
32
781k
  } while (*p++ >= 128);
33
762k
  if (n)
34
762k
    *n = (unsigned)(p - orig_p);
35
762k
  return Value;
36
762k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.13M
{
26
2.13M
  const uint8_t *orig_p = p;
27
2.13M
  uint64_t Value = 0;
28
2.13M
  unsigned Shift = 0;
29
2.21M
  do {
30
2.21M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.21M
    Shift += 7;
32
2.21M
  } while (*p++ >= 128);
33
2.13M
  if (n)
34
2.13M
    *n = (unsigned)(p - orig_p);
35
2.13M
  return Value;
36
2.13M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
25.5M
{
26
25.5M
  const uint8_t *orig_p = p;
27
25.5M
  uint64_t Value = 0;
28
25.5M
  unsigned Shift = 0;
29
28.3M
  do {
30
28.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
28.3M
    Shift += 7;
32
28.3M
  } while (*p++ >= 128);
33
25.5M
  if (n)
34
25.5M
    *n = (unsigned)(p - orig_p);
35
25.5M
  return Value;
36
25.5M
}
AArch64Disassembler.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
6.01M
  do {
30
6.01M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.01M
    Shift += 7;
32
6.01M
  } while (*p++ >= 128);
33
5.45M
  if (n)
34
5.45M
    *n = (unsigned)(p - orig_p);
35
5.45M
  return Value;
36
5.45M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
5.12M
{
26
5.12M
  const uint8_t *orig_p = p;
27
5.12M
  uint64_t Value = 0;
28
5.12M
  unsigned Shift = 0;
29
5.35M
  do {
30
5.35M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.35M
    Shift += 7;
32
5.35M
  } while (*p++ >= 128);
33
5.12M
  if (n)
34
5.12M
    *n = (unsigned)(p - orig_p);
35
5.12M
  return Value;
36
5.12M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
4.03M
{
26
4.03M
  const uint8_t *orig_p = p;
27
4.03M
  uint64_t Value = 0;
28
4.03M
  unsigned Shift = 0;
29
4.20M
  do {
30
4.20M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.20M
    Shift += 7;
32
4.20M
  } while (*p++ >= 128);
33
4.03M
  if (n)
34
4.03M
    *n = (unsigned)(p - orig_p);
35
4.03M
  return Value;
36
4.03M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.51M
{
26
1.51M
  const uint8_t *orig_p = p;
27
1.51M
  uint64_t Value = 0;
28
1.51M
  unsigned Shift = 0;
29
1.56M
  do {
30
1.56M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.56M
    Shift += 7;
32
1.56M
  } while (*p++ >= 128);
33
1.51M
  if (n)
34
1.51M
    *n = (unsigned)(p - orig_p);
35
1.51M
  return Value;
36
1.51M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
7.72M
{
26
7.72M
  const uint8_t *orig_p = p;
27
7.72M
  uint64_t Value = 0;
28
7.72M
  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
7.72M
  if (n)
34
7.72M
    *n = (unsigned)(p - orig_p);
35
7.72M
  return Value;
36
7.72M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
694k
{
26
694k
  const uint8_t *orig_p = p;
27
694k
  uint64_t Value = 0;
28
694k
  unsigned Shift = 0;
29
750k
  do {
30
750k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
750k
    Shift += 7;
32
750k
  } while (*p++ >= 128);
33
694k
  if (n)
34
694k
    *n = (unsigned)(p - orig_p);
35
694k
  return Value;
36
694k
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H