Coverage Report

Created: 2026-11-12 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
73.5M
{
26
73.5M
  const uint8_t *orig_p = p;
27
73.5M
  uint64_t Value = 0;
28
73.5M
  unsigned Shift = 0;
29
83.4M
  do {
30
83.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
83.4M
    Shift += 7;
32
83.4M
  } while (*p++ >= 128);
33
73.5M
  if (n)
34
73.5M
    *n = (unsigned)(p - orig_p);
35
73.5M
  return Value;
36
73.5M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
718k
{
26
718k
  const uint8_t *orig_p = p;
27
718k
  uint64_t Value = 0;
28
718k
  unsigned Shift = 0;
29
791k
  do {
30
791k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
791k
    Shift += 7;
32
791k
  } while (*p++ >= 128);
33
718k
  if (n)
34
718k
    *n = (unsigned)(p - orig_p);
35
718k
  return Value;
36
718k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.14M
{
26
1.14M
  const uint8_t *orig_p = p;
27
1.14M
  uint64_t Value = 0;
28
1.14M
  unsigned Shift = 0;
29
1.17M
  do {
30
1.17M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.17M
    Shift += 7;
32
1.17M
  } while (*p++ >= 128);
33
1.14M
  if (n)
34
1.14M
    *n = (unsigned)(p - orig_p);
35
1.14M
  return Value;
36
1.14M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.72M
{
26
3.72M
  const uint8_t *orig_p = p;
27
3.72M
  uint64_t Value = 0;
28
3.72M
  unsigned Shift = 0;
29
3.82M
  do {
30
3.82M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.82M
    Shift += 7;
32
3.82M
  } while (*p++ >= 128);
33
3.72M
  if (n)
34
3.72M
    *n = (unsigned)(p - orig_p);
35
3.72M
  return Value;
36
3.72M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
29.9M
{
26
29.9M
  const uint8_t *orig_p = p;
27
29.9M
  uint64_t Value = 0;
28
29.9M
  unsigned Shift = 0;
29
32.9M
  do {
30
32.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
32.9M
    Shift += 7;
32
32.9M
  } while (*p++ >= 128);
33
29.9M
  if (n)
34
29.9M
    *n = (unsigned)(p - orig_p);
35
29.9M
  return Value;
36
29.9M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
9.75M
{
26
9.75M
  const uint8_t *orig_p = p;
27
9.75M
  uint64_t Value = 0;
28
9.75M
  unsigned Shift = 0;
29
10.7M
  do {
30
10.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.7M
    Shift += 7;
32
10.7M
  } while (*p++ >= 128);
33
9.75M
  if (n)
34
9.75M
    *n = (unsigned)(p - orig_p);
35
9.75M
  return Value;
36
9.75M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
6.68M
{
26
6.68M
  const uint8_t *orig_p = p;
27
6.68M
  uint64_t Value = 0;
28
6.68M
  unsigned Shift = 0;
29
6.97M
  do {
30
6.97M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.97M
    Shift += 7;
32
6.97M
  } while (*p++ >= 128);
33
6.68M
  if (n)
34
6.68M
    *n = (unsigned)(p - orig_p);
35
6.68M
  return Value;
36
6.68M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
6.02M
{
26
6.02M
  const uint8_t *orig_p = p;
27
6.02M
  uint64_t Value = 0;
28
6.02M
  unsigned Shift = 0;
29
6.25M
  do {
30
6.25M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.25M
    Shift += 7;
32
6.25M
  } while (*p++ >= 128);
33
6.02M
  if (n)
34
6.02M
    *n = (unsigned)(p - orig_p);
35
6.02M
  return Value;
36
6.02M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.25M
{
26
2.25M
  const uint8_t *orig_p = p;
27
2.25M
  uint64_t Value = 0;
28
2.25M
  unsigned Shift = 0;
29
2.32M
  do {
30
2.32M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.32M
    Shift += 7;
32
2.32M
  } while (*p++ >= 128);
33
2.25M
  if (n)
34
2.25M
    *n = (unsigned)(p - orig_p);
35
2.25M
  return Value;
36
2.25M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
12.2M
{
26
12.2M
  const uint8_t *orig_p = p;
27
12.2M
  uint64_t Value = 0;
28
12.2M
  unsigned Shift = 0;
29
17.2M
  do {
30
17.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
17.2M
    Shift += 7;
32
17.2M
  } while (*p++ >= 128);
33
12.2M
  if (n)
34
12.2M
    *n = (unsigned)(p - orig_p);
35
12.2M
  return Value;
36
12.2M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
1.05M
{
26
1.05M
  const uint8_t *orig_p = p;
27
1.05M
  uint64_t Value = 0;
28
1.05M
  unsigned Shift = 0;
29
1.13M
  do {
30
1.13M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.13M
    Shift += 7;
32
1.13M
  } while (*p++ >= 128);
33
1.05M
  if (n)
34
1.05M
    *n = (unsigned)(p - orig_p);
35
1.05M
  return Value;
36
1.05M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H