Coverage Report

Created: 2025-10-12 06:32

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.8M
{
26
46.8M
  const uint8_t *orig_p = p;
27
46.8M
  uint64_t Value = 0;
28
46.8M
  unsigned Shift = 0;
29
53.0M
  do {
30
53.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
53.0M
    Shift += 7;
32
53.0M
  } while (*p++ >= 128);
33
46.8M
  if (n)
34
46.8M
    *n = (unsigned)(p - orig_p);
35
46.8M
  return Value;
36
46.8M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
789k
{
26
789k
  const uint8_t *orig_p = p;
27
789k
  uint64_t Value = 0;
28
789k
  unsigned Shift = 0;
29
865k
  do {
30
865k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
865k
    Shift += 7;
32
865k
  } while (*p++ >= 128);
33
789k
  if (n)
34
789k
    *n = (unsigned)(p - orig_p);
35
789k
  return Value;
36
789k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
880k
{
26
880k
  const uint8_t *orig_p = p;
27
880k
  uint64_t Value = 0;
28
880k
  unsigned Shift = 0;
29
899k
  do {
30
899k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
899k
    Shift += 7;
32
899k
  } while (*p++ >= 128);
33
880k
  if (n)
34
880k
    *n = (unsigned)(p - orig_p);
35
880k
  return Value;
36
880k
}
RISCVDisassembler.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.35M
  do {
30
1.35M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.35M
    Shift += 7;
32
1.35M
  } 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: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
22.9M
{
26
22.9M
  const uint8_t *orig_p = p;
27
22.9M
  uint64_t Value = 0;
28
22.9M
  unsigned Shift = 0;
29
25.4M
  do {
30
25.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
25.4M
    Shift += 7;
32
25.4M
  } while (*p++ >= 128);
33
22.9M
  if (n)
34
22.9M
    *n = (unsigned)(p - orig_p);
35
22.9M
  return Value;
36
22.9M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
4.83M
{
26
4.83M
  const uint8_t *orig_p = p;
27
4.83M
  uint64_t Value = 0;
28
4.83M
  unsigned Shift = 0;
29
5.36M
  do {
30
5.36M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.36M
    Shift += 7;
32
5.36M
  } while (*p++ >= 128);
33
4.83M
  if (n)
34
4.83M
    *n = (unsigned)(p - orig_p);
35
4.83M
  return Value;
36
4.83M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.67M
{
26
3.67M
  const uint8_t *orig_p = p;
27
3.67M
  uint64_t Value = 0;
28
3.67M
  unsigned Shift = 0;
29
3.85M
  do {
30
3.85M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.85M
    Shift += 7;
32
3.85M
  } while (*p++ >= 128);
33
3.67M
  if (n)
34
3.67M
    *n = (unsigned)(p - orig_p);
35
3.67M
  return Value;
36
3.67M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
3.17M
{
26
3.17M
  const uint8_t *orig_p = p;
27
3.17M
  uint64_t Value = 0;
28
3.17M
  unsigned Shift = 0;
29
3.30M
  do {
30
3.30M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.30M
    Shift += 7;
32
3.30M
  } while (*p++ >= 128);
33
3.17M
  if (n)
34
3.17M
    *n = (unsigned)(p - orig_p);
35
3.17M
  return Value;
36
3.17M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.40M
{
26
1.40M
  const uint8_t *orig_p = p;
27
1.40M
  uint64_t Value = 0;
28
1.40M
  unsigned Shift = 0;
29
1.44M
  do {
30
1.44M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.44M
    Shift += 7;
32
1.44M
  } while (*p++ >= 128);
33
1.40M
  if (n)
34
1.40M
    *n = (unsigned)(p - orig_p);
35
1.40M
  return Value;
36
1.40M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
6.23M
{
26
6.23M
  const uint8_t *orig_p = p;
27
6.23M
  uint64_t Value = 0;
28
6.23M
  unsigned Shift = 0;
29
8.61M
  do {
30
8.61M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.61M
    Shift += 7;
32
8.61M
  } while (*p++ >= 128);
33
6.23M
  if (n)
34
6.23M
    *n = (unsigned)(p - orig_p);
35
6.23M
  return Value;
36
6.23M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
1.54M
{
26
1.54M
  const uint8_t *orig_p = p;
27
1.54M
  uint64_t Value = 0;
28
1.54M
  unsigned Shift = 0;
29
1.91M
  do {
30
1.91M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.91M
    Shift += 7;
32
1.91M
  } while (*p++ >= 128);
33
1.54M
  if (n)
34
1.54M
    *n = (unsigned)(p - orig_p);
35
1.54M
  return Value;
36
1.54M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H