Coverage Report

Created: 2026-09-03 07:09

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.38M
{
26
1.38M
  const uint8_t *orig_p = p;
27
1.38M
  uint64_t Value = 0;
28
1.38M
  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.38M
  if (n)
34
1.38M
    *n = (unsigned)(p - orig_p);
35
1.38M
  return Value;
36
1.38M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.78M
{
26
1.78M
  const uint8_t *orig_p = p;
27
1.78M
  uint64_t Value = 0;
28
1.78M
  unsigned Shift = 0;
29
1.82M
  do {
30
1.82M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.82M
    Shift += 7;
32
1.82M
  } while (*p++ >= 128);
33
1.78M
  if (n)
34
1.78M
    *n = (unsigned)(p - orig_p);
35
1.78M
  return Value;
36
1.78M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
5.06M
{
26
5.06M
  const uint8_t *orig_p = p;
27
5.06M
  uint64_t Value = 0;
28
5.06M
  unsigned Shift = 0;
29
5.25M
  do {
30
5.25M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.25M
    Shift += 7;
32
5.25M
  } while (*p++ >= 128);
33
5.06M
  if (n)
34
5.06M
    *n = (unsigned)(p - orig_p);
35
5.06M
  return Value;
36
5.06M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
48.9M
{
26
48.9M
  const uint8_t *orig_p = p;
27
48.9M
  uint64_t Value = 0;
28
48.9M
  unsigned Shift = 0;
29
54.2M
  do {
30
54.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
54.2M
    Shift += 7;
32
54.2M
  } while (*p++ >= 128);
33
48.9M
  if (n)
34
48.9M
    *n = (unsigned)(p - orig_p);
35
48.9M
  return Value;
36
48.9M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
11.8M
{
26
11.8M
  const uint8_t *orig_p = p;
27
11.8M
  uint64_t Value = 0;
28
11.8M
  unsigned Shift = 0;
29
13.0M
  do {
30
13.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
13.0M
    Shift += 7;
32
13.0M
  } while (*p++ >= 128);
33
11.8M
  if (n)
34
11.8M
    *n = (unsigned)(p - orig_p);
35
11.8M
  return Value;
36
11.8M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
9.97M
{
26
9.97M
  const uint8_t *orig_p = p;
27
9.97M
  uint64_t Value = 0;
28
9.97M
  unsigned Shift = 0;
29
10.3M
  do {
30
10.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.3M
    Shift += 7;
32
10.3M
  } while (*p++ >= 128);
33
9.97M
  if (n)
34
9.97M
    *n = (unsigned)(p - orig_p);
35
9.97M
  return Value;
36
9.97M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
9.51M
{
26
9.51M
  const uint8_t *orig_p = p;
27
9.51M
  uint64_t Value = 0;
28
9.51M
  unsigned Shift = 0;
29
9.88M
  do {
30
9.88M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.88M
    Shift += 7;
32
9.88M
  } while (*p++ >= 128);
33
9.51M
  if (n)
34
9.51M
    *n = (unsigned)(p - orig_p);
35
9.51M
  return Value;
36
9.51M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.37M
{
26
3.37M
  const uint8_t *orig_p = p;
27
3.37M
  uint64_t Value = 0;
28
3.37M
  unsigned Shift = 0;
29
3.47M
  do {
30
3.47M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.47M
    Shift += 7;
32
3.47M
  } while (*p++ >= 128);
33
3.37M
  if (n)
34
3.37M
    *n = (unsigned)(p - orig_p);
35
3.37M
  return Value;
36
3.37M
}
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.3M
  do {
30
19.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
19.3M
    Shift += 7;
32
19.3M
  } 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
952k
{
26
952k
  const uint8_t *orig_p = p;
27
952k
  uint64_t Value = 0;
28
952k
  unsigned Shift = 0;
29
1.02M
  do {
30
1.02M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.02M
    Shift += 7;
32
1.02M
  } while (*p++ >= 128);
33
952k
  if (n)
34
952k
    *n = (unsigned)(p - orig_p);
35
952k
  return Value;
36
952k
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H