Coverage Report

Created: 2025-10-10 06:20

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
18.1M
{
26
18.1M
  const uint8_t *orig_p = p;
27
18.1M
  uint64_t Value = 0;
28
18.1M
  unsigned Shift = 0;
29
20.3M
  do {
30
20.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
20.3M
    Shift += 7;
32
20.3M
  } while (*p++ >= 128);
33
18.1M
  if (n)
34
18.1M
    *n = (unsigned)(p - orig_p);
35
18.1M
  return Value;
36
18.1M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
6.27M
{
26
6.27M
  const uint8_t *orig_p = p;
27
6.27M
  uint64_t Value = 0;
28
6.27M
  unsigned Shift = 0;
29
6.94M
  do {
30
6.94M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.94M
    Shift += 7;
32
6.94M
  } while (*p++ >= 128);
33
6.27M
  if (n)
34
6.27M
    *n = (unsigned)(p - orig_p);
35
6.27M
  return Value;
36
6.27M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
3.40M
{
26
3.40M
  const uint8_t *orig_p = p;
27
3.40M
  uint64_t Value = 0;
28
3.40M
  unsigned Shift = 0;
29
3.73M
  do {
30
3.73M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.73M
    Shift += 7;
32
3.73M
  } while (*p++ >= 128);
33
3.40M
  if (n)
34
3.40M
    *n = (unsigned)(p - orig_p);
35
3.40M
  return Value;
36
3.40M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
1.25M
{
26
1.25M
  const uint8_t *orig_p = p;
27
1.25M
  uint64_t Value = 0;
28
1.25M
  unsigned Shift = 0;
29
1.29M
  do {
30
1.29M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.29M
    Shift += 7;
32
1.29M
  } while (*p++ >= 128);
33
1.25M
  if (n)
34
1.25M
    *n = (unsigned)(p - orig_p);
35
1.25M
  return Value;
36
1.25M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
2.17M
{
26
2.17M
  const uint8_t *orig_p = p;
27
2.17M
  uint64_t Value = 0;
28
2.17M
  unsigned Shift = 0;
29
2.27M
  do {
30
2.27M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.27M
    Shift += 7;
32
2.27M
  } while (*p++ >= 128);
33
2.17M
  if (n)
34
2.17M
    *n = (unsigned)(p - orig_p);
35
2.17M
  return Value;
36
2.17M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
776k
{
26
776k
  const uint8_t *orig_p = p;
27
776k
  uint64_t Value = 0;
28
776k
  unsigned Shift = 0;
29
795k
  do {
30
795k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
795k
    Shift += 7;
32
795k
  } while (*p++ >= 128);
33
776k
  if (n)
34
776k
    *n = (unsigned)(p - orig_p);
35
776k
  return Value;
36
776k
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
2.43M
{
26
2.43M
  const uint8_t *orig_p = p;
27
2.43M
  uint64_t Value = 0;
28
2.43M
  unsigned Shift = 0;
29
3.38M
  do {
30
3.38M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.38M
    Shift += 7;
32
3.38M
  } while (*p++ >= 128);
33
2.43M
  if (n)
34
2.43M
    *n = (unsigned)(p - orig_p);
35
2.43M
  return Value;
36
2.43M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
188k
{
26
188k
  const uint8_t *orig_p = p;
27
188k
  uint64_t Value = 0;
28
188k
  unsigned Shift = 0;
29
209k
  do {
30
209k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
209k
    Shift += 7;
32
209k
  } while (*p++ >= 128);
33
188k
  if (n)
34
188k
    *n = (unsigned)(p - orig_p);
35
188k
  return Value;
36
188k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
378k
{
26
378k
  const uint8_t *orig_p = p;
27
378k
  uint64_t Value = 0;
28
378k
  unsigned Shift = 0;
29
386k
  do {
30
386k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
386k
    Shift += 7;
32
386k
  } while (*p++ >= 128);
33
378k
  if (n)
34
378k
    *n = (unsigned)(p - orig_p);
35
378k
  return Value;
36
378k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
1.27M
{
26
1.27M
  const uint8_t *orig_p = p;
27
1.27M
  uint64_t Value = 0;
28
1.27M
  unsigned Shift = 0;
29
1.33M
  do {
30
1.33M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.33M
    Shift += 7;
32
1.33M
  } while (*p++ >= 128);
33
1.27M
  if (n)
34
1.27M
    *n = (unsigned)(p - orig_p);
35
1.27M
  return Value;
36
1.27M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H