Coverage Report

Created: 2026-12-01 07:03

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.4M
{
26
48.4M
  const uint8_t *orig_p = p;
27
48.4M
  uint64_t Value = 0;
28
48.4M
  unsigned Shift = 0;
29
54.3M
  do {
30
54.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
54.3M
    Shift += 7;
32
54.3M
  } while (*p++ >= 128);
33
48.4M
  if (n)
34
48.4M
    *n = (unsigned)(p - orig_p);
35
48.4M
  return Value;
36
48.4M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
15.8M
{
26
15.8M
  const uint8_t *orig_p = p;
27
15.8M
  uint64_t Value = 0;
28
15.8M
  unsigned Shift = 0;
29
17.4M
  do {
30
17.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
17.4M
    Shift += 7;
32
17.4M
  } while (*p++ >= 128);
33
15.8M
  if (n)
34
15.8M
    *n = (unsigned)(p - orig_p);
35
15.8M
  return Value;
36
15.8M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
8.81M
{
26
8.81M
  const uint8_t *orig_p = p;
27
8.81M
  uint64_t Value = 0;
28
8.81M
  unsigned Shift = 0;
29
9.65M
  do {
30
9.65M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.65M
    Shift += 7;
32
9.65M
  } while (*p++ >= 128);
33
8.81M
  if (n)
34
8.81M
    *n = (unsigned)(p - orig_p);
35
8.81M
  return Value;
36
8.81M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.66M
{
26
3.66M
  const uint8_t *orig_p = p;
27
3.66M
  uint64_t Value = 0;
28
3.66M
  unsigned Shift = 0;
29
3.78M
  do {
30
3.78M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.78M
    Shift += 7;
32
3.78M
  } while (*p++ >= 128);
33
3.66M
  if (n)
34
3.66M
    *n = (unsigned)(p - orig_p);
35
3.66M
  return Value;
36
3.66M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
5.76M
{
26
5.76M
  const uint8_t *orig_p = p;
27
5.76M
  uint64_t Value = 0;
28
5.76M
  unsigned Shift = 0;
29
5.98M
  do {
30
5.98M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.98M
    Shift += 7;
32
5.98M
  } while (*p++ >= 128);
33
5.76M
  if (n)
34
5.76M
    *n = (unsigned)(p - orig_p);
35
5.76M
  return Value;
36
5.76M
}
SparcDisassembler.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.13M
  do {
30
2.13M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.13M
    Shift += 7;
32
2.13M
  } while (*p++ >= 128);
33
2.08M
  if (n)
34
2.08M
    *n = (unsigned)(p - orig_p);
35
2.08M
  return Value;
36
2.08M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
7.53M
{
26
7.53M
  const uint8_t *orig_p = p;
27
7.53M
  uint64_t Value = 0;
28
7.53M
  unsigned Shift = 0;
29
10.4M
  do {
30
10.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.4M
    Shift += 7;
32
10.4M
  } while (*p++ >= 128);
33
7.53M
  if (n)
34
7.53M
    *n = (unsigned)(p - orig_p);
35
7.53M
  return Value;
36
7.53M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
722k
{
26
722k
  const uint8_t *orig_p = p;
27
722k
  uint64_t Value = 0;
28
722k
  unsigned Shift = 0;
29
785k
  do {
30
785k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
785k
    Shift += 7;
32
785k
  } while (*p++ >= 128);
33
722k
  if (n)
34
722k
    *n = (unsigned)(p - orig_p);
35
722k
  return Value;
36
722k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
895k
{
26
895k
  const uint8_t *orig_p = p;
27
895k
  uint64_t Value = 0;
28
895k
  unsigned Shift = 0;
29
915k
  do {
30
915k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
915k
    Shift += 7;
32
915k
  } while (*p++ >= 128);
33
895k
  if (n)
34
895k
    *n = (unsigned)(p - orig_p);
35
895k
  return Value;
36
895k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.10M
{
26
3.10M
  const uint8_t *orig_p = p;
27
3.10M
  uint64_t Value = 0;
28
3.10M
  unsigned Shift = 0;
29
3.23M
  do {
30
3.23M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.23M
    Shift += 7;
32
3.23M
  } while (*p++ >= 128);
33
3.10M
  if (n)
34
3.10M
    *n = (unsigned)(p - orig_p);
35
3.10M
  return Value;
36
3.10M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H