Coverage Report

Created: 2026-02-26 07:11

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
62.1M
{
26
62.1M
  const uint8_t *orig_p = p;
27
62.1M
  uint64_t Value = 0;
28
62.1M
  unsigned Shift = 0;
29
70.3M
  do {
30
70.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
70.3M
    Shift += 7;
32
70.3M
  } while (*p++ >= 128);
33
62.1M
  if (n)
34
62.1M
    *n = (unsigned)(p - orig_p);
35
62.1M
  return Value;
36
62.1M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
881k
{
26
881k
  const uint8_t *orig_p = p;
27
881k
  uint64_t Value = 0;
28
881k
  unsigned Shift = 0;
29
964k
  do {
30
964k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
964k
    Shift += 7;
32
964k
  } while (*p++ >= 128);
33
881k
  if (n)
34
881k
    *n = (unsigned)(p - orig_p);
35
881k
  return Value;
36
881k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.07M
{
26
1.07M
  const uint8_t *orig_p = p;
27
1.07M
  uint64_t Value = 0;
28
1.07M
  unsigned Shift = 0;
29
1.09M
  do {
30
1.09M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.09M
    Shift += 7;
32
1.09M
  } while (*p++ >= 128);
33
1.07M
  if (n)
34
1.07M
    *n = (unsigned)(p - orig_p);
35
1.07M
  return Value;
36
1.07M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.34M
{
26
2.34M
  const uint8_t *orig_p = p;
27
2.34M
  uint64_t Value = 0;
28
2.34M
  unsigned Shift = 0;
29
2.44M
  do {
30
2.44M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.44M
    Shift += 7;
32
2.44M
  } while (*p++ >= 128);
33
2.34M
  if (n)
34
2.34M
    *n = (unsigned)(p - orig_p);
35
2.34M
  return Value;
36
2.34M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
28.6M
{
26
28.6M
  const uint8_t *orig_p = p;
27
28.6M
  uint64_t Value = 0;
28
28.6M
  unsigned Shift = 0;
29
31.6M
  do {
30
31.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
31.6M
    Shift += 7;
32
31.6M
  } while (*p++ >= 128);
33
28.6M
  if (n)
34
28.6M
    *n = (unsigned)(p - orig_p);
35
28.6M
  return Value;
36
28.6M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
6.87M
{
26
6.87M
  const uint8_t *orig_p = p;
27
6.87M
  uint64_t Value = 0;
28
6.87M
  unsigned Shift = 0;
29
7.59M
  do {
30
7.59M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.59M
    Shift += 7;
32
7.59M
  } while (*p++ >= 128);
33
6.87M
  if (n)
34
6.87M
    *n = (unsigned)(p - orig_p);
35
6.87M
  return Value;
36
6.87M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
5.37M
{
26
5.37M
  const uint8_t *orig_p = p;
27
5.37M
  uint64_t Value = 0;
28
5.37M
  unsigned Shift = 0;
29
5.60M
  do {
30
5.60M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.60M
    Shift += 7;
32
5.60M
  } while (*p++ >= 128);
33
5.37M
  if (n)
34
5.37M
    *n = (unsigned)(p - orig_p);
35
5.37M
  return Value;
36
5.37M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
4.34M
{
26
4.34M
  const uint8_t *orig_p = p;
27
4.34M
  uint64_t Value = 0;
28
4.34M
  unsigned Shift = 0;
29
4.50M
  do {
30
4.50M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.50M
    Shift += 7;
32
4.50M
  } while (*p++ >= 128);
33
4.34M
  if (n)
34
4.34M
    *n = (unsigned)(p - orig_p);
35
4.34M
  return Value;
36
4.34M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.67M
{
26
1.67M
  const uint8_t *orig_p = p;
27
1.67M
  uint64_t Value = 0;
28
1.67M
  unsigned Shift = 0;
29
1.72M
  do {
30
1.72M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.72M
    Shift += 7;
32
1.72M
  } while (*p++ >= 128);
33
1.67M
  if (n)
34
1.67M
    *n = (unsigned)(p - orig_p);
35
1.67M
  return Value;
36
1.67M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
8.43M
{
26
8.43M
  const uint8_t *orig_p = p;
27
8.43M
  uint64_t Value = 0;
28
8.43M
  unsigned Shift = 0;
29
11.5M
  do {
30
11.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
11.5M
    Shift += 7;
32
11.5M
  } while (*p++ >= 128);
33
8.43M
  if (n)
34
8.43M
    *n = (unsigned)(p - orig_p);
35
8.43M
  return Value;
36
8.43M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
2.54M
{
26
2.54M
  const uint8_t *orig_p = p;
27
2.54M
  uint64_t Value = 0;
28
2.54M
  unsigned Shift = 0;
29
3.11M
  do {
30
3.11M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.11M
    Shift += 7;
32
3.11M
  } while (*p++ >= 128);
33
2.54M
  if (n)
34
2.54M
    *n = (unsigned)(p - orig_p);
35
2.54M
  return Value;
36
2.54M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H