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
106M
{
26
106M
  const uint8_t *orig_p = p;
27
106M
  uint64_t Value = 0;
28
106M
  unsigned Shift = 0;
29
120M
  do {
30
120M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
120M
    Shift += 7;
32
120M
  } while (*p++ >= 128);
33
106M
  if (n)
34
106M
    *n = (unsigned)(p - orig_p);
35
106M
  return Value;
36
106M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.41M
{
26
1.41M
  const uint8_t *orig_p = p;
27
1.41M
  uint64_t Value = 0;
28
1.41M
  unsigned Shift = 0;
29
1.55M
  do {
30
1.55M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.55M
    Shift += 7;
32
1.55M
  } while (*p++ >= 128);
33
1.41M
  if (n)
34
1.41M
    *n = (unsigned)(p - orig_p);
35
1.41M
  return Value;
36
1.41M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.79M
{
26
1.79M
  const uint8_t *orig_p = p;
27
1.79M
  uint64_t Value = 0;
28
1.79M
  unsigned Shift = 0;
29
1.83M
  do {
30
1.83M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.83M
    Shift += 7;
32
1.83M
  } while (*p++ >= 128);
33
1.79M
  if (n)
34
1.79M
    *n = (unsigned)(p - orig_p);
35
1.79M
  return Value;
36
1.79M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
5.19M
{
26
5.19M
  const uint8_t *orig_p = p;
27
5.19M
  uint64_t Value = 0;
28
5.19M
  unsigned Shift = 0;
29
5.40M
  do {
30
5.40M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.40M
    Shift += 7;
32
5.40M
  } while (*p++ >= 128);
33
5.19M
  if (n)
34
5.19M
    *n = (unsigned)(p - orig_p);
35
5.19M
  return Value;
36
5.19M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
47.8M
{
26
47.8M
  const uint8_t *orig_p = p;
27
47.8M
  uint64_t Value = 0;
28
47.8M
  unsigned Shift = 0;
29
53.0M
  do {
30
53.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
53.0M
    Shift += 7;
32
53.0M
  } while (*p++ >= 128);
33
47.8M
  if (n)
34
47.8M
    *n = (unsigned)(p - orig_p);
35
47.8M
  return Value;
36
47.8M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
12.1M
{
26
12.1M
  const uint8_t *orig_p = p;
27
12.1M
  uint64_t Value = 0;
28
12.1M
  unsigned Shift = 0;
29
13.4M
  do {
30
13.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
13.4M
    Shift += 7;
32
13.4M
  } while (*p++ >= 128);
33
12.1M
  if (n)
34
12.1M
    *n = (unsigned)(p - orig_p);
35
12.1M
  return Value;
36
12.1M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
9.01M
{
26
9.01M
  const uint8_t *orig_p = p;
27
9.01M
  uint64_t Value = 0;
28
9.01M
  unsigned Shift = 0;
29
9.41M
  do {
30
9.41M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.41M
    Shift += 7;
32
9.41M
  } while (*p++ >= 128);
33
9.01M
  if (n)
34
9.01M
    *n = (unsigned)(p - orig_p);
35
9.01M
  return Value;
36
9.01M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
8.88M
{
26
8.88M
  const uint8_t *orig_p = p;
27
8.88M
  uint64_t Value = 0;
28
8.88M
  unsigned Shift = 0;
29
9.25M
  do {
30
9.25M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.25M
    Shift += 7;
32
9.25M
  } while (*p++ >= 128);
33
8.88M
  if (n)
34
8.88M
    *n = (unsigned)(p - orig_p);
35
8.88M
  return Value;
36
8.88M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.58M
{
26
3.58M
  const uint8_t *orig_p = p;
27
3.58M
  uint64_t Value = 0;
28
3.58M
  unsigned Shift = 0;
29
3.70M
  do {
30
3.70M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.70M
    Shift += 7;
32
3.70M
  } while (*p++ >= 128);
33
3.58M
  if (n)
34
3.58M
    *n = (unsigned)(p - orig_p);
35
3.58M
  return Value;
36
3.58M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
13.8M
{
26
13.8M
  const uint8_t *orig_p = p;
27
13.8M
  uint64_t Value = 0;
28
13.8M
  unsigned Shift = 0;
29
19.2M
  do {
30
19.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
19.2M
    Shift += 7;
32
19.2M
  } while (*p++ >= 128);
33
13.8M
  if (n)
34
13.8M
    *n = (unsigned)(p - orig_p);
35
13.8M
  return Value;
36
13.8M
}
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