Coverage Report

Created: 2026-01-10 06:34

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
39.1M
{
26
39.1M
  const uint8_t *orig_p = p;
27
39.1M
  uint64_t Value = 0;
28
39.1M
  unsigned Shift = 0;
29
43.8M
  do {
30
43.8M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
43.8M
    Shift += 7;
32
43.8M
  } while (*p++ >= 128);
33
39.1M
  if (n)
34
39.1M
    *n = (unsigned)(p - orig_p);
35
39.1M
  return Value;
36
39.1M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
15.1M
{
26
15.1M
  const uint8_t *orig_p = p;
27
15.1M
  uint64_t Value = 0;
28
15.1M
  unsigned Shift = 0;
29
16.7M
  do {
30
16.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
16.7M
    Shift += 7;
32
16.7M
  } while (*p++ >= 128);
33
15.1M
  if (n)
34
15.1M
    *n = (unsigned)(p - orig_p);
35
15.1M
  return Value;
36
15.1M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
6.17M
{
26
6.17M
  const uint8_t *orig_p = p;
27
6.17M
  uint64_t Value = 0;
28
6.17M
  unsigned Shift = 0;
29
6.75M
  do {
30
6.75M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.75M
    Shift += 7;
32
6.75M
  } while (*p++ >= 128);
33
6.17M
  if (n)
34
6.17M
    *n = (unsigned)(p - orig_p);
35
6.17M
  return Value;
36
6.17M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
2.91M
{
26
2.91M
  const uint8_t *orig_p = p;
27
2.91M
  uint64_t Value = 0;
28
2.91M
  unsigned Shift = 0;
29
3.02M
  do {
30
3.02M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.02M
    Shift += 7;
32
3.02M
  } while (*p++ >= 128);
33
2.91M
  if (n)
34
2.91M
    *n = (unsigned)(p - orig_p);
35
2.91M
  return Value;
36
2.91M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
4.51M
{
26
4.51M
  const uint8_t *orig_p = p;
27
4.51M
  uint64_t Value = 0;
28
4.51M
  unsigned Shift = 0;
29
4.69M
  do {
30
4.69M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.69M
    Shift += 7;
32
4.69M
  } while (*p++ >= 128);
33
4.51M
  if (n)
34
4.51M
    *n = (unsigned)(p - orig_p);
35
4.51M
  return Value;
36
4.51M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.39M
{
26
1.39M
  const uint8_t *orig_p = p;
27
1.39M
  uint64_t Value = 0;
28
1.39M
  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.39M
  if (n)
34
1.39M
    *n = (unsigned)(p - orig_p);
35
1.39M
  return Value;
36
1.39M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
5.37M
{
26
5.37M
  const uint8_t *orig_p = p;
27
5.37M
  uint64_t Value = 0;
28
5.37M
  unsigned Shift = 0;
29
7.42M
  do {
30
7.42M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.42M
    Shift += 7;
32
7.42M
  } while (*p++ >= 128);
33
5.37M
  if (n)
34
5.37M
    *n = (unsigned)(p - orig_p);
35
5.37M
  return Value;
36
5.37M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
828k
{
26
828k
  const uint8_t *orig_p = p;
27
828k
  uint64_t Value = 0;
28
828k
  unsigned Shift = 0;
29
911k
  do {
30
911k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
911k
    Shift += 7;
32
911k
  } while (*p++ >= 128);
33
828k
  if (n)
34
828k
    *n = (unsigned)(p - orig_p);
35
828k
  return Value;
36
828k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
776k
{
26
776k
  const uint8_t *orig_p = p;
27
776k
  uint64_t Value = 0;
28
776k
  unsigned Shift = 0;
29
793k
  do {
30
793k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
793k
    Shift += 7;
32
793k
  } while (*p++ >= 128);
33
776k
  if (n)
34
776k
    *n = (unsigned)(p - orig_p);
35
776k
  return Value;
36
776k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.04M
{
26
2.04M
  const uint8_t *orig_p = p;
27
2.04M
  uint64_t Value = 0;
28
2.04M
  unsigned Shift = 0;
29
2.13M
  do {
30
2.13M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.13M
    Shift += 7;
32
2.13M
  } while (*p++ >= 128);
33
2.04M
  if (n)
34
2.04M
    *n = (unsigned)(p - orig_p);
35
2.04M
  return Value;
36
2.04M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H