Coverage Report

Created: 2026-01-17 06:58

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
742k
{
26
742k
  const uint8_t *orig_p = p;
27
742k
  uint64_t Value = 0;
28
742k
  unsigned Shift = 0;
29
824k
  do {
30
824k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
824k
    Shift += 7;
32
824k
  } while (*p++ >= 128);
33
742k
  if (n)
34
742k
    *n = (unsigned)(p - orig_p);
35
742k
  return Value;
36
742k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.00M
{
26
1.00M
  const uint8_t *orig_p = p;
27
1.00M
  uint64_t Value = 0;
28
1.00M
  unsigned Shift = 0;
29
1.03M
  do {
30
1.03M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.03M
    Shift += 7;
32
1.03M
  } while (*p++ >= 128);
33
1.00M
  if (n)
34
1.00M
    *n = (unsigned)(p - orig_p);
35
1.00M
  return Value;
36
1.00M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.51M
{
26
2.51M
  const uint8_t *orig_p = p;
27
2.51M
  uint64_t Value = 0;
28
2.51M
  unsigned Shift = 0;
29
2.62M
  do {
30
2.62M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.62M
    Shift += 7;
32
2.62M
  } while (*p++ >= 128);
33
2.51M
  if (n)
34
2.51M
    *n = (unsigned)(p - orig_p);
35
2.51M
  return Value;
36
2.51M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
31.4M
{
26
31.4M
  const uint8_t *orig_p = p;
27
31.4M
  uint64_t Value = 0;
28
31.4M
  unsigned Shift = 0;
29
34.7M
  do {
30
34.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
34.7M
    Shift += 7;
32
34.7M
  } while (*p++ >= 128);
33
31.4M
  if (n)
34
31.4M
    *n = (unsigned)(p - orig_p);
35
31.4M
  return Value;
36
31.4M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
7.17M
{
26
7.17M
  const uint8_t *orig_p = p;
27
7.17M
  uint64_t Value = 0;
28
7.17M
  unsigned Shift = 0;
29
7.90M
  do {
30
7.90M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.90M
    Shift += 7;
32
7.90M
  } while (*p++ >= 128);
33
7.17M
  if (n)
34
7.17M
    *n = (unsigned)(p - orig_p);
35
7.17M
  return Value;
36
7.17M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
5.01M
{
26
5.01M
  const uint8_t *orig_p = p;
27
5.01M
  uint64_t Value = 0;
28
5.01M
  unsigned Shift = 0;
29
5.23M
  do {
30
5.23M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.23M
    Shift += 7;
32
5.23M
  } while (*p++ >= 128);
33
5.01M
  if (n)
34
5.01M
    *n = (unsigned)(p - orig_p);
35
5.01M
  return Value;
36
5.01M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
4.43M
{
26
4.43M
  const uint8_t *orig_p = p;
27
4.43M
  uint64_t Value = 0;
28
4.43M
  unsigned Shift = 0;
29
4.58M
  do {
30
4.58M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.58M
    Shift += 7;
32
4.58M
  } while (*p++ >= 128);
33
4.43M
  if (n)
34
4.43M
    *n = (unsigned)(p - orig_p);
35
4.43M
  return Value;
36
4.43M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.70M
{
26
1.70M
  const uint8_t *orig_p = p;
27
1.70M
  uint64_t Value = 0;
28
1.70M
  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.70M
  if (n)
34
1.70M
    *n = (unsigned)(p - orig_p);
35
1.70M
  return Value;
36
1.70M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
9.06M
{
26
9.06M
  const uint8_t *orig_p = p;
27
9.06M
  uint64_t Value = 0;
28
9.06M
  unsigned Shift = 0;
29
12.6M
  do {
30
12.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
12.6M
    Shift += 7;
32
12.6M
  } while (*p++ >= 128);
33
9.06M
  if (n)
34
9.06M
    *n = (unsigned)(p - orig_p);
35
9.06M
  return Value;
36
9.06M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
2.88M
{
26
2.88M
  const uint8_t *orig_p = p;
27
2.88M
  uint64_t Value = 0;
28
2.88M
  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
2.88M
  if (n)
34
2.88M
    *n = (unsigned)(p - orig_p);
35
2.88M
  return Value;
36
2.88M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H