Coverage Report

Created: 2026-11-12 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
128M
{
26
128M
  const uint8_t *orig_p = p;
27
128M
  uint64_t Value = 0;
28
128M
  unsigned Shift = 0;
29
145M
  do {
30
145M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
145M
    Shift += 7;
32
145M
  } while (*p++ >= 128);
33
128M
  if (n)
34
128M
    *n = (unsigned)(p - orig_p);
35
128M
  return Value;
36
128M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
47.5M
{
26
47.5M
  const uint8_t *orig_p = p;
27
47.5M
  uint64_t Value = 0;
28
47.5M
  unsigned Shift = 0;
29
52.2M
  do {
30
52.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
52.2M
    Shift += 7;
32
52.2M
  } while (*p++ >= 128);
33
47.5M
  if (n)
34
47.5M
    *n = (unsigned)(p - orig_p);
35
47.5M
  return Value;
36
47.5M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
19.5M
{
26
19.5M
  const uint8_t *orig_p = p;
27
19.5M
  uint64_t Value = 0;
28
19.5M
  unsigned Shift = 0;
29
21.4M
  do {
30
21.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
21.4M
    Shift += 7;
32
21.4M
  } while (*p++ >= 128);
33
19.5M
  if (n)
34
19.5M
    *n = (unsigned)(p - orig_p);
35
19.5M
  return Value;
36
19.5M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
10.9M
{
26
10.9M
  const uint8_t *orig_p = p;
27
10.9M
  uint64_t Value = 0;
28
10.9M
  unsigned Shift = 0;
29
11.3M
  do {
30
11.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
11.3M
    Shift += 7;
32
11.3M
  } while (*p++ >= 128);
33
10.9M
  if (n)
34
10.9M
    *n = (unsigned)(p - orig_p);
35
10.9M
  return Value;
36
10.9M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
13.0M
{
26
13.0M
  const uint8_t *orig_p = p;
27
13.0M
  uint64_t Value = 0;
28
13.0M
  unsigned Shift = 0;
29
13.5M
  do {
30
13.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
13.5M
    Shift += 7;
32
13.5M
  } while (*p++ >= 128);
33
13.0M
  if (n)
34
13.0M
    *n = (unsigned)(p - orig_p);
35
13.0M
  return Value;
36
13.0M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
4.77M
{
26
4.77M
  const uint8_t *orig_p = p;
27
4.77M
  uint64_t Value = 0;
28
4.77M
  unsigned Shift = 0;
29
4.90M
  do {
30
4.90M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.90M
    Shift += 7;
32
4.90M
  } while (*p++ >= 128);
33
4.77M
  if (n)
34
4.77M
    *n = (unsigned)(p - orig_p);
35
4.77M
  return Value;
36
4.77M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
21.3M
{
26
21.3M
  const uint8_t *orig_p = p;
27
21.3M
  uint64_t Value = 0;
28
21.3M
  unsigned Shift = 0;
29
29.9M
  do {
30
29.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
29.9M
    Shift += 7;
32
29.9M
  } while (*p++ >= 128);
33
21.3M
  if (n)
34
21.3M
    *n = (unsigned)(p - orig_p);
35
21.3M
  return Value;
36
21.3M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.45M
{
26
1.45M
  const uint8_t *orig_p = p;
27
1.45M
  uint64_t Value = 0;
28
1.45M
  unsigned Shift = 0;
29
1.58M
  do {
30
1.58M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.58M
    Shift += 7;
32
1.58M
  } while (*p++ >= 128);
33
1.45M
  if (n)
34
1.45M
    *n = (unsigned)(p - orig_p);
35
1.45M
  return Value;
36
1.45M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
2.09M
{
26
2.09M
  const uint8_t *orig_p = p;
27
2.09M
  uint64_t Value = 0;
28
2.09M
  unsigned Shift = 0;
29
2.13M
  do {
30
2.13M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.13M
    Shift += 7;
32
2.13M
  } while (*p++ >= 128);
33
2.09M
  if (n)
34
2.09M
    *n = (unsigned)(p - orig_p);
35
2.09M
  return Value;
36
2.09M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
7.63M
{
26
7.63M
  const uint8_t *orig_p = p;
27
7.63M
  uint64_t Value = 0;
28
7.63M
  unsigned Shift = 0;
29
7.89M
  do {
30
7.89M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.89M
    Shift += 7;
32
7.89M
  } while (*p++ >= 128);
33
7.63M
  if (n)
34
7.63M
    *n = (unsigned)(p - orig_p);
35
7.63M
  return Value;
36
7.63M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H