Coverage Report

Created: 2026-01-09 06:55

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
54.7M
{
26
54.7M
  const uint8_t *orig_p = p;
27
54.7M
  uint64_t Value = 0;
28
54.7M
  unsigned Shift = 0;
29
61.3M
  do {
30
61.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
61.3M
    Shift += 7;
32
61.3M
  } while (*p++ >= 128);
33
54.7M
  if (n)
34
54.7M
    *n = (unsigned)(p - orig_p);
35
54.7M
  return Value;
36
54.7M
}
ARMDisassembler.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.6M
  do {
30
21.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
21.6M
    Shift += 7;
32
21.6M
  } while (*p++ >= 128);
33
19.5M
  if (n)
34
19.5M
    *n = (unsigned)(p - orig_p);
35
19.5M
  return Value;
36
19.5M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
9.85M
{
26
9.85M
  const uint8_t *orig_p = p;
27
9.85M
  uint64_t Value = 0;
28
9.85M
  unsigned Shift = 0;
29
10.7M
  do {
30
10.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.7M
    Shift += 7;
32
10.7M
  } while (*p++ >= 128);
33
9.85M
  if (n)
34
9.85M
    *n = (unsigned)(p - orig_p);
35
9.85M
  return Value;
36
9.85M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.50M
{
26
3.50M
  const uint8_t *orig_p = p;
27
3.50M
  uint64_t Value = 0;
28
3.50M
  unsigned Shift = 0;
29
3.63M
  do {
30
3.63M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.63M
    Shift += 7;
32
3.63M
  } while (*p++ >= 128);
33
3.50M
  if (n)
34
3.50M
    *n = (unsigned)(p - orig_p);
35
3.50M
  return Value;
36
3.50M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
6.62M
{
26
6.62M
  const uint8_t *orig_p = p;
27
6.62M
  uint64_t Value = 0;
28
6.62M
  unsigned Shift = 0;
29
6.88M
  do {
30
6.88M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.88M
    Shift += 7;
32
6.88M
  } while (*p++ >= 128);
33
6.62M
  if (n)
34
6.62M
    *n = (unsigned)(p - orig_p);
35
6.62M
  return Value;
36
6.62M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.27M
{
26
2.27M
  const uint8_t *orig_p = p;
27
2.27M
  uint64_t Value = 0;
28
2.27M
  unsigned Shift = 0;
29
2.33M
  do {
30
2.33M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.33M
    Shift += 7;
32
2.33M
  } while (*p++ >= 128);
33
2.27M
  if (n)
34
2.27M
    *n = (unsigned)(p - orig_p);
35
2.27M
  return Value;
36
2.27M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
7.44M
{
26
7.44M
  const uint8_t *orig_p = p;
27
7.44M
  uint64_t Value = 0;
28
7.44M
  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
7.44M
  if (n)
34
7.44M
    *n = (unsigned)(p - orig_p);
35
7.44M
  return Value;
36
7.44M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
925k
{
26
925k
  const uint8_t *orig_p = p;
27
925k
  uint64_t Value = 0;
28
925k
  unsigned Shift = 0;
29
1.01M
  do {
30
1.01M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.01M
    Shift += 7;
32
1.01M
  } while (*p++ >= 128);
33
925k
  if (n)
34
925k
    *n = (unsigned)(p - orig_p);
35
925k
  return Value;
36
925k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.06M
{
26
1.06M
  const uint8_t *orig_p = p;
27
1.06M
  uint64_t Value = 0;
28
1.06M
  unsigned Shift = 0;
29
1.08M
  do {
30
1.08M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.08M
    Shift += 7;
32
1.08M
  } while (*p++ >= 128);
33
1.06M
  if (n)
34
1.06M
    *n = (unsigned)(p - orig_p);
35
1.06M
  return Value;
36
1.06M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.50M
{
26
3.50M
  const uint8_t *orig_p = p;
27
3.50M
  uint64_t Value = 0;
28
3.50M
  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.50M
  if (n)
34
3.50M
    *n = (unsigned)(p - orig_p);
35
3.50M
  return Value;
36
3.50M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H