Coverage Report

Created: 2026-09-01 07:20

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
55.2M
{
26
55.2M
  const uint8_t *orig_p = p;
27
55.2M
  uint64_t Value = 0;
28
55.2M
  unsigned Shift = 0;
29
62.1M
  do {
30
62.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
62.1M
    Shift += 7;
32
62.1M
  } while (*p++ >= 128);
33
55.2M
  if (n)
34
55.2M
    *n = (unsigned)(p - orig_p);
35
55.2M
  return Value;
36
55.2M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
778k
{
26
778k
  const uint8_t *orig_p = p;
27
778k
  uint64_t Value = 0;
28
778k
  unsigned Shift = 0;
29
870k
  do {
30
870k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
870k
    Shift += 7;
32
870k
  } while (*p++ >= 128);
33
778k
  if (n)
34
778k
    *n = (unsigned)(p - orig_p);
35
778k
  return Value;
36
778k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
804k
{
26
804k
  const uint8_t *orig_p = p;
27
804k
  uint64_t Value = 0;
28
804k
  unsigned Shift = 0;
29
822k
  do {
30
822k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
822k
    Shift += 7;
32
822k
  } while (*p++ >= 128);
33
804k
  if (n)
34
804k
    *n = (unsigned)(p - orig_p);
35
804k
  return Value;
36
804k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
1.99M
{
26
1.99M
  const uint8_t *orig_p = p;
27
1.99M
  uint64_t Value = 0;
28
1.99M
  unsigned Shift = 0;
29
2.06M
  do {
30
2.06M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.06M
    Shift += 7;
32
2.06M
  } while (*p++ >= 128);
33
1.99M
  if (n)
34
1.99M
    *n = (unsigned)(p - orig_p);
35
1.99M
  return Value;
36
1.99M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
27.3M
{
26
27.3M
  const uint8_t *orig_p = p;
27
27.3M
  uint64_t Value = 0;
28
27.3M
  unsigned Shift = 0;
29
30.3M
  do {
30
30.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
30.3M
    Shift += 7;
32
30.3M
  } while (*p++ >= 128);
33
27.3M
  if (n)
34
27.3M
    *n = (unsigned)(p - orig_p);
35
27.3M
  return Value;
36
27.3M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
5.35M
{
26
5.35M
  const uint8_t *orig_p = p;
27
5.35M
  uint64_t Value = 0;
28
5.35M
  unsigned Shift = 0;
29
5.93M
  do {
30
5.93M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.93M
    Shift += 7;
32
5.93M
  } while (*p++ >= 128);
33
5.35M
  if (n)
34
5.35M
    *n = (unsigned)(p - orig_p);
35
5.35M
  return Value;
36
5.35M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
5.59M
{
26
5.59M
  const uint8_t *orig_p = p;
27
5.59M
  uint64_t Value = 0;
28
5.59M
  unsigned Shift = 0;
29
5.85M
  do {
30
5.85M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.85M
    Shift += 7;
32
5.85M
  } while (*p++ >= 128);
33
5.59M
  if (n)
34
5.59M
    *n = (unsigned)(p - orig_p);
35
5.59M
  return Value;
36
5.59M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
4.34M
{
26
4.34M
  const uint8_t *orig_p = p;
27
4.34M
  uint64_t Value = 0;
28
4.34M
  unsigned Shift = 0;
29
4.52M
  do {
30
4.52M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.52M
    Shift += 7;
32
4.52M
  } while (*p++ >= 128);
33
4.34M
  if (n)
34
4.34M
    *n = (unsigned)(p - orig_p);
35
4.34M
  return Value;
36
4.34M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.57M
{
26
1.57M
  const uint8_t *orig_p = p;
27
1.57M
  uint64_t Value = 0;
28
1.57M
  unsigned Shift = 0;
29
1.62M
  do {
30
1.62M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.62M
    Shift += 7;
32
1.62M
  } while (*p++ >= 128);
33
1.57M
  if (n)
34
1.57M
    *n = (unsigned)(p - orig_p);
35
1.57M
  return Value;
36
1.57M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
6.70M
{
26
6.70M
  const uint8_t *orig_p = p;
27
6.70M
  uint64_t Value = 0;
28
6.70M
  unsigned Shift = 0;
29
9.34M
  do {
30
9.34M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.34M
    Shift += 7;
32
9.34M
  } while (*p++ >= 128);
33
6.70M
  if (n)
34
6.70M
    *n = (unsigned)(p - orig_p);
35
6.70M
  return Value;
36
6.70M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
735k
{
26
735k
  const uint8_t *orig_p = p;
27
735k
  uint64_t Value = 0;
28
735k
  unsigned Shift = 0;
29
792k
  do {
30
792k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
792k
    Shift += 7;
32
792k
  } while (*p++ >= 128);
33
735k
  if (n)
34
735k
    *n = (unsigned)(p - orig_p);
35
735k
  return Value;
36
735k
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H