Coverage Report

Created: 2026-08-14 06:51

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.0M
{
26
41.0M
  const uint8_t *orig_p = p;
27
41.0M
  uint64_t Value = 0;
28
41.0M
  unsigned Shift = 0;
29
46.0M
  do {
30
46.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
46.0M
    Shift += 7;
32
46.0M
  } while (*p++ >= 128);
33
41.0M
  if (n)
34
41.0M
    *n = (unsigned)(p - orig_p);
35
41.0M
  return Value;
36
41.0M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
16.4M
{
26
16.4M
  const uint8_t *orig_p = p;
27
16.4M
  uint64_t Value = 0;
28
16.4M
  unsigned Shift = 0;
29
18.2M
  do {
30
18.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
18.2M
    Shift += 7;
32
18.2M
  } while (*p++ >= 128);
33
16.4M
  if (n)
34
16.4M
    *n = (unsigned)(p - orig_p);
35
16.4M
  return Value;
36
16.4M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
5.59M
{
26
5.59M
  const uint8_t *orig_p = p;
27
5.59M
  uint64_t Value = 0;
28
5.59M
  unsigned Shift = 0;
29
6.12M
  do {
30
6.12M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.12M
    Shift += 7;
32
6.12M
  } while (*p++ >= 128);
33
5.59M
  if (n)
34
5.59M
    *n = (unsigned)(p - orig_p);
35
5.59M
  return Value;
36
5.59M
}
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.51M
  do {
30
3.51M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.51M
    Shift += 7;
32
3.51M
  } 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
4.45M
{
26
4.45M
  const uint8_t *orig_p = p;
27
4.45M
  uint64_t Value = 0;
28
4.45M
  unsigned Shift = 0;
29
4.61M
  do {
30
4.61M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.61M
    Shift += 7;
32
4.61M
  } while (*p++ >= 128);
33
4.45M
  if (n)
34
4.45M
    *n = (unsigned)(p - orig_p);
35
4.45M
  return Value;
36
4.45M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.59M
{
26
1.59M
  const uint8_t *orig_p = p;
27
1.59M
  uint64_t Value = 0;
28
1.59M
  unsigned Shift = 0;
29
1.62M
  do {
30
1.62M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.62M
    Shift += 7;
32
1.62M
  } while (*p++ >= 128);
33
1.59M
  if (n)
34
1.59M
    *n = (unsigned)(p - orig_p);
35
1.59M
  return Value;
36
1.59M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
5.56M
{
26
5.56M
  const uint8_t *orig_p = p;
27
5.56M
  uint64_t Value = 0;
28
5.56M
  unsigned Shift = 0;
29
7.71M
  do {
30
7.71M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.71M
    Shift += 7;
32
7.71M
  } while (*p++ >= 128);
33
5.56M
  if (n)
34
5.56M
    *n = (unsigned)(p - orig_p);
35
5.56M
  return Value;
36
5.56M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
701k
{
26
701k
  const uint8_t *orig_p = p;
27
701k
  uint64_t Value = 0;
28
701k
  unsigned Shift = 0;
29
776k
  do {
30
776k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
776k
    Shift += 7;
32
776k
  } while (*p++ >= 128);
33
701k
  if (n)
34
701k
    *n = (unsigned)(p - orig_p);
35
701k
  return Value;
36
701k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
871k
{
26
871k
  const uint8_t *orig_p = p;
27
871k
  uint64_t Value = 0;
28
871k
  unsigned Shift = 0;
29
891k
  do {
30
891k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
891k
    Shift += 7;
32
891k
  } while (*p++ >= 128);
33
871k
  if (n)
34
871k
    *n = (unsigned)(p - orig_p);
35
871k
  return Value;
36
871k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.41M
{
26
2.41M
  const uint8_t *orig_p = p;
27
2.41M
  uint64_t Value = 0;
28
2.41M
  unsigned Shift = 0;
29
2.51M
  do {
30
2.51M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.51M
    Shift += 7;
32
2.51M
  } while (*p++ >= 128);
33
2.41M
  if (n)
34
2.41M
    *n = (unsigned)(p - orig_p);
35
2.41M
  return Value;
36
2.41M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H