Coverage Report

Created: 2025-11-11 06:33

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
53.1M
{
26
53.1M
  const uint8_t *orig_p = p;
27
53.1M
  uint64_t Value = 0;
28
53.1M
  unsigned Shift = 0;
29
59.4M
  do {
30
59.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
59.4M
    Shift += 7;
32
59.4M
  } while (*p++ >= 128);
33
53.1M
  if (n)
34
53.1M
    *n = (unsigned)(p - orig_p);
35
53.1M
  return Value;
36
53.1M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
18.8M
{
26
18.8M
  const uint8_t *orig_p = p;
27
18.8M
  uint64_t Value = 0;
28
18.8M
  unsigned Shift = 0;
29
20.8M
  do {
30
20.8M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
20.8M
    Shift += 7;
32
20.8M
  } while (*p++ >= 128);
33
18.8M
  if (n)
34
18.8M
    *n = (unsigned)(p - orig_p);
35
18.8M
  return Value;
36
18.8M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
9.72M
{
26
9.72M
  const uint8_t *orig_p = p;
27
9.72M
  uint64_t Value = 0;
28
9.72M
  unsigned Shift = 0;
29
10.6M
  do {
30
10.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.6M
    Shift += 7;
32
10.6M
  } while (*p++ >= 128);
33
9.72M
  if (n)
34
9.72M
    *n = (unsigned)(p - orig_p);
35
9.72M
  return Value;
36
9.72M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.53M
{
26
3.53M
  const uint8_t *orig_p = p;
27
3.53M
  uint64_t Value = 0;
28
3.53M
  unsigned Shift = 0;
29
3.65M
  do {
30
3.65M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.65M
    Shift += 7;
32
3.65M
  } while (*p++ >= 128);
33
3.53M
  if (n)
34
3.53M
    *n = (unsigned)(p - orig_p);
35
3.53M
  return Value;
36
3.53M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
6.00M
{
26
6.00M
  const uint8_t *orig_p = p;
27
6.00M
  uint64_t Value = 0;
28
6.00M
  unsigned Shift = 0;
29
6.24M
  do {
30
6.24M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.24M
    Shift += 7;
32
6.24M
  } while (*p++ >= 128);
33
6.00M
  if (n)
34
6.00M
    *n = (unsigned)(p - orig_p);
35
6.00M
  return Value;
36
6.00M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.06M
{
26
2.06M
  const uint8_t *orig_p = p;
27
2.06M
  uint64_t Value = 0;
28
2.06M
  unsigned Shift = 0;
29
2.10M
  do {
30
2.10M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.10M
    Shift += 7;
32
2.10M
  } while (*p++ >= 128);
33
2.06M
  if (n)
34
2.06M
    *n = (unsigned)(p - orig_p);
35
2.06M
  return Value;
36
2.06M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
7.02M
{
26
7.02M
  const uint8_t *orig_p = p;
27
7.02M
  uint64_t Value = 0;
28
7.02M
  unsigned Shift = 0;
29
9.80M
  do {
30
9.80M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.80M
    Shift += 7;
32
9.80M
  } while (*p++ >= 128);
33
7.02M
  if (n)
34
7.02M
    *n = (unsigned)(p - orig_p);
35
7.02M
  return Value;
36
7.02M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
789k
{
26
789k
  const uint8_t *orig_p = p;
27
789k
  uint64_t Value = 0;
28
789k
  unsigned Shift = 0;
29
876k
  do {
30
876k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
876k
    Shift += 7;
32
876k
  } while (*p++ >= 128);
33
789k
  if (n)
34
789k
    *n = (unsigned)(p - orig_p);
35
789k
  return Value;
36
789k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.00M
{
26
1.00M
  const uint8_t *orig_p = p;
27
1.00M
  uint64_t Value = 0;
28
1.00M
  unsigned Shift = 0;
29
1.03M
  do {
30
1.03M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.03M
    Shift += 7;
32
1.03M
  } while (*p++ >= 128);
33
1.00M
  if (n)
34
1.00M
    *n = (unsigned)(p - orig_p);
35
1.00M
  return Value;
36
1.00M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
4.07M
{
26
4.07M
  const uint8_t *orig_p = p;
27
4.07M
  uint64_t Value = 0;
28
4.07M
  unsigned Shift = 0;
29
4.25M
  do {
30
4.25M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.25M
    Shift += 7;
32
4.25M
  } while (*p++ >= 128);
33
4.07M
  if (n)
34
4.07M
    *n = (unsigned)(p - orig_p);
35
4.07M
  return Value;
36
4.07M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H