Coverage Report

Created: 2026-08-31 06:58

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
128M
{
26
128M
  const uint8_t *orig_p = p;
27
128M
  uint64_t Value = 0;
28
128M
  unsigned Shift = 0;
29
144M
  do {
30
144M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
144M
    Shift += 7;
32
144M
  } while (*p++ >= 128);
33
128M
  if (n)
34
128M
    *n = (unsigned)(p - orig_p);
35
128M
  return Value;
36
128M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.81M
{
26
1.81M
  const uint8_t *orig_p = p;
27
1.81M
  uint64_t Value = 0;
28
1.81M
  unsigned Shift = 0;
29
2.01M
  do {
30
2.01M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.01M
    Shift += 7;
32
2.01M
  } while (*p++ >= 128);
33
1.81M
  if (n)
34
1.81M
    *n = (unsigned)(p - orig_p);
35
1.81M
  return Value;
36
1.81M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
2.28M
{
26
2.28M
  const uint8_t *orig_p = p;
27
2.28M
  uint64_t Value = 0;
28
2.28M
  unsigned Shift = 0;
29
2.33M
  do {
30
2.33M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.33M
    Shift += 7;
32
2.33M
  } while (*p++ >= 128);
33
2.28M
  if (n)
34
2.28M
    *n = (unsigned)(p - orig_p);
35
2.28M
  return Value;
36
2.28M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
5.61M
{
26
5.61M
  const uint8_t *orig_p = p;
27
5.61M
  uint64_t Value = 0;
28
5.61M
  unsigned Shift = 0;
29
5.83M
  do {
30
5.83M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.83M
    Shift += 7;
32
5.83M
  } while (*p++ >= 128);
33
5.61M
  if (n)
34
5.61M
    *n = (unsigned)(p - orig_p);
35
5.61M
  return Value;
36
5.61M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
59.3M
{
26
59.3M
  const uint8_t *orig_p = p;
27
59.3M
  uint64_t Value = 0;
28
59.3M
  unsigned Shift = 0;
29
65.8M
  do {
30
65.8M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
65.8M
    Shift += 7;
32
65.8M
  } while (*p++ >= 128);
33
59.3M
  if (n)
34
59.3M
    *n = (unsigned)(p - orig_p);
35
59.3M
  return Value;
36
59.3M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
14.8M
{
26
14.8M
  const uint8_t *orig_p = p;
27
14.8M
  uint64_t Value = 0;
28
14.8M
  unsigned Shift = 0;
29
16.3M
  do {
30
16.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
16.3M
    Shift += 7;
32
16.3M
  } while (*p++ >= 128);
33
14.8M
  if (n)
34
14.8M
    *n = (unsigned)(p - orig_p);
35
14.8M
  return Value;
36
14.8M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
10.9M
{
26
10.9M
  const uint8_t *orig_p = p;
27
10.9M
  uint64_t Value = 0;
28
10.9M
  unsigned Shift = 0;
29
11.4M
  do {
30
11.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
11.4M
    Shift += 7;
32
11.4M
  } while (*p++ >= 128);
33
10.9M
  if (n)
34
10.9M
    *n = (unsigned)(p - orig_p);
35
10.9M
  return Value;
36
10.9M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
11.5M
{
26
11.5M
  const uint8_t *orig_p = p;
27
11.5M
  uint64_t Value = 0;
28
11.5M
  unsigned Shift = 0;
29
11.9M
  do {
30
11.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
11.9M
    Shift += 7;
32
11.9M
  } while (*p++ >= 128);
33
11.5M
  if (n)
34
11.5M
    *n = (unsigned)(p - orig_p);
35
11.5M
  return Value;
36
11.5M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.91M
{
26
3.91M
  const uint8_t *orig_p = p;
27
3.91M
  uint64_t Value = 0;
28
3.91M
  unsigned Shift = 0;
29
4.03M
  do {
30
4.03M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.03M
    Shift += 7;
32
4.03M
  } while (*p++ >= 128);
33
3.91M
  if (n)
34
3.91M
    *n = (unsigned)(p - orig_p);
35
3.91M
  return Value;
36
3.91M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
16.6M
{
26
16.6M
  const uint8_t *orig_p = p;
27
16.6M
  uint64_t Value = 0;
28
16.6M
  unsigned Shift = 0;
29
23.1M
  do {
30
23.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
23.1M
    Shift += 7;
32
23.1M
  } while (*p++ >= 128);
33
16.6M
  if (n)
34
16.6M
    *n = (unsigned)(p - orig_p);
35
16.6M
  return Value;
36
16.6M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
1.01M
{
26
1.01M
  const uint8_t *orig_p = p;
27
1.01M
  uint64_t Value = 0;
28
1.01M
  unsigned Shift = 0;
29
1.09M
  do {
30
1.09M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.09M
    Shift += 7;
32
1.09M
  } while (*p++ >= 128);
33
1.01M
  if (n)
34
1.01M
    *n = (unsigned)(p - orig_p);
35
1.01M
  return Value;
36
1.01M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H