Coverage Report

Created: 2026-09-28 06:34

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
36.4M
{
26
36.4M
  const uint8_t *orig_p = p;
27
36.4M
  uint64_t Value = 0;
28
36.4M
  unsigned Shift = 0;
29
41.0M
  do {
30
41.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
41.0M
    Shift += 7;
32
41.0M
  } while (*p++ >= 128);
33
36.4M
  if (n)
34
36.4M
    *n = (unsigned)(p - orig_p);
35
36.4M
  return Value;
36
36.4M
}
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.8M
  do {
30
15.8M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
15.8M
    Shift += 7;
32
15.8M
  } 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.12M
{
26
5.12M
  const uint8_t *orig_p = p;
27
5.12M
  uint64_t Value = 0;
28
5.12M
  unsigned Shift = 0;
29
5.60M
  do {
30
5.60M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.60M
    Shift += 7;
32
5.60M
  } while (*p++ >= 128);
33
5.12M
  if (n)
34
5.12M
    *n = (unsigned)(p - orig_p);
35
5.12M
  return Value;
36
5.12M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
2.86M
{
26
2.86M
  const uint8_t *orig_p = p;
27
2.86M
  uint64_t Value = 0;
28
2.86M
  unsigned Shift = 0;
29
2.96M
  do {
30
2.96M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.96M
    Shift += 7;
32
2.96M
  } while (*p++ >= 128);
33
2.86M
  if (n)
34
2.86M
    *n = (unsigned)(p - orig_p);
35
2.86M
  return Value;
36
2.86M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
3.99M
{
26
3.99M
  const uint8_t *orig_p = p;
27
3.99M
  uint64_t Value = 0;
28
3.99M
  unsigned Shift = 0;
29
4.14M
  do {
30
4.14M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.14M
    Shift += 7;
32
4.14M
  } while (*p++ >= 128);
33
3.99M
  if (n)
34
3.99M
    *n = (unsigned)(p - orig_p);
35
3.99M
  return Value;
36
3.99M
}
SparcDisassembler.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.42M
  do {
30
1.42M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.42M
    Shift += 7;
32
1.42M
  } while (*p++ >= 128);
33
1.38M
  if (n)
34
1.38M
    *n = (unsigned)(p - orig_p);
35
1.38M
  return Value;
36
1.38M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
5.35M
{
26
5.35M
  const uint8_t *orig_p = p;
27
5.35M
  uint64_t Value = 0;
28
5.35M
  unsigned Shift = 0;
29
7.41M
  do {
30
7.41M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.41M
    Shift += 7;
32
7.41M
  } while (*p++ >= 128);
33
5.35M
  if (n)
34
5.35M
    *n = (unsigned)(p - orig_p);
35
5.35M
  return Value;
36
5.35M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
575k
{
26
575k
  const uint8_t *orig_p = p;
27
575k
  uint64_t Value = 0;
28
575k
  unsigned Shift = 0;
29
630k
  do {
30
630k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
630k
    Shift += 7;
32
630k
  } while (*p++ >= 128);
33
575k
  if (n)
34
575k
    *n = (unsigned)(p - orig_p);
35
575k
  return Value;
36
575k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
788k
{
26
788k
  const uint8_t *orig_p = p;
27
788k
  uint64_t Value = 0;
28
788k
  unsigned Shift = 0;
29
805k
  do {
30
805k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
805k
    Shift += 7;
32
805k
  } while (*p++ >= 128);
33
788k
  if (n)
34
788k
    *n = (unsigned)(p - orig_p);
35
788k
  return Value;
36
788k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.08M
{
26
2.08M
  const uint8_t *orig_p = p;
27
2.08M
  uint64_t Value = 0;
28
2.08M
  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.08M
  if (n)
34
2.08M
    *n = (unsigned)(p - orig_p);
35
2.08M
  return Value;
36
2.08M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H