Coverage Report

Created: 2026-04-29 06:06

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
98.4M
{
26
98.4M
  const uint8_t *orig_p = p;
27
98.4M
  uint64_t Value = 0;
28
98.4M
  unsigned Shift = 0;
29
111M
  do {
30
111M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
111M
    Shift += 7;
32
111M
  } while (*p++ >= 128);
33
98.4M
  if (n)
34
98.4M
    *n = (unsigned)(p - orig_p);
35
98.4M
  return Value;
36
98.4M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.60M
{
26
1.60M
  const uint8_t *orig_p = p;
27
1.60M
  uint64_t Value = 0;
28
1.60M
  unsigned Shift = 0;
29
1.77M
  do {
30
1.77M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.77M
    Shift += 7;
32
1.77M
  } while (*p++ >= 128);
33
1.60M
  if (n)
34
1.60M
    *n = (unsigned)(p - orig_p);
35
1.60M
  return Value;
36
1.60M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.70M
{
26
1.70M
  const uint8_t *orig_p = p;
27
1.70M
  uint64_t Value = 0;
28
1.70M
  unsigned Shift = 0;
29
1.74M
  do {
30
1.74M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.74M
    Shift += 7;
32
1.74M
  } while (*p++ >= 128);
33
1.70M
  if (n)
34
1.70M
    *n = (unsigned)(p - orig_p);
35
1.70M
  return Value;
36
1.70M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
4.59M
{
26
4.59M
  const uint8_t *orig_p = p;
27
4.59M
  uint64_t Value = 0;
28
4.59M
  unsigned Shift = 0;
29
4.77M
  do {
30
4.77M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.77M
    Shift += 7;
32
4.77M
  } while (*p++ >= 128);
33
4.59M
  if (n)
34
4.59M
    *n = (unsigned)(p - orig_p);
35
4.59M
  return Value;
36
4.59M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
44.9M
{
26
44.9M
  const uint8_t *orig_p = p;
27
44.9M
  uint64_t Value = 0;
28
44.9M
  unsigned Shift = 0;
29
49.7M
  do {
30
49.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
49.7M
    Shift += 7;
32
49.7M
  } while (*p++ >= 128);
33
44.9M
  if (n)
34
44.9M
    *n = (unsigned)(p - orig_p);
35
44.9M
  return Value;
36
44.9M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
11.7M
{
26
11.7M
  const uint8_t *orig_p = p;
27
11.7M
  uint64_t Value = 0;
28
11.7M
  unsigned Shift = 0;
29
12.9M
  do {
30
12.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
12.9M
    Shift += 7;
32
12.9M
  } while (*p++ >= 128);
33
11.7M
  if (n)
34
11.7M
    *n = (unsigned)(p - orig_p);
35
11.7M
  return Value;
36
11.7M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
7.26M
{
26
7.26M
  const uint8_t *orig_p = p;
27
7.26M
  uint64_t Value = 0;
28
7.26M
  unsigned Shift = 0;
29
7.57M
  do {
30
7.57M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.57M
    Shift += 7;
32
7.57M
  } while (*p++ >= 128);
33
7.26M
  if (n)
34
7.26M
    *n = (unsigned)(p - orig_p);
35
7.26M
  return Value;
36
7.26M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
8.13M
{
26
8.13M
  const uint8_t *orig_p = p;
27
8.13M
  uint64_t Value = 0;
28
8.13M
  unsigned Shift = 0;
29
8.46M
  do {
30
8.46M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.46M
    Shift += 7;
32
8.46M
  } while (*p++ >= 128);
33
8.13M
  if (n)
34
8.13M
    *n = (unsigned)(p - orig_p);
35
8.13M
  return Value;
36
8.13M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.04M
{
26
3.04M
  const uint8_t *orig_p = p;
27
3.04M
  uint64_t Value = 0;
28
3.04M
  unsigned Shift = 0;
29
3.13M
  do {
30
3.13M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.13M
    Shift += 7;
32
3.13M
  } while (*p++ >= 128);
33
3.04M
  if (n)
34
3.04M
    *n = (unsigned)(p - orig_p);
35
3.04M
  return Value;
36
3.04M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
12.8M
{
26
12.8M
  const uint8_t *orig_p = p;
27
12.8M
  uint64_t Value = 0;
28
12.8M
  unsigned Shift = 0;
29
17.8M
  do {
30
17.8M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
17.8M
    Shift += 7;
32
17.8M
  } while (*p++ >= 128);
33
12.8M
  if (n)
34
12.8M
    *n = (unsigned)(p - orig_p);
35
12.8M
  return Value;
36
12.8M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
2.58M
{
26
2.58M
  const uint8_t *orig_p = p;
27
2.58M
  uint64_t Value = 0;
28
2.58M
  unsigned Shift = 0;
29
3.07M
  do {
30
3.07M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.07M
    Shift += 7;
32
3.07M
  } while (*p++ >= 128);
33
2.58M
  if (n)
34
2.58M
    *n = (unsigned)(p - orig_p);
35
2.58M
  return Value;
36
2.58M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H