Coverage Report

Created: 2026-01-10 06:34

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
62.5M
{
26
62.5M
  const uint8_t *orig_p = p;
27
62.5M
  uint64_t Value = 0;
28
62.5M
  unsigned Shift = 0;
29
71.2M
  do {
30
71.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
71.2M
    Shift += 7;
32
71.2M
  } while (*p++ >= 128);
33
62.5M
  if (n)
34
62.5M
    *n = (unsigned)(p - orig_p);
35
62.5M
  return Value;
36
62.5M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
703k
{
26
703k
  const uint8_t *orig_p = p;
27
703k
  uint64_t Value = 0;
28
703k
  unsigned Shift = 0;
29
769k
  do {
30
769k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
769k
    Shift += 7;
32
769k
  } while (*p++ >= 128);
33
703k
  if (n)
34
703k
    *n = (unsigned)(p - orig_p);
35
703k
  return Value;
36
703k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
907k
{
26
907k
  const uint8_t *orig_p = p;
27
907k
  uint64_t Value = 0;
28
907k
  unsigned Shift = 0;
29
929k
  do {
30
929k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
929k
    Shift += 7;
32
929k
  } while (*p++ >= 128);
33
907k
  if (n)
34
907k
    *n = (unsigned)(p - orig_p);
35
907k
  return Value;
36
907k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.60M
{
26
2.60M
  const uint8_t *orig_p = p;
27
2.60M
  uint64_t Value = 0;
28
2.60M
  unsigned Shift = 0;
29
2.72M
  do {
30
2.72M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.72M
    Shift += 7;
32
2.72M
  } while (*p++ >= 128);
33
2.60M
  if (n)
34
2.60M
    *n = (unsigned)(p - orig_p);
35
2.60M
  return Value;
36
2.60M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
28.7M
{
26
28.7M
  const uint8_t *orig_p = p;
27
28.7M
  uint64_t Value = 0;
28
28.7M
  unsigned Shift = 0;
29
31.6M
  do {
30
31.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
31.6M
    Shift += 7;
32
31.6M
  } while (*p++ >= 128);
33
28.7M
  if (n)
34
28.7M
    *n = (unsigned)(p - orig_p);
35
28.7M
  return Value;
36
28.7M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
7.81M
{
26
7.81M
  const uint8_t *orig_p = p;
27
7.81M
  uint64_t Value = 0;
28
7.81M
  unsigned Shift = 0;
29
8.63M
  do {
30
8.63M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.63M
    Shift += 7;
32
8.63M
  } while (*p++ >= 128);
33
7.81M
  if (n)
34
7.81M
    *n = (unsigned)(p - orig_p);
35
7.81M
  return Value;
36
7.81M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
4.31M
{
26
4.31M
  const uint8_t *orig_p = p;
27
4.31M
  uint64_t Value = 0;
28
4.31M
  unsigned Shift = 0;
29
4.49M
  do {
30
4.49M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.49M
    Shift += 7;
32
4.49M
  } while (*p++ >= 128);
33
4.31M
  if (n)
34
4.31M
    *n = (unsigned)(p - orig_p);
35
4.31M
  return Value;
36
4.31M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
3.98M
{
26
3.98M
  const uint8_t *orig_p = p;
27
3.98M
  uint64_t Value = 0;
28
3.98M
  unsigned Shift = 0;
29
4.12M
  do {
30
4.12M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.12M
    Shift += 7;
32
4.12M
  } while (*p++ >= 128);
33
3.98M
  if (n)
34
3.98M
    *n = (unsigned)(p - orig_p);
35
3.98M
  return Value;
36
3.98M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.48M
{
26
1.48M
  const uint8_t *orig_p = p;
27
1.48M
  uint64_t Value = 0;
28
1.48M
  unsigned Shift = 0;
29
1.52M
  do {
30
1.52M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.52M
    Shift += 7;
32
1.52M
  } while (*p++ >= 128);
33
1.48M
  if (n)
34
1.48M
    *n = (unsigned)(p - orig_p);
35
1.48M
  return Value;
36
1.48M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
9.24M
{
26
9.24M
  const uint8_t *orig_p = p;
27
9.24M
  uint64_t Value = 0;
28
9.24M
  unsigned Shift = 0;
29
12.9M
  do {
30
12.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
12.9M
    Shift += 7;
32
12.9M
  } while (*p++ >= 128);
33
9.24M
  if (n)
34
9.24M
    *n = (unsigned)(p - orig_p);
35
9.24M
  return Value;
36
9.24M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
2.75M
{
26
2.75M
  const uint8_t *orig_p = p;
27
2.75M
  uint64_t Value = 0;
28
2.75M
  unsigned Shift = 0;
29
3.40M
  do {
30
3.40M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.40M
    Shift += 7;
32
3.40M
  } while (*p++ >= 128);
33
2.75M
  if (n)
34
2.75M
    *n = (unsigned)(p - orig_p);
35
2.75M
  return Value;
36
2.75M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H