Coverage Report

Created: 2026-09-01 07:20

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
93.7M
{
26
93.7M
  const uint8_t *orig_p = p;
27
93.7M
  uint64_t Value = 0;
28
93.7M
  unsigned Shift = 0;
29
105M
  do {
30
105M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
105M
    Shift += 7;
32
105M
  } while (*p++ >= 128);
33
93.7M
  if (n)
34
93.7M
    *n = (unsigned)(p - orig_p);
35
93.7M
  return Value;
36
93.7M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
42.6M
{
26
42.6M
  const uint8_t *orig_p = p;
27
42.6M
  uint64_t Value = 0;
28
42.6M
  unsigned Shift = 0;
29
47.2M
  do {
30
47.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
47.2M
    Shift += 7;
32
47.2M
  } while (*p++ >= 128);
33
42.6M
  if (n)
34
42.6M
    *n = (unsigned)(p - orig_p);
35
42.6M
  return Value;
36
42.6M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
10.7M
{
26
10.7M
  const uint8_t *orig_p = p;
27
10.7M
  uint64_t Value = 0;
28
10.7M
  unsigned Shift = 0;
29
11.8M
  do {
30
11.8M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
11.8M
    Shift += 7;
32
11.8M
  } while (*p++ >= 128);
33
10.7M
  if (n)
34
10.7M
    *n = (unsigned)(p - orig_p);
35
10.7M
  return Value;
36
10.7M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
8.89M
{
26
8.89M
  const uint8_t *orig_p = p;
27
8.89M
  uint64_t Value = 0;
28
8.89M
  unsigned Shift = 0;
29
9.26M
  do {
30
9.26M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.26M
    Shift += 7;
32
9.26M
  } while (*p++ >= 128);
33
8.89M
  if (n)
34
8.89M
    *n = (unsigned)(p - orig_p);
35
8.89M
  return Value;
36
8.89M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
8.97M
{
26
8.97M
  const uint8_t *orig_p = p;
27
8.97M
  uint64_t Value = 0;
28
8.97M
  unsigned Shift = 0;
29
9.32M
  do {
30
9.32M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.32M
    Shift += 7;
32
9.32M
  } while (*p++ >= 128);
33
8.97M
  if (n)
34
8.97M
    *n = (unsigned)(p - orig_p);
35
8.97M
  return Value;
36
8.97M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.05M
{
26
3.05M
  const uint8_t *orig_p = p;
27
3.05M
  uint64_t Value = 0;
28
3.05M
  unsigned Shift = 0;
29
3.14M
  do {
30
3.14M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.14M
    Shift += 7;
32
3.14M
  } while (*p++ >= 128);
33
3.05M
  if (n)
34
3.05M
    *n = (unsigned)(p - orig_p);
35
3.05M
  return Value;
36
3.05M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
12.1M
{
26
12.1M
  const uint8_t *orig_p = p;
27
12.1M
  uint64_t Value = 0;
28
12.1M
  unsigned Shift = 0;
29
16.9M
  do {
30
16.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
16.9M
    Shift += 7;
32
16.9M
  } while (*p++ >= 128);
33
12.1M
  if (n)
34
12.1M
    *n = (unsigned)(p - orig_p);
35
12.1M
  return Value;
36
12.1M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.42M
{
26
1.42M
  const uint8_t *orig_p = p;
27
1.42M
  uint64_t Value = 0;
28
1.42M
  unsigned Shift = 0;
29
1.57M
  do {
30
1.57M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.57M
    Shift += 7;
32
1.57M
  } while (*p++ >= 128);
33
1.42M
  if (n)
34
1.42M
    *n = (unsigned)(p - orig_p);
35
1.42M
  return Value;
36
1.42M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.51M
{
26
1.51M
  const uint8_t *orig_p = p;
27
1.51M
  uint64_t Value = 0;
28
1.51M
  unsigned Shift = 0;
29
1.54M
  do {
30
1.54M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.54M
    Shift += 7;
32
1.54M
  } while (*p++ >= 128);
33
1.51M
  if (n)
34
1.51M
    *n = (unsigned)(p - orig_p);
35
1.51M
  return Value;
36
1.51M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
4.25M
{
26
4.25M
  const uint8_t *orig_p = p;
27
4.25M
  uint64_t Value = 0;
28
4.25M
  unsigned Shift = 0;
29
4.41M
  do {
30
4.41M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.41M
    Shift += 7;
32
4.41M
  } while (*p++ >= 128);
33
4.25M
  if (n)
34
4.25M
    *n = (unsigned)(p - orig_p);
35
4.25M
  return Value;
36
4.25M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H