Coverage Report

Created: 2026-09-03 07:09

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.9M
{
26
39.9M
  const uint8_t *orig_p = p;
27
39.9M
  uint64_t Value = 0;
28
39.9M
  unsigned Shift = 0;
29
44.9M
  do {
30
44.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
44.9M
    Shift += 7;
32
44.9M
  } while (*p++ >= 128);
33
39.9M
  if (n)
34
39.9M
    *n = (unsigned)(p - orig_p);
35
39.9M
  return Value;
36
39.9M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
15.8M
{
26
15.8M
  const uint8_t *orig_p = p;
27
15.8M
  uint64_t Value = 0;
28
15.8M
  unsigned Shift = 0;
29
17.5M
  do {
30
17.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
17.5M
    Shift += 7;
32
17.5M
  } while (*p++ >= 128);
33
15.8M
  if (n)
34
15.8M
    *n = (unsigned)(p - orig_p);
35
15.8M
  return Value;
36
15.8M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
5.40M
{
26
5.40M
  const uint8_t *orig_p = p;
27
5.40M
  uint64_t Value = 0;
28
5.40M
  unsigned Shift = 0;
29
5.91M
  do {
30
5.91M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.91M
    Shift += 7;
32
5.91M
  } while (*p++ >= 128);
33
5.40M
  if (n)
34
5.40M
    *n = (unsigned)(p - orig_p);
35
5.40M
  return Value;
36
5.40M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.38M
{
26
3.38M
  const uint8_t *orig_p = p;
27
3.38M
  uint64_t Value = 0;
28
3.38M
  unsigned Shift = 0;
29
3.50M
  do {
30
3.50M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.50M
    Shift += 7;
32
3.50M
  } while (*p++ >= 128);
33
3.38M
  if (n)
34
3.38M
    *n = (unsigned)(p - orig_p);
35
3.38M
  return Value;
36
3.38M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
4.56M
{
26
4.56M
  const uint8_t *orig_p = p;
27
4.56M
  uint64_t Value = 0;
28
4.56M
  unsigned Shift = 0;
29
4.73M
  do {
30
4.73M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.73M
    Shift += 7;
32
4.73M
  } while (*p++ >= 128);
33
4.56M
  if (n)
34
4.56M
    *n = (unsigned)(p - orig_p);
35
4.56M
  return Value;
36
4.56M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.46M
{
26
1.46M
  const uint8_t *orig_p = p;
27
1.46M
  uint64_t Value = 0;
28
1.46M
  unsigned Shift = 0;
29
1.50M
  do {
30
1.50M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.50M
    Shift += 7;
32
1.50M
  } while (*p++ >= 128);
33
1.46M
  if (n)
34
1.46M
    *n = (unsigned)(p - orig_p);
35
1.46M
  return Value;
36
1.46M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
5.77M
{
26
5.77M
  const uint8_t *orig_p = p;
27
5.77M
  uint64_t Value = 0;
28
5.77M
  unsigned Shift = 0;
29
8.03M
  do {
30
8.03M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.03M
    Shift += 7;
32
8.03M
  } while (*p++ >= 128);
33
5.77M
  if (n)
34
5.77M
    *n = (unsigned)(p - orig_p);
35
5.77M
  return Value;
36
5.77M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
610k
{
26
610k
  const uint8_t *orig_p = p;
27
610k
  uint64_t Value = 0;
28
610k
  unsigned Shift = 0;
29
662k
  do {
30
662k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
662k
    Shift += 7;
32
662k
  } while (*p++ >= 128);
33
610k
  if (n)
34
610k
    *n = (unsigned)(p - orig_p);
35
610k
  return Value;
36
610k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
719k
{
26
719k
  const uint8_t *orig_p = p;
27
719k
  uint64_t Value = 0;
28
719k
  unsigned Shift = 0;
29
734k
  do {
30
734k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
734k
    Shift += 7;
32
734k
  } while (*p++ >= 128);
33
719k
  if (n)
34
719k
    *n = (unsigned)(p - orig_p);
35
719k
  return Value;
36
719k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.22M
{
26
2.22M
  const uint8_t *orig_p = p;
27
2.22M
  uint64_t Value = 0;
28
2.22M
  unsigned Shift = 0;
29
2.31M
  do {
30
2.31M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.31M
    Shift += 7;
32
2.31M
  } while (*p++ >= 128);
33
2.22M
  if (n)
34
2.22M
    *n = (unsigned)(p - orig_p);
35
2.22M
  return Value;
36
2.22M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H