Coverage Report

Created: 2025-12-05 06:11

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
115M
{
26
115M
  const uint8_t *orig_p = p;
27
115M
  uint64_t Value = 0;
28
115M
  unsigned Shift = 0;
29
129M
  do {
30
129M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
129M
    Shift += 7;
32
129M
  } while (*p++ >= 128);
33
115M
  if (n)
34
115M
    *n = (unsigned)(p - orig_p);
35
115M
  return Value;
36
115M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
46.8M
{
26
46.8M
  const uint8_t *orig_p = p;
27
46.8M
  uint64_t Value = 0;
28
46.8M
  unsigned Shift = 0;
29
51.7M
  do {
30
51.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
51.7M
    Shift += 7;
32
51.7M
  } while (*p++ >= 128);
33
46.8M
  if (n)
34
46.8M
    *n = (unsigned)(p - orig_p);
35
46.8M
  return Value;
36
46.8M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
18.2M
{
26
18.2M
  const uint8_t *orig_p = p;
27
18.2M
  uint64_t Value = 0;
28
18.2M
  unsigned Shift = 0;
29
20.0M
  do {
30
20.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
20.0M
    Shift += 7;
32
20.0M
  } while (*p++ >= 128);
33
18.2M
  if (n)
34
18.2M
    *n = (unsigned)(p - orig_p);
35
18.2M
  return Value;
36
18.2M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
8.26M
{
26
8.26M
  const uint8_t *orig_p = p;
27
8.26M
  uint64_t Value = 0;
28
8.26M
  unsigned Shift = 0;
29
8.61M
  do {
30
8.61M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.61M
    Shift += 7;
32
8.61M
  } while (*p++ >= 128);
33
8.26M
  if (n)
34
8.26M
    *n = (unsigned)(p - orig_p);
35
8.26M
  return Value;
36
8.26M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
10.2M
{
26
10.2M
  const uint8_t *orig_p = p;
27
10.2M
  uint64_t Value = 0;
28
10.2M
  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
10.2M
  if (n)
34
10.2M
    *n = (unsigned)(p - orig_p);
35
10.2M
  return Value;
36
10.2M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.93M
{
26
3.93M
  const uint8_t *orig_p = p;
27
3.93M
  uint64_t Value = 0;
28
3.93M
  unsigned Shift = 0;
29
4.03M
  do {
30
4.03M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.03M
    Shift += 7;
32
4.03M
  } while (*p++ >= 128);
33
3.93M
  if (n)
34
3.93M
    *n = (unsigned)(p - orig_p);
35
3.93M
  return Value;
36
3.93M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
16.9M
{
26
16.9M
  const uint8_t *orig_p = p;
27
16.9M
  uint64_t Value = 0;
28
16.9M
  unsigned Shift = 0;
29
23.6M
  do {
30
23.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
23.6M
    Shift += 7;
32
23.6M
  } while (*p++ >= 128);
33
16.9M
  if (n)
34
16.9M
    *n = (unsigned)(p - orig_p);
35
16.9M
  return Value;
36
16.9M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.72M
{
26
1.72M
  const uint8_t *orig_p = p;
27
1.72M
  uint64_t Value = 0;
28
1.72M
  unsigned Shift = 0;
29
1.89M
  do {
30
1.89M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.89M
    Shift += 7;
32
1.89M
  } while (*p++ >= 128);
33
1.72M
  if (n)
34
1.72M
    *n = (unsigned)(p - orig_p);
35
1.72M
  return Value;
36
1.72M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.97M
{
26
1.97M
  const uint8_t *orig_p = p;
27
1.97M
  uint64_t Value = 0;
28
1.97M
  unsigned Shift = 0;
29
2.02M
  do {
30
2.02M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.02M
    Shift += 7;
32
2.02M
  } while (*p++ >= 128);
33
1.97M
  if (n)
34
1.97M
    *n = (unsigned)(p - orig_p);
35
1.97M
  return Value;
36
1.97M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
6.88M
{
26
6.88M
  const uint8_t *orig_p = p;
27
6.88M
  uint64_t Value = 0;
28
6.88M
  unsigned Shift = 0;
29
7.18M
  do {
30
7.18M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.18M
    Shift += 7;
32
7.18M
  } while (*p++ >= 128);
33
6.88M
  if (n)
34
6.88M
    *n = (unsigned)(p - orig_p);
35
6.88M
  return Value;
36
6.88M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H