Coverage Report

Created: 2026-06-06 06:15

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
96.2M
{
26
96.2M
  const uint8_t *orig_p = p;
27
96.2M
  uint64_t Value = 0;
28
96.2M
  unsigned Shift = 0;
29
108M
  do {
30
108M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
108M
    Shift += 7;
32
108M
  } while (*p++ >= 128);
33
96.2M
  if (n)
34
96.2M
    *n = (unsigned)(p - orig_p);
35
96.2M
  return Value;
36
96.2M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.27M
{
26
1.27M
  const uint8_t *orig_p = p;
27
1.27M
  uint64_t Value = 0;
28
1.27M
  unsigned Shift = 0;
29
1.41M
  do {
30
1.41M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.41M
    Shift += 7;
32
1.41M
  } while (*p++ >= 128);
33
1.27M
  if (n)
34
1.27M
    *n = (unsigned)(p - orig_p);
35
1.27M
  return Value;
36
1.27M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.65M
{
26
1.65M
  const uint8_t *orig_p = p;
27
1.65M
  uint64_t Value = 0;
28
1.65M
  unsigned Shift = 0;
29
1.69M
  do {
30
1.69M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.69M
    Shift += 7;
32
1.69M
  } while (*p++ >= 128);
33
1.65M
  if (n)
34
1.65M
    *n = (unsigned)(p - orig_p);
35
1.65M
  return Value;
36
1.65M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
4.62M
{
26
4.62M
  const uint8_t *orig_p = p;
27
4.62M
  uint64_t Value = 0;
28
4.62M
  unsigned Shift = 0;
29
4.81M
  do {
30
4.81M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.81M
    Shift += 7;
32
4.81M
  } while (*p++ >= 128);
33
4.62M
  if (n)
34
4.62M
    *n = (unsigned)(p - orig_p);
35
4.62M
  return Value;
36
4.62M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
42.6M
{
26
42.6M
  const uint8_t *orig_p = p;
27
42.6M
  uint64_t Value = 0;
28
42.6M
  unsigned Shift = 0;
29
47.1M
  do {
30
47.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
47.1M
    Shift += 7;
32
47.1M
  } while (*p++ >= 128);
33
42.6M
  if (n)
34
42.6M
    *n = (unsigned)(p - orig_p);
35
42.6M
  return Value;
36
42.6M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
13.0M
{
26
13.0M
  const uint8_t *orig_p = p;
27
13.0M
  uint64_t Value = 0;
28
13.0M
  unsigned Shift = 0;
29
14.3M
  do {
30
14.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
14.3M
    Shift += 7;
32
14.3M
  } while (*p++ >= 128);
33
13.0M
  if (n)
34
13.0M
    *n = (unsigned)(p - orig_p);
35
13.0M
  return Value;
36
13.0M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
7.15M
{
26
7.15M
  const uint8_t *orig_p = p;
27
7.15M
  uint64_t Value = 0;
28
7.15M
  unsigned Shift = 0;
29
7.43M
  do {
30
7.43M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.43M
    Shift += 7;
32
7.43M
  } while (*p++ >= 128);
33
7.15M
  if (n)
34
7.15M
    *n = (unsigned)(p - orig_p);
35
7.15M
  return Value;
36
7.15M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
8.59M
{
26
8.59M
  const uint8_t *orig_p = p;
27
8.59M
  uint64_t Value = 0;
28
8.59M
  unsigned Shift = 0;
29
8.94M
  do {
30
8.94M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.94M
    Shift += 7;
32
8.94M
  } while (*p++ >= 128);
33
8.59M
  if (n)
34
8.59M
    *n = (unsigned)(p - orig_p);
35
8.59M
  return Value;
36
8.59M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.31M
{
26
3.31M
  const uint8_t *orig_p = p;
27
3.31M
  uint64_t Value = 0;
28
3.31M
  unsigned Shift = 0;
29
3.40M
  do {
30
3.40M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.40M
    Shift += 7;
32
3.40M
  } while (*p++ >= 128);
33
3.31M
  if (n)
34
3.31M
    *n = (unsigned)(p - orig_p);
35
3.31M
  return Value;
36
3.31M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
12.4M
{
26
12.4M
  const uint8_t *orig_p = p;
27
12.4M
  uint64_t Value = 0;
28
12.4M
  unsigned Shift = 0;
29
17.2M
  do {
30
17.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
17.2M
    Shift += 7;
32
17.2M
  } while (*p++ >= 128);
33
12.4M
  if (n)
34
12.4M
    *n = (unsigned)(p - orig_p);
35
12.4M
  return Value;
36
12.4M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
1.57M
{
26
1.57M
  const uint8_t *orig_p = p;
27
1.57M
  uint64_t Value = 0;
28
1.57M
  unsigned Shift = 0;
29
1.91M
  do {
30
1.91M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.91M
    Shift += 7;
32
1.91M
  } while (*p++ >= 128);
33
1.57M
  if (n)
34
1.57M
    *n = (unsigned)(p - orig_p);
35
1.57M
  return Value;
36
1.57M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H