Coverage Report

Created: 2026-04-12 06:30

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
48.7M
{
26
48.7M
  const uint8_t *orig_p = p;
27
48.7M
  uint64_t Value = 0;
28
48.7M
  unsigned Shift = 0;
29
54.8M
  do {
30
54.8M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
54.8M
    Shift += 7;
32
54.8M
  } while (*p++ >= 128);
33
48.7M
  if (n)
34
48.7M
    *n = (unsigned)(p - orig_p);
35
48.7M
  return Value;
36
48.7M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
19.7M
{
26
19.7M
  const uint8_t *orig_p = p;
27
19.7M
  uint64_t Value = 0;
28
19.7M
  unsigned Shift = 0;
29
21.7M
  do {
30
21.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
21.7M
    Shift += 7;
32
21.7M
  } while (*p++ >= 128);
33
19.7M
  if (n)
34
19.7M
    *n = (unsigned)(p - orig_p);
35
19.7M
  return Value;
36
19.7M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
7.26M
{
26
7.26M
  const uint8_t *orig_p = p;
27
7.26M
  uint64_t Value = 0;
28
7.26M
  unsigned Shift = 0;
29
7.96M
  do {
30
7.96M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.96M
    Shift += 7;
32
7.96M
  } while (*p++ >= 128);
33
7.26M
  if (n)
34
7.26M
    *n = (unsigned)(p - orig_p);
35
7.26M
  return Value;
36
7.26M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.54M
{
26
3.54M
  const uint8_t *orig_p = p;
27
3.54M
  uint64_t Value = 0;
28
3.54M
  unsigned Shift = 0;
29
3.66M
  do {
30
3.66M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.66M
    Shift += 7;
32
3.66M
  } while (*p++ >= 128);
33
3.54M
  if (n)
34
3.54M
    *n = (unsigned)(p - orig_p);
35
3.54M
  return Value;
36
3.54M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
5.23M
{
26
5.23M
  const uint8_t *orig_p = p;
27
5.23M
  uint64_t Value = 0;
28
5.23M
  unsigned Shift = 0;
29
5.45M
  do {
30
5.45M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.45M
    Shift += 7;
32
5.45M
  } while (*p++ >= 128);
33
5.23M
  if (n)
34
5.23M
    *n = (unsigned)(p - orig_p);
35
5.23M
  return Value;
36
5.23M
}
SparcDisassembler.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.14M
  do {
30
2.14M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.14M
    Shift += 7;
32
2.14M
  } while (*p++ >= 128);
33
2.09M
  if (n)
34
2.09M
    *n = (unsigned)(p - orig_p);
35
2.09M
  return Value;
36
2.09M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
6.72M
{
26
6.72M
  const uint8_t *orig_p = p;
27
6.72M
  uint64_t Value = 0;
28
6.72M
  unsigned Shift = 0;
29
9.43M
  do {
30
9.43M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.43M
    Shift += 7;
32
9.43M
  } while (*p++ >= 128);
33
6.72M
  if (n)
34
6.72M
    *n = (unsigned)(p - orig_p);
35
6.72M
  return Value;
36
6.72M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
830k
{
26
830k
  const uint8_t *orig_p = p;
27
830k
  uint64_t Value = 0;
28
830k
  unsigned Shift = 0;
29
918k
  do {
30
918k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
918k
    Shift += 7;
32
918k
  } while (*p++ >= 128);
33
830k
  if (n)
34
830k
    *n = (unsigned)(p - orig_p);
35
830k
  return Value;
36
830k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
812k
{
26
812k
  const uint8_t *orig_p = p;
27
812k
  uint64_t Value = 0;
28
812k
  unsigned Shift = 0;
29
829k
  do {
30
829k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
829k
    Shift += 7;
32
829k
  } while (*p++ >= 128);
33
812k
  if (n)
34
812k
    *n = (unsigned)(p - orig_p);
35
812k
  return Value;
36
812k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.53M
{
26
2.53M
  const uint8_t *orig_p = p;
27
2.53M
  uint64_t Value = 0;
28
2.53M
  unsigned Shift = 0;
29
2.64M
  do {
30
2.64M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.64M
    Shift += 7;
32
2.64M
  } while (*p++ >= 128);
33
2.53M
  if (n)
34
2.53M
    *n = (unsigned)(p - orig_p);
35
2.53M
  return Value;
36
2.53M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H