Coverage Report

Created: 2026-03-13 06:50

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
46.3M
{
26
46.3M
  const uint8_t *orig_p = p;
27
46.3M
  uint64_t Value = 0;
28
46.3M
  unsigned Shift = 0;
29
52.3M
  do {
30
52.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
52.3M
    Shift += 7;
32
52.3M
  } while (*p++ >= 128);
33
46.3M
  if (n)
34
46.3M
    *n = (unsigned)(p - orig_p);
35
46.3M
  return Value;
36
46.3M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
706k
{
26
706k
  const uint8_t *orig_p = p;
27
706k
  uint64_t Value = 0;
28
706k
  unsigned Shift = 0;
29
784k
  do {
30
784k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
784k
    Shift += 7;
32
784k
  } while (*p++ >= 128);
33
706k
  if (n)
34
706k
    *n = (unsigned)(p - orig_p);
35
706k
  return Value;
36
706k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
860k
{
26
860k
  const uint8_t *orig_p = p;
27
860k
  uint64_t Value = 0;
28
860k
  unsigned Shift = 0;
29
881k
  do {
30
881k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
881k
    Shift += 7;
32
881k
  } while (*p++ >= 128);
33
860k
  if (n)
34
860k
    *n = (unsigned)(p - orig_p);
35
860k
  return Value;
36
860k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
1.90M
{
26
1.90M
  const uint8_t *orig_p = p;
27
1.90M
  uint64_t Value = 0;
28
1.90M
  unsigned Shift = 0;
29
1.99M
  do {
30
1.99M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.99M
    Shift += 7;
32
1.99M
  } while (*p++ >= 128);
33
1.90M
  if (n)
34
1.90M
    *n = (unsigned)(p - orig_p);
35
1.90M
  return Value;
36
1.90M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
22.6M
{
26
22.6M
  const uint8_t *orig_p = p;
27
22.6M
  uint64_t Value = 0;
28
22.6M
  unsigned Shift = 0;
29
25.0M
  do {
30
25.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
25.0M
    Shift += 7;
32
25.0M
  } while (*p++ >= 128);
33
22.6M
  if (n)
34
22.6M
    *n = (unsigned)(p - orig_p);
35
22.6M
  return Value;
36
22.6M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
5.01M
{
26
5.01M
  const uint8_t *orig_p = p;
27
5.01M
  uint64_t Value = 0;
28
5.01M
  unsigned Shift = 0;
29
5.52M
  do {
30
5.52M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.52M
    Shift += 7;
32
5.52M
  } while (*p++ >= 128);
33
5.01M
  if (n)
34
5.01M
    *n = (unsigned)(p - orig_p);
35
5.01M
  return Value;
36
5.01M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.70M
{
26
3.70M
  const uint8_t *orig_p = p;
27
3.70M
  uint64_t Value = 0;
28
3.70M
  unsigned Shift = 0;
29
3.86M
  do {
30
3.86M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.86M
    Shift += 7;
32
3.86M
  } while (*p++ >= 128);
33
3.70M
  if (n)
34
3.70M
    *n = (unsigned)(p - orig_p);
35
3.70M
  return Value;
36
3.70M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
2.69M
{
26
2.69M
  const uint8_t *orig_p = p;
27
2.69M
  uint64_t Value = 0;
28
2.69M
  unsigned Shift = 0;
29
2.81M
  do {
30
2.81M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.81M
    Shift += 7;
32
2.81M
  } while (*p++ >= 128);
33
2.69M
  if (n)
34
2.69M
    *n = (unsigned)(p - orig_p);
35
2.69M
  return Value;
36
2.69M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.29M
{
26
1.29M
  const uint8_t *orig_p = p;
27
1.29M
  uint64_t Value = 0;
28
1.29M
  unsigned Shift = 0;
29
1.33M
  do {
30
1.33M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.33M
    Shift += 7;
32
1.33M
  } while (*p++ >= 128);
33
1.29M
  if (n)
34
1.29M
    *n = (unsigned)(p - orig_p);
35
1.29M
  return Value;
36
1.29M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
5.76M
{
26
5.76M
  const uint8_t *orig_p = p;
27
5.76M
  uint64_t Value = 0;
28
5.76M
  unsigned Shift = 0;
29
7.97M
  do {
30
7.97M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.97M
    Shift += 7;
32
7.97M
  } while (*p++ >= 128);
33
5.76M
  if (n)
34
5.76M
    *n = (unsigned)(p - orig_p);
35
5.76M
  return Value;
36
5.76M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
1.74M
{
26
1.74M
  const uint8_t *orig_p = p;
27
1.74M
  uint64_t Value = 0;
28
1.74M
  unsigned Shift = 0;
29
2.11M
  do {
30
2.11M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.11M
    Shift += 7;
32
2.11M
  } while (*p++ >= 128);
33
1.74M
  if (n)
34
1.74M
    *n = (unsigned)(p - orig_p);
35
1.74M
  return Value;
36
1.74M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H