Coverage Report

Created: 2026-04-12 06:30

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
36.2M
{
26
36.2M
  const uint8_t *orig_p = p;
27
36.2M
  uint64_t Value = 0;
28
36.2M
  unsigned Shift = 0;
29
41.1M
  do {
30
41.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
41.1M
    Shift += 7;
32
41.1M
  } while (*p++ >= 128);
33
36.2M
  if (n)
34
36.2M
    *n = (unsigned)(p - orig_p);
35
36.2M
  return Value;
36
36.2M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
479k
{
26
479k
  const uint8_t *orig_p = p;
27
479k
  uint64_t Value = 0;
28
479k
  unsigned Shift = 0;
29
523k
  do {
30
523k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
523k
    Shift += 7;
32
523k
  } while (*p++ >= 128);
33
479k
  if (n)
34
479k
    *n = (unsigned)(p - orig_p);
35
479k
  return Value;
36
479k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
604k
{
26
604k
  const uint8_t *orig_p = p;
27
604k
  uint64_t Value = 0;
28
604k
  unsigned Shift = 0;
29
617k
  do {
30
617k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
617k
    Shift += 7;
32
617k
  } while (*p++ >= 128);
33
604k
  if (n)
34
604k
    *n = (unsigned)(p - orig_p);
35
604k
  return Value;
36
604k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
1.34M
{
26
1.34M
  const uint8_t *orig_p = p;
27
1.34M
  uint64_t Value = 0;
28
1.34M
  unsigned Shift = 0;
29
1.40M
  do {
30
1.40M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.40M
    Shift += 7;
32
1.40M
  } while (*p++ >= 128);
33
1.34M
  if (n)
34
1.34M
    *n = (unsigned)(p - orig_p);
35
1.34M
  return Value;
36
1.34M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
17.3M
{
26
17.3M
  const uint8_t *orig_p = p;
27
17.3M
  uint64_t Value = 0;
28
17.3M
  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
17.3M
  if (n)
34
17.3M
    *n = (unsigned)(p - orig_p);
35
17.3M
  return Value;
36
17.3M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
3.87M
{
26
3.87M
  const uint8_t *orig_p = p;
27
3.87M
  uint64_t Value = 0;
28
3.87M
  unsigned Shift = 0;
29
4.27M
  do {
30
4.27M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.27M
    Shift += 7;
32
4.27M
  } while (*p++ >= 128);
33
3.87M
  if (n)
34
3.87M
    *n = (unsigned)(p - orig_p);
35
3.87M
  return Value;
36
3.87M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.04M
{
26
3.04M
  const uint8_t *orig_p = p;
27
3.04M
  uint64_t Value = 0;
28
3.04M
  unsigned Shift = 0;
29
3.17M
  do {
30
3.17M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.17M
    Shift += 7;
32
3.17M
  } while (*p++ >= 128);
33
3.04M
  if (n)
34
3.04M
    *n = (unsigned)(p - orig_p);
35
3.04M
  return Value;
36
3.04M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
2.14M
{
26
2.14M
  const uint8_t *orig_p = p;
27
2.14M
  uint64_t Value = 0;
28
2.14M
  unsigned Shift = 0;
29
2.22M
  do {
30
2.22M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.22M
    Shift += 7;
32
2.22M
  } while (*p++ >= 128);
33
2.14M
  if (n)
34
2.14M
    *n = (unsigned)(p - orig_p);
35
2.14M
  return Value;
36
2.14M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
876k
{
26
876k
  const uint8_t *orig_p = p;
27
876k
  uint64_t Value = 0;
28
876k
  unsigned Shift = 0;
29
904k
  do {
30
904k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
904k
    Shift += 7;
32
904k
  } while (*p++ >= 128);
33
876k
  if (n)
34
876k
    *n = (unsigned)(p - orig_p);
35
876k
  return Value;
36
876k
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
5.16M
{
26
5.16M
  const uint8_t *orig_p = p;
27
5.16M
  uint64_t Value = 0;
28
5.16M
  unsigned Shift = 0;
29
7.15M
  do {
30
7.15M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.15M
    Shift += 7;
32
7.15M
  } while (*p++ >= 128);
33
5.16M
  if (n)
34
5.16M
    *n = (unsigned)(p - orig_p);
35
5.16M
  return Value;
36
5.16M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.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.67M
  do {
30
1.67M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.67M
    Shift += 7;
32
1.67M
  } while (*p++ >= 128);
33
1.38M
  if (n)
34
1.38M
    *n = (unsigned)(p - orig_p);
35
1.38M
  return Value;
36
1.38M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H