Coverage Report

Created: 2026-03-03 06:15

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
60.2M
{
26
60.2M
  const uint8_t *orig_p = p;
27
60.2M
  uint64_t Value = 0;
28
60.2M
  unsigned Shift = 0;
29
67.3M
  do {
30
67.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
67.3M
    Shift += 7;
32
67.3M
  } while (*p++ >= 128);
33
60.2M
  if (n)
34
60.2M
    *n = (unsigned)(p - orig_p);
35
60.2M
  return Value;
36
60.2M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
24.0M
{
26
24.0M
  const uint8_t *orig_p = p;
27
24.0M
  uint64_t Value = 0;
28
24.0M
  unsigned Shift = 0;
29
26.5M
  do {
30
26.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
26.5M
    Shift += 7;
32
26.5M
  } while (*p++ >= 128);
33
24.0M
  if (n)
34
24.0M
    *n = (unsigned)(p - orig_p);
35
24.0M
  return Value;
36
24.0M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
9.58M
{
26
9.58M
  const uint8_t *orig_p = p;
27
9.58M
  uint64_t Value = 0;
28
9.58M
  unsigned Shift = 0;
29
10.4M
  do {
30
10.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.4M
    Shift += 7;
32
10.4M
  } while (*p++ >= 128);
33
9.58M
  if (n)
34
9.58M
    *n = (unsigned)(p - orig_p);
35
9.58M
  return Value;
36
9.58M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
4.89M
{
26
4.89M
  const uint8_t *orig_p = p;
27
4.89M
  uint64_t Value = 0;
28
4.89M
  unsigned Shift = 0;
29
5.06M
  do {
30
5.06M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.06M
    Shift += 7;
32
5.06M
  } while (*p++ >= 128);
33
4.89M
  if (n)
34
4.89M
    *n = (unsigned)(p - orig_p);
35
4.89M
  return Value;
36
4.89M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
6.39M
{
26
6.39M
  const uint8_t *orig_p = p;
27
6.39M
  uint64_t Value = 0;
28
6.39M
  unsigned Shift = 0;
29
6.65M
  do {
30
6.65M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.65M
    Shift += 7;
32
6.65M
  } while (*p++ >= 128);
33
6.39M
  if (n)
34
6.39M
    *n = (unsigned)(p - orig_p);
35
6.39M
  return Value;
36
6.39M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.27M
{
26
2.27M
  const uint8_t *orig_p = p;
27
2.27M
  uint64_t Value = 0;
28
2.27M
  unsigned Shift = 0;
29
2.32M
  do {
30
2.32M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.32M
    Shift += 7;
32
2.32M
  } while (*p++ >= 128);
33
2.27M
  if (n)
34
2.27M
    *n = (unsigned)(p - orig_p);
35
2.27M
  return Value;
36
2.27M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
7.69M
{
26
7.69M
  const uint8_t *orig_p = p;
27
7.69M
  uint64_t Value = 0;
28
7.69M
  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.69M
  if (n)
34
7.69M
    *n = (unsigned)(p - orig_p);
35
7.69M
  return Value;
36
7.69M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
898k
{
26
898k
  const uint8_t *orig_p = p;
27
898k
  uint64_t Value = 0;
28
898k
  unsigned Shift = 0;
29
995k
  do {
30
995k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
995k
    Shift += 7;
32
995k
  } while (*p++ >= 128);
33
898k
  if (n)
34
898k
    *n = (unsigned)(p - orig_p);
35
898k
  return Value;
36
898k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.20M
{
26
1.20M
  const uint8_t *orig_p = p;
27
1.20M
  uint64_t Value = 0;
28
1.20M
  unsigned Shift = 0;
29
1.23M
  do {
30
1.23M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.23M
    Shift += 7;
32
1.23M
  } while (*p++ >= 128);
33
1.20M
  if (n)
34
1.20M
    *n = (unsigned)(p - orig_p);
35
1.20M
  return Value;
36
1.20M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.23M
{
26
3.23M
  const uint8_t *orig_p = p;
27
3.23M
  uint64_t Value = 0;
28
3.23M
  unsigned Shift = 0;
29
3.37M
  do {
30
3.37M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.37M
    Shift += 7;
32
3.37M
  } while (*p++ >= 128);
33
3.23M
  if (n)
34
3.23M
    *n = (unsigned)(p - orig_p);
35
3.23M
  return Value;
36
3.23M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H