Coverage Report

Created: 2025-10-14 06:42

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
63.4M
{
26
63.4M
  const uint8_t *orig_p = p;
27
63.4M
  uint64_t Value = 0;
28
63.4M
  unsigned Shift = 0;
29
72.1M
  do {
30
72.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
72.1M
    Shift += 7;
32
72.1M
  } while (*p++ >= 128);
33
63.4M
  if (n)
34
63.4M
    *n = (unsigned)(p - orig_p);
35
63.4M
  return Value;
36
63.4M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
879k
{
26
879k
  const uint8_t *orig_p = p;
27
879k
  uint64_t Value = 0;
28
879k
  unsigned Shift = 0;
29
968k
  do {
30
968k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
968k
    Shift += 7;
32
968k
  } while (*p++ >= 128);
33
879k
  if (n)
34
879k
    *n = (unsigned)(p - orig_p);
35
879k
  return Value;
36
879k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
980k
{
26
980k
  const uint8_t *orig_p = p;
27
980k
  uint64_t Value = 0;
28
980k
  unsigned Shift = 0;
29
1.00M
  do {
30
1.00M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.00M
    Shift += 7;
32
1.00M
  } while (*p++ >= 128);
33
980k
  if (n)
34
980k
    *n = (unsigned)(p - orig_p);
35
980k
  return Value;
36
980k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.35M
{
26
2.35M
  const uint8_t *orig_p = p;
27
2.35M
  uint64_t Value = 0;
28
2.35M
  unsigned Shift = 0;
29
2.45M
  do {
30
2.45M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.45M
    Shift += 7;
32
2.45M
  } while (*p++ >= 128);
33
2.35M
  if (n)
34
2.35M
    *n = (unsigned)(p - orig_p);
35
2.35M
  return Value;
36
2.35M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
30.4M
{
26
30.4M
  const uint8_t *orig_p = p;
27
30.4M
  uint64_t Value = 0;
28
30.4M
  unsigned Shift = 0;
29
33.6M
  do {
30
33.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
33.6M
    Shift += 7;
32
33.6M
  } while (*p++ >= 128);
33
30.4M
  if (n)
34
30.4M
    *n = (unsigned)(p - orig_p);
35
30.4M
  return Value;
36
30.4M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
6.86M
{
26
6.86M
  const uint8_t *orig_p = p;
27
6.86M
  uint64_t Value = 0;
28
6.86M
  unsigned Shift = 0;
29
7.60M
  do {
30
7.60M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.60M
    Shift += 7;
32
7.60M
  } while (*p++ >= 128);
33
6.86M
  if (n)
34
6.86M
    *n = (unsigned)(p - orig_p);
35
6.86M
  return Value;
36
6.86M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
4.68M
{
26
4.68M
  const uint8_t *orig_p = p;
27
4.68M
  uint64_t Value = 0;
28
4.68M
  unsigned Shift = 0;
29
4.90M
  do {
30
4.90M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.90M
    Shift += 7;
32
4.90M
  } while (*p++ >= 128);
33
4.68M
  if (n)
34
4.68M
    *n = (unsigned)(p - orig_p);
35
4.68M
  return Value;
36
4.68M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
4.29M
{
26
4.29M
  const uint8_t *orig_p = p;
27
4.29M
  uint64_t Value = 0;
28
4.29M
  unsigned Shift = 0;
29
4.46M
  do {
30
4.46M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.46M
    Shift += 7;
32
4.46M
  } while (*p++ >= 128);
33
4.29M
  if (n)
34
4.29M
    *n = (unsigned)(p - orig_p);
35
4.29M
  return Value;
36
4.29M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.87M
{
26
1.87M
  const uint8_t *orig_p = p;
27
1.87M
  uint64_t Value = 0;
28
1.87M
  unsigned Shift = 0;
29
1.93M
  do {
30
1.93M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.93M
    Shift += 7;
32
1.93M
  } while (*p++ >= 128);
33
1.87M
  if (n)
34
1.87M
    *n = (unsigned)(p - orig_p);
35
1.87M
  return Value;
36
1.87M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
8.97M
{
26
8.97M
  const uint8_t *orig_p = p;
27
8.97M
  uint64_t Value = 0;
28
8.97M
  unsigned Shift = 0;
29
12.5M
  do {
30
12.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
12.5M
    Shift += 7;
32
12.5M
  } while (*p++ >= 128);
33
8.97M
  if (n)
34
8.97M
    *n = (unsigned)(p - orig_p);
35
8.97M
  return Value;
36
8.97M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
2.14M
{
26
2.14M
  const uint8_t *orig_p = p;
27
2.14M
  uint64_t Value = 0;
28
2.14M
  unsigned Shift = 0;
29
2.64M
  do {
30
2.64M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.64M
    Shift += 7;
32
2.64M
  } while (*p++ >= 128);
33
2.14M
  if (n)
34
2.14M
    *n = (unsigned)(p - orig_p);
35
2.14M
  return Value;
36
2.14M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H