Coverage Report

Created: 2025-11-24 06:12

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
71.0M
{
26
71.0M
  const uint8_t *orig_p = p;
27
71.0M
  uint64_t Value = 0;
28
71.0M
  unsigned Shift = 0;
29
81.1M
  do {
30
81.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
81.1M
    Shift += 7;
32
81.1M
  } while (*p++ >= 128);
33
71.0M
  if (n)
34
71.0M
    *n = (unsigned)(p - orig_p);
35
71.0M
  return Value;
36
71.0M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
754k
{
26
754k
  const uint8_t *orig_p = p;
27
754k
  uint64_t Value = 0;
28
754k
  unsigned Shift = 0;
29
841k
  do {
30
841k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
841k
    Shift += 7;
32
841k
  } while (*p++ >= 128);
33
754k
  if (n)
34
754k
    *n = (unsigned)(p - orig_p);
35
754k
  return Value;
36
754k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.08M
{
26
1.08M
  const uint8_t *orig_p = p;
27
1.08M
  uint64_t Value = 0;
28
1.08M
  unsigned Shift = 0;
29
1.10M
  do {
30
1.10M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.10M
    Shift += 7;
32
1.10M
  } while (*p++ >= 128);
33
1.08M
  if (n)
34
1.08M
    *n = (unsigned)(p - orig_p);
35
1.08M
  return Value;
36
1.08M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.55M
{
26
3.55M
  const uint8_t *orig_p = p;
27
3.55M
  uint64_t Value = 0;
28
3.55M
  unsigned Shift = 0;
29
3.71M
  do {
30
3.71M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.71M
    Shift += 7;
32
3.71M
  } while (*p++ >= 128);
33
3.55M
  if (n)
34
3.55M
    *n = (unsigned)(p - orig_p);
35
3.55M
  return Value;
36
3.55M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
30.6M
{
26
30.6M
  const uint8_t *orig_p = p;
27
30.6M
  uint64_t Value = 0;
28
30.6M
  unsigned Shift = 0;
29
33.7M
  do {
30
33.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
33.7M
    Shift += 7;
32
33.7M
  } while (*p++ >= 128);
33
30.6M
  if (n)
34
30.6M
    *n = (unsigned)(p - orig_p);
35
30.6M
  return Value;
36
30.6M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
9.83M
{
26
9.83M
  const uint8_t *orig_p = p;
27
9.83M
  uint64_t Value = 0;
28
9.83M
  unsigned Shift = 0;
29
10.8M
  do {
30
10.8M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.8M
    Shift += 7;
32
10.8M
  } while (*p++ >= 128);
33
9.83M
  if (n)
34
9.83M
    *n = (unsigned)(p - orig_p);
35
9.83M
  return Value;
36
9.83M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
5.23M
{
26
5.23M
  const uint8_t *orig_p = p;
27
5.23M
  uint64_t Value = 0;
28
5.23M
  unsigned Shift = 0;
29
5.46M
  do {
30
5.46M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.46M
    Shift += 7;
32
5.46M
  } while (*p++ >= 128);
33
5.23M
  if (n)
34
5.23M
    *n = (unsigned)(p - orig_p);
35
5.23M
  return Value;
36
5.23M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
4.35M
{
26
4.35M
  const uint8_t *orig_p = p;
27
4.35M
  uint64_t Value = 0;
28
4.35M
  unsigned Shift = 0;
29
4.50M
  do {
30
4.50M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.50M
    Shift += 7;
32
4.50M
  } while (*p++ >= 128);
33
4.35M
  if (n)
34
4.35M
    *n = (unsigned)(p - orig_p);
35
4.35M
  return Value;
36
4.35M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.82M
{
26
1.82M
  const uint8_t *orig_p = p;
27
1.82M
  uint64_t Value = 0;
28
1.82M
  unsigned Shift = 0;
29
1.88M
  do {
30
1.88M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.88M
    Shift += 7;
32
1.88M
  } while (*p++ >= 128);
33
1.82M
  if (n)
34
1.82M
    *n = (unsigned)(p - orig_p);
35
1.82M
  return Value;
36
1.82M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
11.1M
{
26
11.1M
  const uint8_t *orig_p = p;
27
11.1M
  uint64_t Value = 0;
28
11.1M
  unsigned Shift = 0;
29
15.6M
  do {
30
15.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
15.6M
    Shift += 7;
32
15.6M
  } while (*p++ >= 128);
33
11.1M
  if (n)
34
11.1M
    *n = (unsigned)(p - orig_p);
35
11.1M
  return Value;
36
11.1M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
2.63M
{
26
2.63M
  const uint8_t *orig_p = p;
27
2.63M
  uint64_t Value = 0;
28
2.63M
  unsigned Shift = 0;
29
3.30M
  do {
30
3.30M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.30M
    Shift += 7;
32
3.30M
  } while (*p++ >= 128);
33
2.63M
  if (n)
34
2.63M
    *n = (unsigned)(p - orig_p);
35
2.63M
  return Value;
36
2.63M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H