Coverage Report

Created: 2026-01-12 07:13

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
63.9M
{
26
63.9M
  const uint8_t *orig_p = p;
27
63.9M
  uint64_t Value = 0;
28
63.9M
  unsigned Shift = 0;
29
72.9M
  do {
30
72.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
72.9M
    Shift += 7;
32
72.9M
  } while (*p++ >= 128);
33
63.9M
  if (n)
34
63.9M
    *n = (unsigned)(p - orig_p);
35
63.9M
  return Value;
36
63.9M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
738k
{
26
738k
  const uint8_t *orig_p = p;
27
738k
  uint64_t Value = 0;
28
738k
  unsigned Shift = 0;
29
809k
  do {
30
809k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
809k
    Shift += 7;
32
809k
  } while (*p++ >= 128);
33
738k
  if (n)
34
738k
    *n = (unsigned)(p - orig_p);
35
738k
  return Value;
36
738k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
960k
{
26
960k
  const uint8_t *orig_p = p;
27
960k
  uint64_t Value = 0;
28
960k
  unsigned Shift = 0;
29
985k
  do {
30
985k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
985k
    Shift += 7;
32
985k
  } while (*p++ >= 128);
33
960k
  if (n)
34
960k
    *n = (unsigned)(p - orig_p);
35
960k
  return Value;
36
960k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.76M
{
26
2.76M
  const uint8_t *orig_p = p;
27
2.76M
  uint64_t Value = 0;
28
2.76M
  unsigned Shift = 0;
29
2.88M
  do {
30
2.88M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.88M
    Shift += 7;
32
2.88M
  } while (*p++ >= 128);
33
2.76M
  if (n)
34
2.76M
    *n = (unsigned)(p - orig_p);
35
2.76M
  return Value;
36
2.76M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
29.5M
{
26
29.5M
  const uint8_t *orig_p = p;
27
29.5M
  uint64_t Value = 0;
28
29.5M
  unsigned Shift = 0;
29
32.5M
  do {
30
32.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
32.5M
    Shift += 7;
32
32.5M
  } while (*p++ >= 128);
33
29.5M
  if (n)
34
29.5M
    *n = (unsigned)(p - orig_p);
35
29.5M
  return Value;
36
29.5M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
8.04M
{
26
8.04M
  const uint8_t *orig_p = p;
27
8.04M
  uint64_t Value = 0;
28
8.04M
  unsigned Shift = 0;
29
8.89M
  do {
30
8.89M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.89M
    Shift += 7;
32
8.89M
  } while (*p++ >= 128);
33
8.04M
  if (n)
34
8.04M
    *n = (unsigned)(p - orig_p);
35
8.04M
  return Value;
36
8.04M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
4.34M
{
26
4.34M
  const uint8_t *orig_p = p;
27
4.34M
  uint64_t Value = 0;
28
4.34M
  unsigned Shift = 0;
29
4.52M
  do {
30
4.52M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.52M
    Shift += 7;
32
4.52M
  } while (*p++ >= 128);
33
4.34M
  if (n)
34
4.34M
    *n = (unsigned)(p - orig_p);
35
4.34M
  return Value;
36
4.34M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
3.94M
{
26
3.94M
  const uint8_t *orig_p = p;
27
3.94M
  uint64_t Value = 0;
28
3.94M
  unsigned Shift = 0;
29
4.07M
  do {
30
4.07M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.07M
    Shift += 7;
32
4.07M
  } while (*p++ >= 128);
33
3.94M
  if (n)
34
3.94M
    *n = (unsigned)(p - orig_p);
35
3.94M
  return Value;
36
3.94M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.56M
{
26
1.56M
  const uint8_t *orig_p = p;
27
1.56M
  uint64_t Value = 0;
28
1.56M
  unsigned Shift = 0;
29
1.61M
  do {
30
1.61M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.61M
    Shift += 7;
32
1.61M
  } while (*p++ >= 128);
33
1.56M
  if (n)
34
1.56M
    *n = (unsigned)(p - orig_p);
35
1.56M
  return Value;
36
1.56M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
9.39M
{
26
9.39M
  const uint8_t *orig_p = p;
27
9.39M
  uint64_t Value = 0;
28
9.39M
  unsigned Shift = 0;
29
13.2M
  do {
30
13.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
13.2M
    Shift += 7;
32
13.2M
  } while (*p++ >= 128);
33
9.39M
  if (n)
34
9.39M
    *n = (unsigned)(p - orig_p);
35
9.39M
  return Value;
36
9.39M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
2.70M
{
26
2.70M
  const uint8_t *orig_p = p;
27
2.70M
  uint64_t Value = 0;
28
2.70M
  unsigned Shift = 0;
29
3.33M
  do {
30
3.33M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.33M
    Shift += 7;
32
3.33M
  } while (*p++ >= 128);
33
2.70M
  if (n)
34
2.70M
    *n = (unsigned)(p - orig_p);
35
2.70M
  return Value;
36
2.70M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H