Coverage Report

Created: 2026-08-13 06:59

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
41.1M
{
26
41.1M
  const uint8_t *orig_p = p;
27
41.1M
  uint64_t Value = 0;
28
41.1M
  unsigned Shift = 0;
29
46.1M
  do {
30
46.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
46.1M
    Shift += 7;
32
46.1M
  } while (*p++ >= 128);
33
41.1M
  if (n)
34
41.1M
    *n = (unsigned)(p - orig_p);
35
41.1M
  return Value;
36
41.1M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
16.8M
{
26
16.8M
  const uint8_t *orig_p = p;
27
16.8M
  uint64_t Value = 0;
28
16.8M
  unsigned Shift = 0;
29
18.6M
  do {
30
18.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
18.6M
    Shift += 7;
32
18.6M
  } while (*p++ >= 128);
33
16.8M
  if (n)
34
16.8M
    *n = (unsigned)(p - orig_p);
35
16.8M
  return Value;
36
16.8M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
5.70M
{
26
5.70M
  const uint8_t *orig_p = p;
27
5.70M
  uint64_t Value = 0;
28
5.70M
  unsigned Shift = 0;
29
6.23M
  do {
30
6.23M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.23M
    Shift += 7;
32
6.23M
  } while (*p++ >= 128);
33
5.70M
  if (n)
34
5.70M
    *n = (unsigned)(p - orig_p);
35
5.70M
  return Value;
36
5.70M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.25M
{
26
3.25M
  const uint8_t *orig_p = p;
27
3.25M
  uint64_t Value = 0;
28
3.25M
  unsigned Shift = 0;
29
3.36M
  do {
30
3.36M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.36M
    Shift += 7;
32
3.36M
  } while (*p++ >= 128);
33
3.25M
  if (n)
34
3.25M
    *n = (unsigned)(p - orig_p);
35
3.25M
  return Value;
36
3.25M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
4.40M
{
26
4.40M
  const uint8_t *orig_p = p;
27
4.40M
  uint64_t Value = 0;
28
4.40M
  unsigned Shift = 0;
29
4.55M
  do {
30
4.55M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.55M
    Shift += 7;
32
4.55M
  } while (*p++ >= 128);
33
4.40M
  if (n)
34
4.40M
    *n = (unsigned)(p - orig_p);
35
4.40M
  return Value;
36
4.40M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.55M
{
26
1.55M
  const uint8_t *orig_p = p;
27
1.55M
  uint64_t Value = 0;
28
1.55M
  unsigned Shift = 0;
29
1.59M
  do {
30
1.59M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.59M
    Shift += 7;
32
1.59M
  } while (*p++ >= 128);
33
1.55M
  if (n)
34
1.55M
    *n = (unsigned)(p - orig_p);
35
1.55M
  return Value;
36
1.55M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
5.51M
{
26
5.51M
  const uint8_t *orig_p = p;
27
5.51M
  uint64_t Value = 0;
28
5.51M
  unsigned Shift = 0;
29
7.65M
  do {
30
7.65M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.65M
    Shift += 7;
32
7.65M
  } while (*p++ >= 128);
33
5.51M
  if (n)
34
5.51M
    *n = (unsigned)(p - orig_p);
35
5.51M
  return Value;
36
5.51M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
708k
{
26
708k
  const uint8_t *orig_p = p;
27
708k
  uint64_t Value = 0;
28
708k
  unsigned Shift = 0;
29
789k
  do {
30
789k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
789k
    Shift += 7;
32
789k
  } while (*p++ >= 128);
33
708k
  if (n)
34
708k
    *n = (unsigned)(p - orig_p);
35
708k
  return Value;
36
708k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
805k
{
26
805k
  const uint8_t *orig_p = p;
27
805k
  uint64_t Value = 0;
28
805k
  unsigned Shift = 0;
29
822k
  do {
30
822k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
822k
    Shift += 7;
32
822k
  } while (*p++ >= 128);
33
805k
  if (n)
34
805k
    *n = (unsigned)(p - orig_p);
35
805k
  return Value;
36
805k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.38M
{
26
2.38M
  const uint8_t *orig_p = p;
27
2.38M
  uint64_t Value = 0;
28
2.38M
  unsigned Shift = 0;
29
2.48M
  do {
30
2.48M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.48M
    Shift += 7;
32
2.48M
  } while (*p++ >= 128);
33
2.38M
  if (n)
34
2.38M
    *n = (unsigned)(p - orig_p);
35
2.38M
  return Value;
36
2.38M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H