Coverage Report

Created: 2025-11-11 06:33

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
56.5M
{
26
56.5M
  const uint8_t *orig_p = p;
27
56.5M
  uint64_t Value = 0;
28
56.5M
  unsigned Shift = 0;
29
64.1M
  do {
30
64.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
64.1M
    Shift += 7;
32
64.1M
  } while (*p++ >= 128);
33
56.5M
  if (n)
34
56.5M
    *n = (unsigned)(p - orig_p);
35
56.5M
  return Value;
36
56.5M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
861k
{
26
861k
  const uint8_t *orig_p = p;
27
861k
  uint64_t Value = 0;
28
861k
  unsigned Shift = 0;
29
951k
  do {
30
951k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
951k
    Shift += 7;
32
951k
  } while (*p++ >= 128);
33
861k
  if (n)
34
861k
    *n = (unsigned)(p - orig_p);
35
861k
  return Value;
36
861k
}
TMS320C64xDisassembler.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
980k
  do {
30
980k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
980k
    Shift += 7;
32
980k
  } while (*p++ >= 128);
33
959k
  if (n)
34
959k
    *n = (unsigned)(p - orig_p);
35
959k
  return Value;
36
959k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
1.90M
{
26
1.90M
  const uint8_t *orig_p = p;
27
1.90M
  uint64_t Value = 0;
28
1.90M
  unsigned Shift = 0;
29
1.99M
  do {
30
1.99M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.99M
    Shift += 7;
32
1.99M
  } while (*p++ >= 128);
33
1.90M
  if (n)
34
1.90M
    *n = (unsigned)(p - orig_p);
35
1.90M
  return Value;
36
1.90M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
27.6M
{
26
27.6M
  const uint8_t *orig_p = p;
27
27.6M
  uint64_t Value = 0;
28
27.6M
  unsigned Shift = 0;
29
30.6M
  do {
30
30.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
30.6M
    Shift += 7;
32
30.6M
  } while (*p++ >= 128);
33
27.6M
  if (n)
34
27.6M
    *n = (unsigned)(p - orig_p);
35
27.6M
  return Value;
36
27.6M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
6.16M
{
26
6.16M
  const uint8_t *orig_p = p;
27
6.16M
  uint64_t Value = 0;
28
6.16M
  unsigned Shift = 0;
29
6.84M
  do {
30
6.84M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.84M
    Shift += 7;
32
6.84M
  } while (*p++ >= 128);
33
6.16M
  if (n)
34
6.16M
    *n = (unsigned)(p - orig_p);
35
6.16M
  return Value;
36
6.16M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
4.07M
{
26
4.07M
  const uint8_t *orig_p = p;
27
4.07M
  uint64_t Value = 0;
28
4.07M
  unsigned Shift = 0;
29
4.26M
  do {
30
4.26M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.26M
    Shift += 7;
32
4.26M
  } while (*p++ >= 128);
33
4.07M
  if (n)
34
4.07M
    *n = (unsigned)(p - orig_p);
35
4.07M
  return Value;
36
4.07M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
3.80M
{
26
3.80M
  const uint8_t *orig_p = p;
27
3.80M
  uint64_t Value = 0;
28
3.80M
  unsigned Shift = 0;
29
3.94M
  do {
30
3.94M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.94M
    Shift += 7;
32
3.94M
  } while (*p++ >= 128);
33
3.80M
  if (n)
34
3.80M
    *n = (unsigned)(p - orig_p);
35
3.80M
  return Value;
36
3.80M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.37M
{
26
1.37M
  const uint8_t *orig_p = p;
27
1.37M
  uint64_t Value = 0;
28
1.37M
  unsigned Shift = 0;
29
1.42M
  do {
30
1.42M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.42M
    Shift += 7;
32
1.42M
  } while (*p++ >= 128);
33
1.37M
  if (n)
34
1.37M
    *n = (unsigned)(p - orig_p);
35
1.37M
  return Value;
36
1.37M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
7.63M
{
26
7.63M
  const uint8_t *orig_p = p;
27
7.63M
  uint64_t Value = 0;
28
7.63M
  unsigned Shift = 0;
29
10.6M
  do {
30
10.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.6M
    Shift += 7;
32
10.6M
  } while (*p++ >= 128);
33
7.63M
  if (n)
34
7.63M
    *n = (unsigned)(p - orig_p);
35
7.63M
  return Value;
36
7.63M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
2.11M
{
26
2.11M
  const uint8_t *orig_p = p;
27
2.11M
  uint64_t Value = 0;
28
2.11M
  unsigned Shift = 0;
29
2.57M
  do {
30
2.57M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.57M
    Shift += 7;
32
2.57M
  } while (*p++ >= 128);
33
2.11M
  if (n)
34
2.11M
    *n = (unsigned)(p - orig_p);
35
2.11M
  return Value;
36
2.11M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H