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
114M
{
26
114M
  const uint8_t *orig_p = p;
27
114M
  uint64_t Value = 0;
28
114M
  unsigned Shift = 0;
29
128M
  do {
30
128M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
128M
    Shift += 7;
32
128M
  } while (*p++ >= 128);
33
114M
  if (n)
34
114M
    *n = (unsigned)(p - orig_p);
35
114M
  return Value;
36
114M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.52M
{
26
1.52M
  const uint8_t *orig_p = p;
27
1.52M
  uint64_t Value = 0;
28
1.52M
  unsigned Shift = 0;
29
1.68M
  do {
30
1.68M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.68M
    Shift += 7;
32
1.68M
  } while (*p++ >= 128);
33
1.52M
  if (n)
34
1.52M
    *n = (unsigned)(p - orig_p);
35
1.52M
  return Value;
36
1.52M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.95M
{
26
1.95M
  const uint8_t *orig_p = p;
27
1.95M
  uint64_t Value = 0;
28
1.95M
  unsigned Shift = 0;
29
2.00M
  do {
30
2.00M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.00M
    Shift += 7;
32
2.00M
  } while (*p++ >= 128);
33
1.95M
  if (n)
34
1.95M
    *n = (unsigned)(p - orig_p);
35
1.95M
  return Value;
36
1.95M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
5.55M
{
26
5.55M
  const uint8_t *orig_p = p;
27
5.55M
  uint64_t Value = 0;
28
5.55M
  unsigned Shift = 0;
29
5.80M
  do {
30
5.80M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.80M
    Shift += 7;
32
5.80M
  } while (*p++ >= 128);
33
5.55M
  if (n)
34
5.55M
    *n = (unsigned)(p - orig_p);
35
5.55M
  return Value;
36
5.55M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
50.5M
{
26
50.5M
  const uint8_t *orig_p = p;
27
50.5M
  uint64_t Value = 0;
28
50.5M
  unsigned Shift = 0;
29
55.9M
  do {
30
55.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
55.9M
    Shift += 7;
32
55.9M
  } while (*p++ >= 128);
33
50.5M
  if (n)
34
50.5M
    *n = (unsigned)(p - orig_p);
35
50.5M
  return Value;
36
50.5M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
15.6M
{
26
15.6M
  const uint8_t *orig_p = p;
27
15.6M
  uint64_t Value = 0;
28
15.6M
  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
15.6M
  if (n)
34
15.6M
    *n = (unsigned)(p - orig_p);
35
15.6M
  return Value;
36
15.6M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
8.09M
{
26
8.09M
  const uint8_t *orig_p = p;
27
8.09M
  uint64_t Value = 0;
28
8.09M
  unsigned Shift = 0;
29
8.44M
  do {
30
8.44M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.44M
    Shift += 7;
32
8.44M
  } while (*p++ >= 128);
33
8.09M
  if (n)
34
8.09M
    *n = (unsigned)(p - orig_p);
35
8.09M
  return Value;
36
8.09M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
10.0M
{
26
10.0M
  const uint8_t *orig_p = p;
27
10.0M
  uint64_t Value = 0;
28
10.0M
  unsigned Shift = 0;
29
10.4M
  do {
30
10.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.4M
    Shift += 7;
32
10.4M
  } while (*p++ >= 128);
33
10.0M
  if (n)
34
10.0M
    *n = (unsigned)(p - orig_p);
35
10.0M
  return Value;
36
10.0M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.75M
{
26
3.75M
  const uint8_t *orig_p = p;
27
3.75M
  uint64_t Value = 0;
28
3.75M
  unsigned Shift = 0;
29
3.85M
  do {
30
3.85M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.85M
    Shift += 7;
32
3.85M
  } while (*p++ >= 128);
33
3.75M
  if (n)
34
3.75M
    *n = (unsigned)(p - orig_p);
35
3.75M
  return Value;
36
3.75M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
14.7M
{
26
14.7M
  const uint8_t *orig_p = p;
27
14.7M
  uint64_t Value = 0;
28
14.7M
  unsigned Shift = 0;
29
20.5M
  do {
30
20.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
20.5M
    Shift += 7;
32
20.5M
  } while (*p++ >= 128);
33
14.7M
  if (n)
34
14.7M
    *n = (unsigned)(p - orig_p);
35
14.7M
  return Value;
36
14.7M
}
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