Coverage Report

Created: 2026-08-31 06:58

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
56.0M
{
26
56.0M
  const uint8_t *orig_p = p;
27
56.0M
  uint64_t Value = 0;
28
56.0M
  unsigned Shift = 0;
29
63.0M
  do {
30
63.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
63.0M
    Shift += 7;
32
63.0M
  } while (*p++ >= 128);
33
56.0M
  if (n)
34
56.0M
    *n = (unsigned)(p - orig_p);
35
56.0M
  return Value;
36
56.0M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
23.2M
{
26
23.2M
  const uint8_t *orig_p = p;
27
23.2M
  uint64_t Value = 0;
28
23.2M
  unsigned Shift = 0;
29
25.8M
  do {
30
25.8M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
25.8M
    Shift += 7;
32
25.8M
  } while (*p++ >= 128);
33
23.2M
  if (n)
34
23.2M
    *n = (unsigned)(p - orig_p);
35
23.2M
  return Value;
36
23.2M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
7.74M
{
26
7.74M
  const uint8_t *orig_p = p;
27
7.74M
  uint64_t Value = 0;
28
7.74M
  unsigned Shift = 0;
29
8.47M
  do {
30
8.47M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.47M
    Shift += 7;
32
8.47M
  } while (*p++ >= 128);
33
7.74M
  if (n)
34
7.74M
    *n = (unsigned)(p - orig_p);
35
7.74M
  return Value;
36
7.74M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
4.29M
{
26
4.29M
  const uint8_t *orig_p = p;
27
4.29M
  uint64_t Value = 0;
28
4.29M
  unsigned Shift = 0;
29
4.44M
  do {
30
4.44M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.44M
    Shift += 7;
32
4.44M
  } while (*p++ >= 128);
33
4.29M
  if (n)
34
4.29M
    *n = (unsigned)(p - orig_p);
35
4.29M
  return Value;
36
4.29M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
6.06M
{
26
6.06M
  const uint8_t *orig_p = p;
27
6.06M
  uint64_t Value = 0;
28
6.06M
  unsigned Shift = 0;
29
6.30M
  do {
30
6.30M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.30M
    Shift += 7;
32
6.30M
  } while (*p++ >= 128);
33
6.06M
  if (n)
34
6.06M
    *n = (unsigned)(p - orig_p);
35
6.06M
  return Value;
36
6.06M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.93M
{
26
1.93M
  const uint8_t *orig_p = p;
27
1.93M
  uint64_t Value = 0;
28
1.93M
  unsigned Shift = 0;
29
1.98M
  do {
30
1.98M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.98M
    Shift += 7;
32
1.98M
  } while (*p++ >= 128);
33
1.93M
  if (n)
34
1.93M
    *n = (unsigned)(p - orig_p);
35
1.93M
  return Value;
36
1.93M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
7.64M
{
26
7.64M
  const uint8_t *orig_p = p;
27
7.64M
  uint64_t Value = 0;
28
7.64M
  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.64M
  if (n)
34
7.64M
    *n = (unsigned)(p - orig_p);
35
7.64M
  return Value;
36
7.64M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
956k
{
26
956k
  const uint8_t *orig_p = p;
27
956k
  uint64_t Value = 0;
28
956k
  unsigned Shift = 0;
29
1.06M
  do {
30
1.06M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.06M
    Shift += 7;
32
1.06M
  } while (*p++ >= 128);
33
956k
  if (n)
34
956k
    *n = (unsigned)(p - orig_p);
35
956k
  return Value;
36
956k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.13M
{
26
1.13M
  const uint8_t *orig_p = p;
27
1.13M
  uint64_t Value = 0;
28
1.13M
  unsigned Shift = 0;
29
1.15M
  do {
30
1.15M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.15M
    Shift += 7;
32
1.15M
  } while (*p++ >= 128);
33
1.13M
  if (n)
34
1.13M
    *n = (unsigned)(p - orig_p);
35
1.13M
  return Value;
36
1.13M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.99M
{
26
2.99M
  const uint8_t *orig_p = p;
27
2.99M
  uint64_t Value = 0;
28
2.99M
  unsigned Shift = 0;
29
3.12M
  do {
30
3.12M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.12M
    Shift += 7;
32
3.12M
  } while (*p++ >= 128);
33
2.99M
  if (n)
34
2.99M
    *n = (unsigned)(p - orig_p);
35
2.99M
  return Value;
36
2.99M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H