Coverage Report

Created: 2025-12-05 06:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/capstonev5/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
53.1M
{
26
53.1M
  const uint8_t *orig_p = p;
27
53.1M
  uint64_t Value = 0;
28
53.1M
  unsigned Shift = 0;
29
59.4M
  do {
30
59.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
59.4M
    Shift += 7;
32
59.4M
  } while (*p++ >= 128);
33
53.1M
  if (n)
34
53.1M
    *n = (unsigned)(p - orig_p);
35
53.1M
  return Value;
36
53.1M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
18.3M
{
26
18.3M
  const uint8_t *orig_p = p;
27
18.3M
  uint64_t Value = 0;
28
18.3M
  unsigned Shift = 0;
29
20.2M
  do {
30
20.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
20.2M
    Shift += 7;
32
20.2M
  } while (*p++ >= 128);
33
18.3M
  if (n)
34
18.3M
    *n = (unsigned)(p - orig_p);
35
18.3M
  return Value;
36
18.3M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
10.1M
{
26
10.1M
  const uint8_t *orig_p = p;
27
10.1M
  uint64_t Value = 0;
28
10.1M
  unsigned Shift = 0;
29
11.1M
  do {
30
11.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
11.1M
    Shift += 7;
32
11.1M
  } while (*p++ >= 128);
33
10.1M
  if (n)
34
10.1M
    *n = (unsigned)(p - orig_p);
35
10.1M
  return Value;
36
10.1M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.40M
{
26
3.40M
  const uint8_t *orig_p = p;
27
3.40M
  uint64_t Value = 0;
28
3.40M
  unsigned Shift = 0;
29
3.52M
  do {
30
3.52M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.52M
    Shift += 7;
32
3.52M
  } while (*p++ >= 128);
33
3.40M
  if (n)
34
3.40M
    *n = (unsigned)(p - orig_p);
35
3.40M
  return Value;
36
3.40M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
6.15M
{
26
6.15M
  const uint8_t *orig_p = p;
27
6.15M
  uint64_t Value = 0;
28
6.15M
  unsigned Shift = 0;
29
6.41M
  do {
30
6.41M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.41M
    Shift += 7;
32
6.41M
  } while (*p++ >= 128);
33
6.15M
  if (n)
34
6.15M
    *n = (unsigned)(p - orig_p);
35
6.15M
  return Value;
36
6.15M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.18M
{
26
2.18M
  const uint8_t *orig_p = p;
27
2.18M
  uint64_t Value = 0;
28
2.18M
  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.18M
  if (n)
34
2.18M
    *n = (unsigned)(p - orig_p);
35
2.18M
  return Value;
36
2.18M
}
SystemZDisassembler.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
9.94M
  do {
30
9.94M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.94M
    Shift += 7;
32
9.94M
  } while (*p++ >= 128);
33
7.17M
  if (n)
34
7.17M
    *n = (unsigned)(p - orig_p);
35
7.17M
  return Value;
36
7.17M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
914k
{
26
914k
  const uint8_t *orig_p = p;
27
914k
  uint64_t Value = 0;
28
914k
  unsigned Shift = 0;
29
1.01M
  do {
30
1.01M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.01M
    Shift += 7;
32
1.01M
  } while (*p++ >= 128);
33
914k
  if (n)
34
914k
    *n = (unsigned)(p - orig_p);
35
914k
  return Value;
36
914k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
962k
{
26
962k
  const uint8_t *orig_p = p;
27
962k
  uint64_t Value = 0;
28
962k
  unsigned Shift = 0;
29
985k
  do {
30
985k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
985k
    Shift += 7;
32
985k
  } while (*p++ >= 128);
33
962k
  if (n)
34
962k
    *n = (unsigned)(p - orig_p);
35
962k
  return Value;
36
962k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.83M
{
26
3.83M
  const uint8_t *orig_p = p;
27
3.83M
  uint64_t Value = 0;
28
3.83M
  unsigned Shift = 0;
29
4.00M
  do {
30
4.00M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.00M
    Shift += 7;
32
4.00M
  } while (*p++ >= 128);
33
3.83M
  if (n)
34
3.83M
    *n = (unsigned)(p - orig_p);
35
3.83M
  return Value;
36
3.83M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H