Coverage Report

Created: 2026-10-17 07:17

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
70.1M
{
26
70.1M
  const uint8_t *orig_p = p;
27
70.1M
  uint64_t Value = 0;
28
70.1M
  unsigned Shift = 0;
29
79.3M
  do {
30
79.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
79.3M
    Shift += 7;
32
79.3M
  } while (*p++ >= 128);
33
70.1M
  if (n)
34
70.1M
    *n = (unsigned)(p - orig_p);
35
70.1M
  return Value;
36
70.1M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
704k
{
26
704k
  const uint8_t *orig_p = p;
27
704k
  uint64_t Value = 0;
28
704k
  unsigned Shift = 0;
29
774k
  do {
30
774k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
774k
    Shift += 7;
32
774k
  } while (*p++ >= 128);
33
704k
  if (n)
34
704k
    *n = (unsigned)(p - orig_p);
35
704k
  return Value;
36
704k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.05M
{
26
1.05M
  const uint8_t *orig_p = p;
27
1.05M
  uint64_t Value = 0;
28
1.05M
  unsigned Shift = 0;
29
1.07M
  do {
30
1.07M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.07M
    Shift += 7;
32
1.07M
  } while (*p++ >= 128);
33
1.05M
  if (n)
34
1.05M
    *n = (unsigned)(p - orig_p);
35
1.05M
  return Value;
36
1.05M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.28M
{
26
3.28M
  const uint8_t *orig_p = p;
27
3.28M
  uint64_t Value = 0;
28
3.28M
  unsigned Shift = 0;
29
3.38M
  do {
30
3.38M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.38M
    Shift += 7;
32
3.38M
  } while (*p++ >= 128);
33
3.28M
  if (n)
34
3.28M
    *n = (unsigned)(p - orig_p);
35
3.28M
  return Value;
36
3.28M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
31.2M
{
26
31.2M
  const uint8_t *orig_p = p;
27
31.2M
  uint64_t Value = 0;
28
31.2M
  unsigned Shift = 0;
29
34.4M
  do {
30
34.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
34.4M
    Shift += 7;
32
34.4M
  } while (*p++ >= 128);
33
31.2M
  if (n)
34
31.2M
    *n = (unsigned)(p - orig_p);
35
31.2M
  return Value;
36
31.2M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
8.57M
{
26
8.57M
  const uint8_t *orig_p = p;
27
8.57M
  uint64_t Value = 0;
28
8.57M
  unsigned Shift = 0;
29
9.47M
  do {
30
9.47M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.47M
    Shift += 7;
32
9.47M
  } while (*p++ >= 128);
33
8.57M
  if (n)
34
8.57M
    *n = (unsigned)(p - orig_p);
35
8.57M
  return Value;
36
8.57M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
6.29M
{
26
6.29M
  const uint8_t *orig_p = p;
27
6.29M
  uint64_t Value = 0;
28
6.29M
  unsigned Shift = 0;
29
6.57M
  do {
30
6.57M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.57M
    Shift += 7;
32
6.57M
  } while (*p++ >= 128);
33
6.29M
  if (n)
34
6.29M
    *n = (unsigned)(p - orig_p);
35
6.29M
  return Value;
36
6.29M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
5.20M
{
26
5.20M
  const uint8_t *orig_p = p;
27
5.20M
  uint64_t Value = 0;
28
5.20M
  unsigned Shift = 0;
29
5.40M
  do {
30
5.40M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.40M
    Shift += 7;
32
5.40M
  } while (*p++ >= 128);
33
5.20M
  if (n)
34
5.20M
    *n = (unsigned)(p - orig_p);
35
5.20M
  return Value;
36
5.20M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.74M
{
26
1.74M
  const uint8_t *orig_p = p;
27
1.74M
  uint64_t Value = 0;
28
1.74M
  unsigned Shift = 0;
29
1.79M
  do {
30
1.79M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.79M
    Shift += 7;
32
1.79M
  } while (*p++ >= 128);
33
1.74M
  if (n)
34
1.74M
    *n = (unsigned)(p - orig_p);
35
1.74M
  return Value;
36
1.74M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
11.0M
{
26
11.0M
  const uint8_t *orig_p = p;
27
11.0M
  uint64_t Value = 0;
28
11.0M
  unsigned Shift = 0;
29
15.3M
  do {
30
15.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
15.3M
    Shift += 7;
32
15.3M
  } while (*p++ >= 128);
33
11.0M
  if (n)
34
11.0M
    *n = (unsigned)(p - orig_p);
35
11.0M
  return Value;
36
11.0M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
947k
{
26
947k
  const uint8_t *orig_p = p;
27
947k
  uint64_t Value = 0;
28
947k
  unsigned Shift = 0;
29
1.02M
  do {
30
1.02M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.02M
    Shift += 7;
32
1.02M
  } while (*p++ >= 128);
33
947k
  if (n)
34
947k
    *n = (unsigned)(p - orig_p);
35
947k
  return Value;
36
947k
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H