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
78.2M
{
26
78.2M
  const uint8_t *orig_p = p;
27
78.2M
  uint64_t Value = 0;
28
78.2M
  unsigned Shift = 0;
29
89.2M
  do {
30
89.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
89.2M
    Shift += 7;
32
89.2M
  } while (*p++ >= 128);
33
78.2M
  if (n)
34
78.2M
    *n = (unsigned)(p - orig_p);
35
78.2M
  return Value;
36
78.2M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
815k
{
26
815k
  const uint8_t *orig_p = p;
27
815k
  uint64_t Value = 0;
28
815k
  unsigned Shift = 0;
29
909k
  do {
30
909k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
909k
    Shift += 7;
32
909k
  } while (*p++ >= 128);
33
815k
  if (n)
34
815k
    *n = (unsigned)(p - orig_p);
35
815k
  return Value;
36
815k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.15M
{
26
1.15M
  const uint8_t *orig_p = p;
27
1.15M
  uint64_t Value = 0;
28
1.15M
  unsigned Shift = 0;
29
1.17M
  do {
30
1.17M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.17M
    Shift += 7;
32
1.17M
  } while (*p++ >= 128);
33
1.15M
  if (n)
34
1.15M
    *n = (unsigned)(p - orig_p);
35
1.15M
  return Value;
36
1.15M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.98M
{
26
3.98M
  const uint8_t *orig_p = p;
27
3.98M
  uint64_t Value = 0;
28
3.98M
  unsigned Shift = 0;
29
4.15M
  do {
30
4.15M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.15M
    Shift += 7;
32
4.15M
  } while (*p++ >= 128);
33
3.98M
  if (n)
34
3.98M
    *n = (unsigned)(p - orig_p);
35
3.98M
  return Value;
36
3.98M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
33.2M
{
26
33.2M
  const uint8_t *orig_p = p;
27
33.2M
  uint64_t Value = 0;
28
33.2M
  unsigned Shift = 0;
29
36.6M
  do {
30
36.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
36.6M
    Shift += 7;
32
36.6M
  } while (*p++ >= 128);
33
33.2M
  if (n)
34
33.2M
    *n = (unsigned)(p - orig_p);
35
33.2M
  return Value;
36
33.2M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
11.0M
{
26
11.0M
  const uint8_t *orig_p = p;
27
11.0M
  uint64_t Value = 0;
28
11.0M
  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.0M
  if (n)
34
11.0M
    *n = (unsigned)(p - orig_p);
35
11.0M
  return Value;
36
11.0M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
5.64M
{
26
5.64M
  const uint8_t *orig_p = p;
27
5.64M
  uint64_t Value = 0;
28
5.64M
  unsigned Shift = 0;
29
5.89M
  do {
30
5.89M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.89M
    Shift += 7;
32
5.89M
  } while (*p++ >= 128);
33
5.64M
  if (n)
34
5.64M
    *n = (unsigned)(p - orig_p);
35
5.64M
  return Value;
36
5.64M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
5.40M
{
26
5.40M
  const uint8_t *orig_p = p;
27
5.40M
  uint64_t Value = 0;
28
5.40M
  unsigned Shift = 0;
29
5.60M
  do {
30
5.60M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.60M
    Shift += 7;
32
5.60M
  } while (*p++ >= 128);
33
5.40M
  if (n)
34
5.40M
    *n = (unsigned)(p - orig_p);
35
5.40M
  return Value;
36
5.40M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.13M
{
26
2.13M
  const uint8_t *orig_p = p;
27
2.13M
  uint64_t Value = 0;
28
2.13M
  unsigned Shift = 0;
29
2.20M
  do {
30
2.20M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.20M
    Shift += 7;
32
2.20M
  } while (*p++ >= 128);
33
2.13M
  if (n)
34
2.13M
    *n = (unsigned)(p - orig_p);
35
2.13M
  return Value;
36
2.13M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
12.1M
{
26
12.1M
  const uint8_t *orig_p = p;
27
12.1M
  uint64_t Value = 0;
28
12.1M
  unsigned Shift = 0;
29
17.1M
  do {
30
17.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
17.1M
    Shift += 7;
32
17.1M
  } while (*p++ >= 128);
33
12.1M
  if (n)
34
12.1M
    *n = (unsigned)(p - orig_p);
35
12.1M
  return Value;
36
12.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