Coverage Report

Created: 2026-12-01 07:03

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
65.9M
{
26
65.9M
  const uint8_t *orig_p = p;
27
65.9M
  uint64_t Value = 0;
28
65.9M
  unsigned Shift = 0;
29
74.8M
  do {
30
74.8M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
74.8M
    Shift += 7;
32
74.8M
  } while (*p++ >= 128);
33
65.9M
  if (n)
34
65.9M
    *n = (unsigned)(p - orig_p);
35
65.9M
  return Value;
36
65.9M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
689k
{
26
689k
  const uint8_t *orig_p = p;
27
689k
  uint64_t Value = 0;
28
689k
  unsigned Shift = 0;
29
752k
  do {
30
752k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
752k
    Shift += 7;
32
752k
  } while (*p++ >= 128);
33
689k
  if (n)
34
689k
    *n = (unsigned)(p - orig_p);
35
689k
  return Value;
36
689k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
606k
{
26
606k
  const uint8_t *orig_p = p;
27
606k
  uint64_t Value = 0;
28
606k
  unsigned Shift = 0;
29
621k
  do {
30
621k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
621k
    Shift += 7;
32
621k
  } while (*p++ >= 128);
33
606k
  if (n)
34
606k
    *n = (unsigned)(p - orig_p);
35
606k
  return Value;
36
606k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.43M
{
26
3.43M
  const uint8_t *orig_p = p;
27
3.43M
  uint64_t Value = 0;
28
3.43M
  unsigned Shift = 0;
29
3.53M
  do {
30
3.53M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.53M
    Shift += 7;
32
3.53M
  } while (*p++ >= 128);
33
3.43M
  if (n)
34
3.43M
    *n = (unsigned)(p - orig_p);
35
3.43M
  return Value;
36
3.43M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
27.8M
{
26
27.8M
  const uint8_t *orig_p = p;
27
27.8M
  uint64_t Value = 0;
28
27.8M
  unsigned Shift = 0;
29
30.5M
  do {
30
30.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
30.5M
    Shift += 7;
32
30.5M
  } while (*p++ >= 128);
33
27.8M
  if (n)
34
27.8M
    *n = (unsigned)(p - orig_p);
35
27.8M
  return Value;
36
27.8M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
9.04M
{
26
9.04M
  const uint8_t *orig_p = p;
27
9.04M
  uint64_t Value = 0;
28
9.04M
  unsigned Shift = 0;
29
9.95M
  do {
30
9.95M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.95M
    Shift += 7;
32
9.95M
  } while (*p++ >= 128);
33
9.04M
  if (n)
34
9.04M
    *n = (unsigned)(p - orig_p);
35
9.04M
  return Value;
36
9.04M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
5.82M
{
26
5.82M
  const uint8_t *orig_p = p;
27
5.82M
  uint64_t Value = 0;
28
5.82M
  unsigned Shift = 0;
29
6.10M
  do {
30
6.10M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.10M
    Shift += 7;
32
6.10M
  } while (*p++ >= 128);
33
5.82M
  if (n)
34
5.82M
    *n = (unsigned)(p - orig_p);
35
5.82M
  return Value;
36
5.82M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
4.82M
{
26
4.82M
  const uint8_t *orig_p = p;
27
4.82M
  uint64_t Value = 0;
28
4.82M
  unsigned Shift = 0;
29
4.99M
  do {
30
4.99M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.99M
    Shift += 7;
32
4.99M
  } while (*p++ >= 128);
33
4.82M
  if (n)
34
4.82M
    *n = (unsigned)(p - orig_p);
35
4.82M
  return Value;
36
4.82M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.85M
{
26
1.85M
  const uint8_t *orig_p = p;
27
1.85M
  uint64_t Value = 0;
28
1.85M
  unsigned Shift = 0;
29
1.90M
  do {
30
1.90M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.90M
    Shift += 7;
32
1.90M
  } while (*p++ >= 128);
33
1.85M
  if (n)
34
1.85M
    *n = (unsigned)(p - orig_p);
35
1.85M
  return Value;
36
1.85M
}
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.5M
  do {
30
15.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
15.5M
    Shift += 7;
32
15.5M
  } 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
879k
{
26
879k
  const uint8_t *orig_p = p;
27
879k
  uint64_t Value = 0;
28
879k
  unsigned Shift = 0;
29
934k
  do {
30
934k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
934k
    Shift += 7;
32
934k
  } while (*p++ >= 128);
33
879k
  if (n)
34
879k
    *n = (unsigned)(p - orig_p);
35
879k
  return Value;
36
879k
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H