Coverage Report

Created: 2026-09-03 07:09

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
105M
{
26
105M
  const uint8_t *orig_p = p;
27
105M
  uint64_t Value = 0;
28
105M
  unsigned Shift = 0;
29
119M
  do {
30
119M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
119M
    Shift += 7;
32
119M
  } while (*p++ >= 128);
33
105M
  if (n)
34
105M
    *n = (unsigned)(p - orig_p);
35
105M
  return Value;
36
105M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
48.9M
{
26
48.9M
  const uint8_t *orig_p = p;
27
48.9M
  uint64_t Value = 0;
28
48.9M
  unsigned Shift = 0;
29
54.2M
  do {
30
54.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
54.2M
    Shift += 7;
32
54.2M
  } while (*p++ >= 128);
33
48.9M
  if (n)
34
48.9M
    *n = (unsigned)(p - orig_p);
35
48.9M
  return Value;
36
48.9M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
11.8M
{
26
11.8M
  const uint8_t *orig_p = p;
27
11.8M
  uint64_t Value = 0;
28
11.8M
  unsigned Shift = 0;
29
13.0M
  do {
30
13.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
13.0M
    Shift += 7;
32
13.0M
  } while (*p++ >= 128);
33
11.8M
  if (n)
34
11.8M
    *n = (unsigned)(p - orig_p);
35
11.8M
  return Value;
36
11.8M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
9.97M
{
26
9.97M
  const uint8_t *orig_p = p;
27
9.97M
  uint64_t Value = 0;
28
9.97M
  unsigned Shift = 0;
29
10.3M
  do {
30
10.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.3M
    Shift += 7;
32
10.3M
  } while (*p++ >= 128);
33
9.97M
  if (n)
34
9.97M
    *n = (unsigned)(p - orig_p);
35
9.97M
  return Value;
36
9.97M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
9.51M
{
26
9.51M
  const uint8_t *orig_p = p;
27
9.51M
  uint64_t Value = 0;
28
9.51M
  unsigned Shift = 0;
29
9.88M
  do {
30
9.88M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.88M
    Shift += 7;
32
9.88M
  } while (*p++ >= 128);
33
9.51M
  if (n)
34
9.51M
    *n = (unsigned)(p - orig_p);
35
9.51M
  return Value;
36
9.51M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.37M
{
26
3.37M
  const uint8_t *orig_p = p;
27
3.37M
  uint64_t Value = 0;
28
3.37M
  unsigned Shift = 0;
29
3.47M
  do {
30
3.47M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.47M
    Shift += 7;
32
3.47M
  } while (*p++ >= 128);
33
3.37M
  if (n)
34
3.37M
    *n = (unsigned)(p - orig_p);
35
3.37M
  return Value;
36
3.37M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
13.8M
{
26
13.8M
  const uint8_t *orig_p = p;
27
13.8M
  uint64_t Value = 0;
28
13.8M
  unsigned Shift = 0;
29
19.3M
  do {
30
19.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
19.3M
    Shift += 7;
32
19.3M
  } while (*p++ >= 128);
33
13.8M
  if (n)
34
13.8M
    *n = (unsigned)(p - orig_p);
35
13.8M
  return Value;
36
13.8M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.38M
{
26
1.38M
  const uint8_t *orig_p = p;
27
1.38M
  uint64_t Value = 0;
28
1.38M
  unsigned Shift = 0;
29
1.52M
  do {
30
1.52M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.52M
    Shift += 7;
32
1.52M
  } while (*p++ >= 128);
33
1.38M
  if (n)
34
1.38M
    *n = (unsigned)(p - orig_p);
35
1.38M
  return Value;
36
1.38M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.78M
{
26
1.78M
  const uint8_t *orig_p = p;
27
1.78M
  uint64_t Value = 0;
28
1.78M
  unsigned Shift = 0;
29
1.82M
  do {
30
1.82M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.82M
    Shift += 7;
32
1.82M
  } while (*p++ >= 128);
33
1.78M
  if (n)
34
1.78M
    *n = (unsigned)(p - orig_p);
35
1.78M
  return Value;
36
1.78M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
5.06M
{
26
5.06M
  const uint8_t *orig_p = p;
27
5.06M
  uint64_t Value = 0;
28
5.06M
  unsigned Shift = 0;
29
5.25M
  do {
30
5.25M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.25M
    Shift += 7;
32
5.25M
  } while (*p++ >= 128);
33
5.06M
  if (n)
34
5.06M
    *n = (unsigned)(p - orig_p);
35
5.06M
  return Value;
36
5.06M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H