Coverage Report

Created: 2026-05-30 06:22

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
50.8M
{
26
50.8M
  const uint8_t *orig_p = p;
27
50.8M
  uint64_t Value = 0;
28
50.8M
  unsigned Shift = 0;
29
57.5M
  do {
30
57.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
57.5M
    Shift += 7;
32
57.5M
  } while (*p++ >= 128);
33
50.8M
  if (n)
34
50.8M
    *n = (unsigned)(p - orig_p);
35
50.8M
  return Value;
36
50.8M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
699k
{
26
699k
  const uint8_t *orig_p = p;
27
699k
  uint64_t Value = 0;
28
699k
  unsigned Shift = 0;
29
789k
  do {
30
789k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
789k
    Shift += 7;
32
789k
  } while (*p++ >= 128);
33
699k
  if (n)
34
699k
    *n = (unsigned)(p - orig_p);
35
699k
  return Value;
36
699k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
805k
{
26
805k
  const uint8_t *orig_p = p;
27
805k
  uint64_t Value = 0;
28
805k
  unsigned Shift = 0;
29
824k
  do {
30
824k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
824k
    Shift += 7;
32
824k
  } while (*p++ >= 128);
33
805k
  if (n)
34
805k
    *n = (unsigned)(p - orig_p);
35
805k
  return Value;
36
805k
}
RISCVDisassembler.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
1.82M
  do {
30
1.82M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.82M
    Shift += 7;
32
1.82M
  } 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: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
24.9M
{
26
24.9M
  const uint8_t *orig_p = p;
27
24.9M
  uint64_t Value = 0;
28
24.9M
  unsigned Shift = 0;
29
27.7M
  do {
30
27.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
27.7M
    Shift += 7;
32
27.7M
  } while (*p++ >= 128);
33
24.9M
  if (n)
34
24.9M
    *n = (unsigned)(p - orig_p);
35
24.9M
  return Value;
36
24.9M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
5.23M
{
26
5.23M
  const uint8_t *orig_p = p;
27
5.23M
  uint64_t Value = 0;
28
5.23M
  unsigned Shift = 0;
29
5.77M
  do {
30
5.77M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.77M
    Shift += 7;
32
5.77M
  } while (*p++ >= 128);
33
5.23M
  if (n)
34
5.23M
    *n = (unsigned)(p - orig_p);
35
5.23M
  return Value;
36
5.23M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
4.38M
{
26
4.38M
  const uint8_t *orig_p = p;
27
4.38M
  uint64_t Value = 0;
28
4.38M
  unsigned Shift = 0;
29
4.58M
  do {
30
4.58M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.58M
    Shift += 7;
32
4.58M
  } while (*p++ >= 128);
33
4.38M
  if (n)
34
4.38M
    *n = (unsigned)(p - orig_p);
35
4.38M
  return Value;
36
4.38M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
3.15M
{
26
3.15M
  const uint8_t *orig_p = p;
27
3.15M
  uint64_t Value = 0;
28
3.15M
  unsigned Shift = 0;
29
3.27M
  do {
30
3.27M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.27M
    Shift += 7;
32
3.27M
  } while (*p++ >= 128);
33
3.15M
  if (n)
34
3.15M
    *n = (unsigned)(p - orig_p);
35
3.15M
  return Value;
36
3.15M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.44M
{
26
1.44M
  const uint8_t *orig_p = p;
27
1.44M
  uint64_t Value = 0;
28
1.44M
  unsigned Shift = 0;
29
1.48M
  do {
30
1.48M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.48M
    Shift += 7;
32
1.48M
  } while (*p++ >= 128);
33
1.44M
  if (n)
34
1.44M
    *n = (unsigned)(p - orig_p);
35
1.44M
  return Value;
36
1.44M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
6.28M
{
26
6.28M
  const uint8_t *orig_p = p;
27
6.28M
  uint64_t Value = 0;
28
6.28M
  unsigned Shift = 0;
29
8.72M
  do {
30
8.72M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.72M
    Shift += 7;
32
8.72M
  } while (*p++ >= 128);
33
6.28M
  if (n)
34
6.28M
    *n = (unsigned)(p - orig_p);
35
6.28M
  return Value;
36
6.28M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
2.12M
{
26
2.12M
  const uint8_t *orig_p = p;
27
2.12M
  uint64_t Value = 0;
28
2.12M
  unsigned Shift = 0;
29
2.53M
  do {
30
2.53M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.53M
    Shift += 7;
32
2.53M
  } while (*p++ >= 128);
33
2.12M
  if (n)
34
2.12M
    *n = (unsigned)(p - orig_p);
35
2.12M
  return Value;
36
2.12M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H