Coverage Report

Created: 2025-11-16 06:38

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/capstonenext/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
119M
{
26
119M
  const uint8_t *orig_p = p;
27
119M
  uint64_t Value = 0;
28
119M
  unsigned Shift = 0;
29
135M
  do {
30
135M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
135M
    Shift += 7;
32
135M
  } while (*p++ >= 128);
33
119M
  if (n)
34
119M
    *n = (unsigned)(p - orig_p);
35
119M
  return Value;
36
119M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.63M
{
26
1.63M
  const uint8_t *orig_p = p;
27
1.63M
  uint64_t Value = 0;
28
1.63M
  unsigned Shift = 0;
29
1.79M
  do {
30
1.79M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.79M
    Shift += 7;
32
1.79M
  } while (*p++ >= 128);
33
1.63M
  if (n)
34
1.63M
    *n = (unsigned)(p - orig_p);
35
1.63M
  return Value;
36
1.63M
}
TMS320C64xDisassembler.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
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
6.95M
{
26
6.95M
  const uint8_t *orig_p = p;
27
6.95M
  uint64_t Value = 0;
28
6.95M
  unsigned Shift = 0;
29
7.26M
  do {
30
7.26M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.26M
    Shift += 7;
32
7.26M
  } while (*p++ >= 128);
33
6.95M
  if (n)
34
6.95M
    *n = (unsigned)(p - orig_p);
35
6.95M
  return Value;
36
6.95M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
49.0M
{
26
49.0M
  const uint8_t *orig_p = p;
27
49.0M
  uint64_t Value = 0;
28
49.0M
  unsigned Shift = 0;
29
54.1M
  do {
30
54.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
54.1M
    Shift += 7;
32
54.1M
  } while (*p++ >= 128);
33
49.0M
  if (n)
34
49.0M
    *n = (unsigned)(p - orig_p);
35
49.0M
  return Value;
36
49.0M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
18.0M
{
26
18.0M
  const uint8_t *orig_p = p;
27
18.0M
  uint64_t Value = 0;
28
18.0M
  unsigned Shift = 0;
29
19.8M
  do {
30
19.8M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
19.8M
    Shift += 7;
32
19.8M
  } while (*p++ >= 128);
33
18.0M
  if (n)
34
18.0M
    *n = (unsigned)(p - orig_p);
35
18.0M
  return Value;
36
18.0M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
8.37M
{
26
8.37M
  const uint8_t *orig_p = p;
27
8.37M
  uint64_t Value = 0;
28
8.37M
  unsigned Shift = 0;
29
8.72M
  do {
30
8.72M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.72M
    Shift += 7;
32
8.72M
  } while (*p++ >= 128);
33
8.37M
  if (n)
34
8.37M
    *n = (unsigned)(p - orig_p);
35
8.37M
  return Value;
36
8.37M
}
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
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.75M
{
26
3.75M
  const uint8_t *orig_p = p;
27
3.75M
  uint64_t Value = 0;
28
3.75M
  unsigned Shift = 0;
29
3.86M
  do {
30
3.86M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.86M
    Shift += 7;
32
3.86M
  } while (*p++ >= 128);
33
3.75M
  if (n)
34
3.75M
    *n = (unsigned)(p - orig_p);
35
3.75M
  return Value;
36
3.75M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
17.3M
{
26
17.3M
  const uint8_t *orig_p = p;
27
17.3M
  uint64_t Value = 0;
28
17.3M
  unsigned Shift = 0;
29
24.3M
  do {
30
24.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
24.3M
    Shift += 7;
32
24.3M
  } while (*p++ >= 128);
33
17.3M
  if (n)
34
17.3M
    *n = (unsigned)(p - orig_p);
35
17.3M
  return Value;
36
17.3M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
2.33M
{
26
2.33M
  const uint8_t *orig_p = p;
27
2.33M
  uint64_t Value = 0;
28
2.33M
  unsigned Shift = 0;
29
2.87M
  do {
30
2.87M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.87M
    Shift += 7;
32
2.87M
  } while (*p++ >= 128);
33
2.33M
  if (n)
34
2.33M
    *n = (unsigned)(p - orig_p);
35
2.33M
  return Value;
36
2.33M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H