Coverage Report

Created: 2025-12-05 06:11

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
64.0M
{
26
64.0M
  const uint8_t *orig_p = p;
27
64.0M
  uint64_t Value = 0;
28
64.0M
  unsigned Shift = 0;
29
73.0M
  do {
30
73.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
73.0M
    Shift += 7;
32
73.0M
  } while (*p++ >= 128);
33
64.0M
  if (n)
34
64.0M
    *n = (unsigned)(p - orig_p);
35
64.0M
  return Value;
36
64.0M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
806k
{
26
806k
  const uint8_t *orig_p = p;
27
806k
  uint64_t Value = 0;
28
806k
  unsigned Shift = 0;
29
881k
  do {
30
881k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
881k
    Shift += 7;
32
881k
  } while (*p++ >= 128);
33
806k
  if (n)
34
806k
    *n = (unsigned)(p - orig_p);
35
806k
  return Value;
36
806k
}
TMS320C64xDisassembler.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.03M
  do {
30
1.03M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.03M
    Shift += 7;
32
1.03M
  } while (*p++ >= 128);
33
1.01M
  if (n)
34
1.01M
    *n = (unsigned)(p - orig_p);
35
1.01M
  return Value;
36
1.01M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.05M
{
26
3.05M
  const uint8_t *orig_p = p;
27
3.05M
  uint64_t Value = 0;
28
3.05M
  unsigned Shift = 0;
29
3.18M
  do {
30
3.18M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.18M
    Shift += 7;
32
3.18M
  } while (*p++ >= 128);
33
3.05M
  if (n)
34
3.05M
    *n = (unsigned)(p - orig_p);
35
3.05M
  return Value;
36
3.05M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
28.5M
{
26
28.5M
  const uint8_t *orig_p = p;
27
28.5M
  uint64_t Value = 0;
28
28.5M
  unsigned Shift = 0;
29
31.4M
  do {
30
31.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
31.4M
    Shift += 7;
32
31.4M
  } while (*p++ >= 128);
33
28.5M
  if (n)
34
28.5M
    *n = (unsigned)(p - orig_p);
35
28.5M
  return Value;
36
28.5M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
8.04M
{
26
8.04M
  const uint8_t *orig_p = p;
27
8.04M
  uint64_t Value = 0;
28
8.04M
  unsigned Shift = 0;
29
8.89M
  do {
30
8.89M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.89M
    Shift += 7;
32
8.89M
  } while (*p++ >= 128);
33
8.04M
  if (n)
34
8.04M
    *n = (unsigned)(p - orig_p);
35
8.04M
  return Value;
36
8.04M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
4.86M
{
26
4.86M
  const uint8_t *orig_p = p;
27
4.86M
  uint64_t Value = 0;
28
4.86M
  unsigned Shift = 0;
29
5.08M
  do {
30
5.08M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.08M
    Shift += 7;
32
5.08M
  } while (*p++ >= 128);
33
4.86M
  if (n)
34
4.86M
    *n = (unsigned)(p - orig_p);
35
4.86M
  return Value;
36
4.86M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
4.04M
{
26
4.04M
  const uint8_t *orig_p = p;
27
4.04M
  uint64_t Value = 0;
28
4.04M
  unsigned Shift = 0;
29
4.19M
  do {
30
4.19M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.19M
    Shift += 7;
32
4.19M
  } while (*p++ >= 128);
33
4.04M
  if (n)
34
4.04M
    *n = (unsigned)(p - orig_p);
35
4.04M
  return Value;
36
4.04M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.75M
{
26
1.75M
  const uint8_t *orig_p = p;
27
1.75M
  uint64_t Value = 0;
28
1.75M
  unsigned Shift = 0;
29
1.81M
  do {
30
1.81M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.81M
    Shift += 7;
32
1.81M
  } while (*p++ >= 128);
33
1.75M
  if (n)
34
1.75M
    *n = (unsigned)(p - orig_p);
35
1.75M
  return Value;
36
1.75M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
9.78M
{
26
9.78M
  const uint8_t *orig_p = p;
27
9.78M
  uint64_t Value = 0;
28
9.78M
  unsigned Shift = 0;
29
13.7M
  do {
30
13.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
13.7M
    Shift += 7;
32
13.7M
  } while (*p++ >= 128);
33
9.78M
  if (n)
34
9.78M
    *n = (unsigned)(p - orig_p);
35
9.78M
  return Value;
36
9.78M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
2.13M
{
26
2.13M
  const uint8_t *orig_p = p;
27
2.13M
  uint64_t Value = 0;
28
2.13M
  unsigned Shift = 0;
29
2.68M
  do {
30
2.68M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.68M
    Shift += 7;
32
2.68M
  } while (*p++ >= 128);
33
2.13M
  if (n)
34
2.13M
    *n = (unsigned)(p - orig_p);
35
2.13M
  return Value;
36
2.13M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H