Coverage Report

Created: 2026-05-30 06:22

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
95.4M
{
26
95.4M
  const uint8_t *orig_p = p;
27
95.4M
  uint64_t Value = 0;
28
95.4M
  unsigned Shift = 0;
29
107M
  do {
30
107M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
107M
    Shift += 7;
32
107M
  } while (*p++ >= 128);
33
95.4M
  if (n)
34
95.4M
    *n = (unsigned)(p - orig_p);
35
95.4M
  return Value;
36
95.4M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
44.5M
{
26
44.5M
  const uint8_t *orig_p = p;
27
44.5M
  uint64_t Value = 0;
28
44.5M
  unsigned Shift = 0;
29
49.4M
  do {
30
49.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
49.4M
    Shift += 7;
32
49.4M
  } while (*p++ >= 128);
33
44.5M
  if (n)
34
44.5M
    *n = (unsigned)(p - orig_p);
35
44.5M
  return Value;
36
44.5M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
12.0M
{
26
12.0M
  const uint8_t *orig_p = p;
27
12.0M
  uint64_t Value = 0;
28
12.0M
  unsigned Shift = 0;
29
13.2M
  do {
30
13.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
13.2M
    Shift += 7;
32
13.2M
  } while (*p++ >= 128);
33
12.0M
  if (n)
34
12.0M
    *n = (unsigned)(p - orig_p);
35
12.0M
  return Value;
36
12.0M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
7.96M
{
26
7.96M
  const uint8_t *orig_p = p;
27
7.96M
  uint64_t Value = 0;
28
7.96M
  unsigned Shift = 0;
29
8.28M
  do {
30
8.28M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.28M
    Shift += 7;
32
8.28M
  } while (*p++ >= 128);
33
7.96M
  if (n)
34
7.96M
    *n = (unsigned)(p - orig_p);
35
7.96M
  return Value;
36
7.96M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
7.89M
{
26
7.89M
  const uint8_t *orig_p = p;
27
7.89M
  uint64_t Value = 0;
28
7.89M
  unsigned Shift = 0;
29
8.22M
  do {
30
8.22M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.22M
    Shift += 7;
32
8.22M
  } while (*p++ >= 128);
33
7.89M
  if (n)
34
7.89M
    *n = (unsigned)(p - orig_p);
35
7.89M
  return Value;
36
7.89M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.20M
{
26
3.20M
  const uint8_t *orig_p = p;
27
3.20M
  uint64_t Value = 0;
28
3.20M
  unsigned Shift = 0;
29
3.28M
  do {
30
3.28M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.28M
    Shift += 7;
32
3.28M
  } while (*p++ >= 128);
33
3.20M
  if (n)
34
3.20M
    *n = (unsigned)(p - orig_p);
35
3.20M
  return Value;
36
3.20M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
12.4M
{
26
12.4M
  const uint8_t *orig_p = p;
27
12.4M
  uint64_t Value = 0;
28
12.4M
  unsigned Shift = 0;
29
17.3M
  do {
30
17.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
17.3M
    Shift += 7;
32
17.3M
  } while (*p++ >= 128);
33
12.4M
  if (n)
34
12.4M
    *n = (unsigned)(p - orig_p);
35
12.4M
  return Value;
36
12.4M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.50M
{
26
1.50M
  const uint8_t *orig_p = p;
27
1.50M
  uint64_t Value = 0;
28
1.50M
  unsigned Shift = 0;
29
1.69M
  do {
30
1.69M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.69M
    Shift += 7;
32
1.69M
  } while (*p++ >= 128);
33
1.50M
  if (n)
34
1.50M
    *n = (unsigned)(p - orig_p);
35
1.50M
  return Value;
36
1.50M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.65M
{
26
1.65M
  const uint8_t *orig_p = p;
27
1.65M
  uint64_t Value = 0;
28
1.65M
  unsigned Shift = 0;
29
1.69M
  do {
30
1.69M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.69M
    Shift += 7;
32
1.69M
  } while (*p++ >= 128);
33
1.65M
  if (n)
34
1.65M
    *n = (unsigned)(p - orig_p);
35
1.65M
  return Value;
36
1.65M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
4.10M
{
26
4.10M
  const uint8_t *orig_p = p;
27
4.10M
  uint64_t Value = 0;
28
4.10M
  unsigned Shift = 0;
29
4.28M
  do {
30
4.28M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.28M
    Shift += 7;
32
4.28M
  } while (*p++ >= 128);
33
4.10M
  if (n)
34
4.10M
    *n = (unsigned)(p - orig_p);
35
4.10M
  return Value;
36
4.10M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H