Coverage Report

Created: 2026-03-11 06:06

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
84.3M
{
26
84.3M
  const uint8_t *orig_p = p;
27
84.3M
  uint64_t Value = 0;
28
84.3M
  unsigned Shift = 0;
29
95.0M
  do {
30
95.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
95.0M
    Shift += 7;
32
95.0M
  } while (*p++ >= 128);
33
84.3M
  if (n)
34
84.3M
    *n = (unsigned)(p - orig_p);
35
84.3M
  return Value;
36
84.3M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.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.43M
  do {
30
1.43M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.43M
    Shift += 7;
32
1.43M
  } while (*p++ >= 128);
33
1.29M
  if (n)
34
1.29M
    *n = (unsigned)(p - orig_p);
35
1.29M
  return Value;
36
1.29M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.72M
{
26
1.72M
  const uint8_t *orig_p = p;
27
1.72M
  uint64_t Value = 0;
28
1.72M
  unsigned Shift = 0;
29
1.76M
  do {
30
1.76M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.76M
    Shift += 7;
32
1.76M
  } while (*p++ >= 128);
33
1.72M
  if (n)
34
1.72M
    *n = (unsigned)(p - orig_p);
35
1.72M
  return Value;
36
1.72M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.84M
{
26
3.84M
  const uint8_t *orig_p = p;
27
3.84M
  uint64_t Value = 0;
28
3.84M
  unsigned Shift = 0;
29
4.01M
  do {
30
4.01M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.01M
    Shift += 7;
32
4.01M
  } while (*p++ >= 128);
33
3.84M
  if (n)
34
3.84M
    *n = (unsigned)(p - orig_p);
35
3.84M
  return Value;
36
3.84M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
37.5M
{
26
37.5M
  const uint8_t *orig_p = p;
27
37.5M
  uint64_t Value = 0;
28
37.5M
  unsigned Shift = 0;
29
41.6M
  do {
30
41.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
41.6M
    Shift += 7;
32
41.6M
  } while (*p++ >= 128);
33
37.5M
  if (n)
34
37.5M
    *n = (unsigned)(p - orig_p);
35
37.5M
  return Value;
36
37.5M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
11.1M
{
26
11.1M
  const uint8_t *orig_p = p;
27
11.1M
  uint64_t Value = 0;
28
11.1M
  unsigned Shift = 0;
29
12.2M
  do {
30
12.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
12.2M
    Shift += 7;
32
12.2M
  } while (*p++ >= 128);
33
11.1M
  if (n)
34
11.1M
    *n = (unsigned)(p - orig_p);
35
11.1M
  return Value;
36
11.1M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
6.51M
{
26
6.51M
  const uint8_t *orig_p = p;
27
6.51M
  uint64_t Value = 0;
28
6.51M
  unsigned Shift = 0;
29
6.78M
  do {
30
6.78M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.78M
    Shift += 7;
32
6.78M
  } while (*p++ >= 128);
33
6.51M
  if (n)
34
6.51M
    *n = (unsigned)(p - orig_p);
35
6.51M
  return Value;
36
6.51M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
6.74M
{
26
6.74M
  const uint8_t *orig_p = p;
27
6.74M
  uint64_t Value = 0;
28
6.74M
  unsigned Shift = 0;
29
7.02M
  do {
30
7.02M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.02M
    Shift += 7;
32
7.02M
  } while (*p++ >= 128);
33
6.74M
  if (n)
34
6.74M
    *n = (unsigned)(p - orig_p);
35
6.74M
  return Value;
36
6.74M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.98M
{
26
2.98M
  const uint8_t *orig_p = p;
27
2.98M
  uint64_t Value = 0;
28
2.98M
  unsigned Shift = 0;
29
3.06M
  do {
30
3.06M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.06M
    Shift += 7;
32
3.06M
  } while (*p++ >= 128);
33
2.98M
  if (n)
34
2.98M
    *n = (unsigned)(p - orig_p);
35
2.98M
  return Value;
36
2.98M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
10.9M
{
26
10.9M
  const uint8_t *orig_p = p;
27
10.9M
  uint64_t Value = 0;
28
10.9M
  unsigned Shift = 0;
29
15.1M
  do {
30
15.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
15.1M
    Shift += 7;
32
15.1M
  } while (*p++ >= 128);
33
10.9M
  if (n)
34
10.9M
    *n = (unsigned)(p - orig_p);
35
10.9M
  return Value;
36
10.9M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
1.58M
{
26
1.58M
  const uint8_t *orig_p = p;
27
1.58M
  uint64_t Value = 0;
28
1.58M
  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.58M
  if (n)
34
1.58M
    *n = (unsigned)(p - orig_p);
35
1.58M
  return Value;
36
1.58M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H