Coverage Report

Created: 2026-03-13 06:50

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
42.4M
{
26
42.4M
  const uint8_t *orig_p = p;
27
42.4M
  uint64_t Value = 0;
28
42.4M
  unsigned Shift = 0;
29
47.5M
  do {
30
47.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
47.5M
    Shift += 7;
32
47.5M
  } while (*p++ >= 128);
33
42.4M
  if (n)
34
42.4M
    *n = (unsigned)(p - orig_p);
35
42.4M
  return Value;
36
42.4M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
17.3M
{
26
17.3M
  const uint8_t *orig_p = p;
27
17.3M
  uint64_t Value = 0;
28
17.3M
  unsigned Shift = 0;
29
19.1M
  do {
30
19.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
19.1M
    Shift += 7;
32
19.1M
  } while (*p++ >= 128);
33
17.3M
  if (n)
34
17.3M
    *n = (unsigned)(p - orig_p);
35
17.3M
  return Value;
36
17.3M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
6.25M
{
26
6.25M
  const uint8_t *orig_p = p;
27
6.25M
  uint64_t Value = 0;
28
6.25M
  unsigned Shift = 0;
29
6.85M
  do {
30
6.85M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.85M
    Shift += 7;
32
6.85M
  } while (*p++ >= 128);
33
6.25M
  if (n)
34
6.25M
    *n = (unsigned)(p - orig_p);
35
6.25M
  return Value;
36
6.25M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.45M
{
26
3.45M
  const uint8_t *orig_p = p;
27
3.45M
  uint64_t Value = 0;
28
3.45M
  unsigned Shift = 0;
29
3.58M
  do {
30
3.58M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.58M
    Shift += 7;
32
3.58M
  } while (*p++ >= 128);
33
3.45M
  if (n)
34
3.45M
    *n = (unsigned)(p - orig_p);
35
3.45M
  return Value;
36
3.45M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
4.64M
{
26
4.64M
  const uint8_t *orig_p = p;
27
4.64M
  uint64_t Value = 0;
28
4.64M
  unsigned Shift = 0;
29
4.83M
  do {
30
4.83M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.83M
    Shift += 7;
32
4.83M
  } while (*p++ >= 128);
33
4.64M
  if (n)
34
4.64M
    *n = (unsigned)(p - orig_p);
35
4.64M
  return Value;
36
4.64M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.68M
{
26
1.68M
  const uint8_t *orig_p = p;
27
1.68M
  uint64_t Value = 0;
28
1.68M
  unsigned Shift = 0;
29
1.72M
  do {
30
1.72M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.72M
    Shift += 7;
32
1.72M
  } while (*p++ >= 128);
33
1.68M
  if (n)
34
1.68M
    *n = (unsigned)(p - orig_p);
35
1.68M
  return Value;
36
1.68M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
5.32M
{
26
5.32M
  const uint8_t *orig_p = p;
27
5.32M
  uint64_t Value = 0;
28
5.32M
  unsigned Shift = 0;
29
7.40M
  do {
30
7.40M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.40M
    Shift += 7;
32
7.40M
  } while (*p++ >= 128);
33
5.32M
  if (n)
34
5.32M
    *n = (unsigned)(p - orig_p);
35
5.32M
  return Value;
36
5.32M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
805k
{
26
805k
  const uint8_t *orig_p = p;
27
805k
  uint64_t Value = 0;
28
805k
  unsigned Shift = 0;
29
885k
  do {
30
885k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
885k
    Shift += 7;
32
885k
  } while (*p++ >= 128);
33
805k
  if (n)
34
805k
    *n = (unsigned)(p - orig_p);
35
805k
  return Value;
36
805k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
945k
{
26
945k
  const uint8_t *orig_p = p;
27
945k
  uint64_t Value = 0;
28
945k
  unsigned Shift = 0;
29
964k
  do {
30
964k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
964k
    Shift += 7;
32
964k
  } while (*p++ >= 128);
33
945k
  if (n)
34
945k
    *n = (unsigned)(p - orig_p);
35
945k
  return Value;
36
945k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.07M
{
26
2.07M
  const uint8_t *orig_p = p;
27
2.07M
  uint64_t Value = 0;
28
2.07M
  unsigned Shift = 0;
29
2.16M
  do {
30
2.16M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.16M
    Shift += 7;
32
2.16M
  } while (*p++ >= 128);
33
2.07M
  if (n)
34
2.07M
    *n = (unsigned)(p - orig_p);
35
2.07M
  return Value;
36
2.07M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H