Coverage Report

Created: 2025-10-12 06:32

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
86.3M
{
26
86.3M
  const uint8_t *orig_p = p;
27
86.3M
  uint64_t Value = 0;
28
86.3M
  unsigned Shift = 0;
29
97.1M
  do {
30
97.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
97.1M
    Shift += 7;
32
97.1M
  } while (*p++ >= 128);
33
86.3M
  if (n)
34
86.3M
    *n = (unsigned)(p - orig_p);
35
86.3M
  return Value;
36
86.3M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.50M
{
26
1.50M
  const uint8_t *orig_p = p;
27
1.50M
  uint64_t Value = 0;
28
1.50M
  unsigned Shift = 0;
29
1.67M
  do {
30
1.67M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.67M
    Shift += 7;
32
1.67M
  } while (*p++ >= 128);
33
1.50M
  if (n)
34
1.50M
    *n = (unsigned)(p - orig_p);
35
1.50M
  return Value;
36
1.50M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.69M
{
26
1.69M
  const uint8_t *orig_p = p;
27
1.69M
  uint64_t Value = 0;
28
1.69M
  unsigned Shift = 0;
29
1.73M
  do {
30
1.73M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.73M
    Shift += 7;
32
1.73M
  } while (*p++ >= 128);
33
1.69M
  if (n)
34
1.69M
    *n = (unsigned)(p - orig_p);
35
1.69M
  return Value;
36
1.69M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.30M
{
26
3.30M
  const uint8_t *orig_p = p;
27
3.30M
  uint64_t Value = 0;
28
3.30M
  unsigned Shift = 0;
29
3.44M
  do {
30
3.44M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.44M
    Shift += 7;
32
3.44M
  } while (*p++ >= 128);
33
3.30M
  if (n)
34
3.30M
    *n = (unsigned)(p - orig_p);
35
3.30M
  return Value;
36
3.30M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
39.4M
{
26
39.4M
  const uint8_t *orig_p = p;
27
39.4M
  uint64_t Value = 0;
28
39.4M
  unsigned Shift = 0;
29
43.6M
  do {
30
43.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
43.6M
    Shift += 7;
32
43.6M
  } while (*p++ >= 128);
33
39.4M
  if (n)
34
39.4M
    *n = (unsigned)(p - orig_p);
35
39.4M
  return Value;
36
39.4M
}
AArch64Disassembler.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
12.2M
  do {
30
12.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
12.2M
    Shift += 7;
32
12.2M
  } while (*p++ >= 128);
33
11.1M
  if (n)
34
11.1M
    *n = (unsigned)(p - orig_p);
35
11.1M
  return Value;
36
11.1M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
6.49M
{
26
6.49M
  const uint8_t *orig_p = p;
27
6.49M
  uint64_t Value = 0;
28
6.49M
  unsigned Shift = 0;
29
6.77M
  do {
30
6.77M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.77M
    Shift += 7;
32
6.77M
  } while (*p++ >= 128);
33
6.49M
  if (n)
34
6.49M
    *n = (unsigned)(p - orig_p);
35
6.49M
  return Value;
36
6.49M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
7.68M
{
26
7.68M
  const uint8_t *orig_p = p;
27
7.68M
  uint64_t Value = 0;
28
7.68M
  unsigned Shift = 0;
29
8.00M
  do {
30
8.00M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.00M
    Shift += 7;
32
8.00M
  } while (*p++ >= 128);
33
7.68M
  if (n)
34
7.68M
    *n = (unsigned)(p - orig_p);
35
7.68M
  return Value;
36
7.68M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.82M
{
26
2.82M
  const uint8_t *orig_p = p;
27
2.82M
  uint64_t Value = 0;
28
2.82M
  unsigned Shift = 0;
29
2.89M
  do {
30
2.89M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.89M
    Shift += 7;
32
2.89M
  } while (*p++ >= 128);
33
2.82M
  if (n)
34
2.82M
    *n = (unsigned)(p - orig_p);
35
2.82M
  return Value;
36
2.82M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
10.7M
{
26
10.7M
  const uint8_t *orig_p = p;
27
10.7M
  uint64_t Value = 0;
28
10.7M
  unsigned Shift = 0;
29
14.7M
  do {
30
14.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
14.7M
    Shift += 7;
32
14.7M
  } while (*p++ >= 128);
33
10.7M
  if (n)
34
10.7M
    *n = (unsigned)(p - orig_p);
35
10.7M
  return Value;
36
10.7M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
1.54M
{
26
1.54M
  const uint8_t *orig_p = p;
27
1.54M
  uint64_t Value = 0;
28
1.54M
  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.54M
  if (n)
34
1.54M
    *n = (unsigned)(p - orig_p);
35
1.54M
  return Value;
36
1.54M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H