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
128M
{
26
128M
  const uint8_t *orig_p = p;
27
128M
  uint64_t Value = 0;
28
128M
  unsigned Shift = 0;
29
144M
  do {
30
144M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
144M
    Shift += 7;
32
144M
  } while (*p++ >= 128);
33
128M
  if (n)
34
128M
    *n = (unsigned)(p - orig_p);
35
128M
  return Value;
36
128M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.44M
{
26
1.44M
  const uint8_t *orig_p = p;
27
1.44M
  uint64_t Value = 0;
28
1.44M
  unsigned Shift = 0;
29
1.57M
  do {
30
1.57M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.57M
    Shift += 7;
32
1.57M
  } while (*p++ >= 128);
33
1.44M
  if (n)
34
1.44M
    *n = (unsigned)(p - orig_p);
35
1.44M
  return Value;
36
1.44M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
2.04M
{
26
2.04M
  const uint8_t *orig_p = p;
27
2.04M
  uint64_t Value = 0;
28
2.04M
  unsigned Shift = 0;
29
2.08M
  do {
30
2.08M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.08M
    Shift += 7;
32
2.08M
  } while (*p++ >= 128);
33
2.04M
  if (n)
34
2.04M
    *n = (unsigned)(p - orig_p);
35
2.04M
  return Value;
36
2.04M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
7.09M
{
26
7.09M
  const uint8_t *orig_p = p;
27
7.09M
  uint64_t Value = 0;
28
7.09M
  unsigned Shift = 0;
29
7.36M
  do {
30
7.36M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.36M
    Shift += 7;
32
7.36M
  } while (*p++ >= 128);
33
7.09M
  if (n)
34
7.09M
    *n = (unsigned)(p - orig_p);
35
7.09M
  return Value;
36
7.09M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
52.0M
{
26
52.0M
  const uint8_t *orig_p = p;
27
52.0M
  uint64_t Value = 0;
28
52.0M
  unsigned Shift = 0;
29
57.3M
  do {
30
57.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
57.3M
    Shift += 7;
32
57.3M
  } while (*p++ >= 128);
33
52.0M
  if (n)
34
52.0M
    *n = (unsigned)(p - orig_p);
35
52.0M
  return Value;
36
52.0M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
18.4M
{
26
18.4M
  const uint8_t *orig_p = p;
27
18.4M
  uint64_t Value = 0;
28
18.4M
  unsigned Shift = 0;
29
20.2M
  do {
30
20.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
20.2M
    Shift += 7;
32
20.2M
  } while (*p++ >= 128);
33
18.4M
  if (n)
34
18.4M
    *n = (unsigned)(p - orig_p);
35
18.4M
  return Value;
36
18.4M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
10.5M
{
26
10.5M
  const uint8_t *orig_p = p;
27
10.5M
  uint64_t Value = 0;
28
10.5M
  unsigned Shift = 0;
29
10.9M
  do {
30
10.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.9M
    Shift += 7;
32
10.9M
  } while (*p++ >= 128);
33
10.5M
  if (n)
34
10.5M
    *n = (unsigned)(p - orig_p);
35
10.5M
  return Value;
36
10.5M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
11.9M
{
26
11.9M
  const uint8_t *orig_p = p;
27
11.9M
  uint64_t Value = 0;
28
11.9M
  unsigned Shift = 0;
29
12.3M
  do {
30
12.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
12.3M
    Shift += 7;
32
12.3M
  } while (*p++ >= 128);
33
11.9M
  if (n)
34
11.9M
    *n = (unsigned)(p - orig_p);
35
11.9M
  return Value;
36
11.9M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
4.15M
{
26
4.15M
  const uint8_t *orig_p = p;
27
4.15M
  uint64_t Value = 0;
28
4.15M
  unsigned Shift = 0;
29
4.27M
  do {
30
4.27M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.27M
    Shift += 7;
32
4.27M
  } while (*p++ >= 128);
33
4.15M
  if (n)
34
4.15M
    *n = (unsigned)(p - orig_p);
35
4.15M
  return Value;
36
4.15M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
19.4M
{
26
19.4M
  const uint8_t *orig_p = p;
27
19.4M
  uint64_t Value = 0;
28
19.4M
  unsigned Shift = 0;
29
27.0M
  do {
30
27.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
27.0M
    Shift += 7;
32
27.0M
  } while (*p++ >= 128);
33
19.4M
  if (n)
34
19.4M
    *n = (unsigned)(p - orig_p);
35
19.4M
  return Value;
36
19.4M
}
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