Coverage Report

Created: 2026-07-16 06:55

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
35.9M
{
26
35.9M
  const uint8_t *orig_p = p;
27
35.9M
  uint64_t Value = 0;
28
35.9M
  unsigned Shift = 0;
29
40.2M
  do {
30
40.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
40.2M
    Shift += 7;
32
40.2M
  } while (*p++ >= 128);
33
35.9M
  if (n)
34
35.9M
    *n = (unsigned)(p - orig_p);
35
35.9M
  return Value;
36
35.9M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
14.3M
{
26
14.3M
  const uint8_t *orig_p = p;
27
14.3M
  uint64_t Value = 0;
28
14.3M
  unsigned Shift = 0;
29
15.9M
  do {
30
15.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
15.9M
    Shift += 7;
32
15.9M
  } while (*p++ >= 128);
33
14.3M
  if (n)
34
14.3M
    *n = (unsigned)(p - orig_p);
35
14.3M
  return Value;
36
14.3M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
5.15M
{
26
5.15M
  const uint8_t *orig_p = p;
27
5.15M
  uint64_t Value = 0;
28
5.15M
  unsigned Shift = 0;
29
5.64M
  do {
30
5.64M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.64M
    Shift += 7;
32
5.64M
  } while (*p++ >= 128);
33
5.15M
  if (n)
34
5.15M
    *n = (unsigned)(p - orig_p);
35
5.15M
  return Value;
36
5.15M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
2.81M
{
26
2.81M
  const uint8_t *orig_p = p;
27
2.81M
  uint64_t Value = 0;
28
2.81M
  unsigned Shift = 0;
29
2.91M
  do {
30
2.91M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.91M
    Shift += 7;
32
2.91M
  } while (*p++ >= 128);
33
2.81M
  if (n)
34
2.81M
    *n = (unsigned)(p - orig_p);
35
2.81M
  return Value;
36
2.81M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
3.91M
{
26
3.91M
  const uint8_t *orig_p = p;
27
3.91M
  uint64_t Value = 0;
28
3.91M
  unsigned Shift = 0;
29
4.07M
  do {
30
4.07M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.07M
    Shift += 7;
32
4.07M
  } while (*p++ >= 128);
33
3.91M
  if (n)
34
3.91M
    *n = (unsigned)(p - orig_p);
35
3.91M
  return Value;
36
3.91M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.71M
{
26
1.71M
  const uint8_t *orig_p = p;
27
1.71M
  uint64_t Value = 0;
28
1.71M
  unsigned Shift = 0;
29
1.76M
  do {
30
1.76M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.76M
    Shift += 7;
32
1.76M
  } while (*p++ >= 128);
33
1.71M
  if (n)
34
1.71M
    *n = (unsigned)(p - orig_p);
35
1.71M
  return Value;
36
1.71M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
4.70M
{
26
4.70M
  const uint8_t *orig_p = p;
27
4.70M
  uint64_t Value = 0;
28
4.70M
  unsigned Shift = 0;
29
6.52M
  do {
30
6.52M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.52M
    Shift += 7;
32
6.52M
  } while (*p++ >= 128);
33
4.70M
  if (n)
34
4.70M
    *n = (unsigned)(p - orig_p);
35
4.70M
  return Value;
36
4.70M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
532k
{
26
532k
  const uint8_t *orig_p = p;
27
532k
  uint64_t Value = 0;
28
532k
  unsigned Shift = 0;
29
578k
  do {
30
578k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
578k
    Shift += 7;
32
578k
  } while (*p++ >= 128);
33
532k
  if (n)
34
532k
    *n = (unsigned)(p - orig_p);
35
532k
  return Value;
36
532k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
725k
{
26
725k
  const uint8_t *orig_p = p;
27
725k
  uint64_t Value = 0;
28
725k
  unsigned Shift = 0;
29
741k
  do {
30
741k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
741k
    Shift += 7;
32
741k
  } while (*p++ >= 128);
33
725k
  if (n)
34
725k
    *n = (unsigned)(p - orig_p);
35
725k
  return Value;
36
725k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.00M
{
26
2.00M
  const uint8_t *orig_p = p;
27
2.00M
  uint64_t Value = 0;
28
2.00M
  unsigned Shift = 0;
29
2.09M
  do {
30
2.09M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.09M
    Shift += 7;
32
2.09M
  } while (*p++ >= 128);
33
2.00M
  if (n)
34
2.00M
    *n = (unsigned)(p - orig_p);
35
2.00M
  return Value;
36
2.00M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H