Coverage Report

Created: 2026-07-16 06:55

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
70.9M
{
26
70.9M
  const uint8_t *orig_p = p;
27
70.9M
  uint64_t Value = 0;
28
70.9M
  unsigned Shift = 0;
29
80.3M
  do {
30
80.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
80.3M
    Shift += 7;
32
80.3M
  } while (*p++ >= 128);
33
70.9M
  if (n)
34
70.9M
    *n = (unsigned)(p - orig_p);
35
70.9M
  return Value;
36
70.9M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
884k
{
26
884k
  const uint8_t *orig_p = p;
27
884k
  uint64_t Value = 0;
28
884k
  unsigned Shift = 0;
29
980k
  do {
30
980k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
980k
    Shift += 7;
32
980k
  } while (*p++ >= 128);
33
884k
  if (n)
34
884k
    *n = (unsigned)(p - orig_p);
35
884k
  return Value;
36
884k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.07M
{
26
1.07M
  const uint8_t *orig_p = p;
27
1.07M
  uint64_t Value = 0;
28
1.07M
  unsigned Shift = 0;
29
1.09M
  do {
30
1.09M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.09M
    Shift += 7;
32
1.09M
  } while (*p++ >= 128);
33
1.07M
  if (n)
34
1.07M
    *n = (unsigned)(p - orig_p);
35
1.07M
  return Value;
36
1.07M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.18M
{
26
3.18M
  const uint8_t *orig_p = p;
27
3.18M
  uint64_t Value = 0;
28
3.18M
  unsigned Shift = 0;
29
3.31M
  do {
30
3.31M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.31M
    Shift += 7;
32
3.31M
  } while (*p++ >= 128);
33
3.18M
  if (n)
34
3.18M
    *n = (unsigned)(p - orig_p);
35
3.18M
  return Value;
36
3.18M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
33.4M
{
26
33.4M
  const uint8_t *orig_p = p;
27
33.4M
  uint64_t Value = 0;
28
33.4M
  unsigned Shift = 0;
29
37.0M
  do {
30
37.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
37.0M
    Shift += 7;
32
37.0M
  } while (*p++ >= 128);
33
33.4M
  if (n)
34
33.4M
    *n = (unsigned)(p - orig_p);
35
33.4M
  return Value;
36
33.4M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
7.02M
{
26
7.02M
  const uint8_t *orig_p = p;
27
7.02M
  uint64_t Value = 0;
28
7.02M
  unsigned Shift = 0;
29
7.75M
  do {
30
7.75M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.75M
    Shift += 7;
32
7.75M
  } while (*p++ >= 128);
33
7.02M
  if (n)
34
7.02M
    *n = (unsigned)(p - orig_p);
35
7.02M
  return Value;
36
7.02M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
6.19M
{
26
6.19M
  const uint8_t *orig_p = p;
27
6.19M
  uint64_t Value = 0;
28
6.19M
  unsigned Shift = 0;
29
6.50M
  do {
30
6.50M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.50M
    Shift += 7;
32
6.50M
  } while (*p++ >= 128);
33
6.19M
  if (n)
34
6.19M
    *n = (unsigned)(p - orig_p);
35
6.19M
  return Value;
36
6.19M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
4.96M
{
26
4.96M
  const uint8_t *orig_p = p;
27
4.96M
  uint64_t Value = 0;
28
4.96M
  unsigned Shift = 0;
29
5.18M
  do {
30
5.18M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.18M
    Shift += 7;
32
5.18M
  } while (*p++ >= 128);
33
4.96M
  if (n)
34
4.96M
    *n = (unsigned)(p - orig_p);
35
4.96M
  return Value;
36
4.96M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.87M
{
26
1.87M
  const uint8_t *orig_p = p;
27
1.87M
  uint64_t Value = 0;
28
1.87M
  unsigned Shift = 0;
29
1.94M
  do {
30
1.94M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.94M
    Shift += 7;
32
1.94M
  } while (*p++ >= 128);
33
1.87M
  if (n)
34
1.87M
    *n = (unsigned)(p - orig_p);
35
1.87M
  return Value;
36
1.87M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
9.15M
{
26
9.15M
  const uint8_t *orig_p = p;
27
9.15M
  uint64_t Value = 0;
28
9.15M
  unsigned Shift = 0;
29
12.6M
  do {
30
12.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
12.6M
    Shift += 7;
32
12.6M
  } while (*p++ >= 128);
33
9.15M
  if (n)
34
9.15M
    *n = (unsigned)(p - orig_p);
35
9.15M
  return Value;
36
9.15M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
3.09M
{
26
3.09M
  const uint8_t *orig_p = p;
27
3.09M
  uint64_t Value = 0;
28
3.09M
  unsigned Shift = 0;
29
3.75M
  do {
30
3.75M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.75M
    Shift += 7;
32
3.75M
  } while (*p++ >= 128);
33
3.09M
  if (n)
34
3.09M
    *n = (unsigned)(p - orig_p);
35
3.09M
  return Value;
36
3.09M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H