Coverage Report

Created: 2026-09-28 06:34

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
39.9M
{
26
39.9M
  const uint8_t *orig_p = p;
27
39.9M
  uint64_t Value = 0;
28
39.9M
  unsigned Shift = 0;
29
45.0M
  do {
30
45.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
45.0M
    Shift += 7;
32
45.0M
  } while (*p++ >= 128);
33
39.9M
  if (n)
34
39.9M
    *n = (unsigned)(p - orig_p);
35
39.9M
  return Value;
36
39.9M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
615k
{
26
615k
  const uint8_t *orig_p = p;
27
615k
  uint64_t Value = 0;
28
615k
  unsigned Shift = 0;
29
688k
  do {
30
688k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
688k
    Shift += 7;
32
688k
  } while (*p++ >= 128);
33
615k
  if (n)
34
615k
    *n = (unsigned)(p - orig_p);
35
615k
  return Value;
36
615k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
643k
{
26
643k
  const uint8_t *orig_p = p;
27
643k
  uint64_t Value = 0;
28
643k
  unsigned Shift = 0;
29
657k
  do {
30
657k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
657k
    Shift += 7;
32
657k
  } while (*p++ >= 128);
33
643k
  if (n)
34
643k
    *n = (unsigned)(p - orig_p);
35
643k
  return Value;
36
643k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
1.69M
{
26
1.69M
  const uint8_t *orig_p = p;
27
1.69M
  uint64_t Value = 0;
28
1.69M
  unsigned Shift = 0;
29
1.75M
  do {
30
1.75M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.75M
    Shift += 7;
32
1.75M
  } while (*p++ >= 128);
33
1.69M
  if (n)
34
1.69M
    *n = (unsigned)(p - orig_p);
35
1.69M
  return Value;
36
1.69M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
19.3M
{
26
19.3M
  const uint8_t *orig_p = p;
27
19.3M
  uint64_t Value = 0;
28
19.3M
  unsigned Shift = 0;
29
21.4M
  do {
30
21.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
21.4M
    Shift += 7;
32
21.4M
  } while (*p++ >= 128);
33
19.3M
  if (n)
34
19.3M
    *n = (unsigned)(p - orig_p);
35
19.3M
  return Value;
36
19.3M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
4.04M
{
26
4.04M
  const uint8_t *orig_p = p;
27
4.04M
  uint64_t Value = 0;
28
4.04M
  unsigned Shift = 0;
29
4.46M
  do {
30
4.46M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.46M
    Shift += 7;
32
4.46M
  } while (*p++ >= 128);
33
4.04M
  if (n)
34
4.04M
    *n = (unsigned)(p - orig_p);
35
4.04M
  return Value;
36
4.04M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.79M
{
26
3.79M
  const uint8_t *orig_p = p;
27
3.79M
  uint64_t Value = 0;
28
3.79M
  unsigned Shift = 0;
29
3.97M
  do {
30
3.97M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.97M
    Shift += 7;
32
3.97M
  } while (*p++ >= 128);
33
3.79M
  if (n)
34
3.79M
    *n = (unsigned)(p - orig_p);
35
3.79M
  return Value;
36
3.79M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
2.98M
{
26
2.98M
  const uint8_t *orig_p = p;
27
2.98M
  uint64_t Value = 0;
28
2.98M
  unsigned Shift = 0;
29
3.09M
  do {
30
3.09M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.09M
    Shift += 7;
32
3.09M
  } while (*p++ >= 128);
33
2.98M
  if (n)
34
2.98M
    *n = (unsigned)(p - orig_p);
35
2.98M
  return Value;
36
2.98M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
959k
{
26
959k
  const uint8_t *orig_p = p;
27
959k
  uint64_t Value = 0;
28
959k
  unsigned Shift = 0;
29
995k
  do {
30
995k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
995k
    Shift += 7;
32
995k
  } while (*p++ >= 128);
33
959k
  if (n)
34
959k
    *n = (unsigned)(p - orig_p);
35
959k
  return Value;
36
959k
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
5.36M
{
26
5.36M
  const uint8_t *orig_p = p;
27
5.36M
  uint64_t Value = 0;
28
5.36M
  unsigned Shift = 0;
29
7.47M
  do {
30
7.47M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.47M
    Shift += 7;
32
7.47M
  } while (*p++ >= 128);
33
5.36M
  if (n)
34
5.36M
    *n = (unsigned)(p - orig_p);
35
5.36M
  return Value;
36
5.36M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
516k
{
26
516k
  const uint8_t *orig_p = p;
27
516k
  uint64_t Value = 0;
28
516k
  unsigned Shift = 0;
29
555k
  do {
30
555k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
555k
    Shift += 7;
32
555k
  } while (*p++ >= 128);
33
516k
  if (n)
34
516k
    *n = (unsigned)(p - orig_p);
35
516k
  return Value;
36
516k
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H