Coverage Report

Created: 2025-11-09 07:00

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
10.1M
{
26
10.1M
  const uint8_t *orig_p = p;
27
10.1M
  uint64_t Value = 0;
28
10.1M
  unsigned Shift = 0;
29
11.6M
  do {
30
11.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
11.6M
    Shift += 7;
32
11.6M
  } while (*p++ >= 128);
33
10.1M
  if (n)
34
10.1M
    *n = (unsigned)(p - orig_p);
35
10.1M
  return Value;
36
10.1M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
181k
{
26
181k
  const uint8_t *orig_p = p;
27
181k
  uint64_t Value = 0;
28
181k
  unsigned Shift = 0;
29
202k
  do {
30
202k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
202k
    Shift += 7;
32
202k
  } while (*p++ >= 128);
33
181k
  if (n)
34
181k
    *n = (unsigned)(p - orig_p);
35
181k
  return Value;
36
181k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
145k
{
26
145k
  const uint8_t *orig_p = p;
27
145k
  uint64_t Value = 0;
28
145k
  unsigned Shift = 0;
29
148k
  do {
30
148k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
148k
    Shift += 7;
32
148k
  } while (*p++ >= 128);
33
145k
  if (n)
34
145k
    *n = (unsigned)(p - orig_p);
35
145k
  return Value;
36
145k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
294k
{
26
294k
  const uint8_t *orig_p = p;
27
294k
  uint64_t Value = 0;
28
294k
  unsigned Shift = 0;
29
306k
  do {
30
306k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
306k
    Shift += 7;
32
306k
  } while (*p++ >= 128);
33
294k
  if (n)
34
294k
    *n = (unsigned)(p - orig_p);
35
294k
  return Value;
36
294k
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
4.51M
{
26
4.51M
  const uint8_t *orig_p = p;
27
4.51M
  uint64_t Value = 0;
28
4.51M
  unsigned Shift = 0;
29
4.98M
  do {
30
4.98M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.98M
    Shift += 7;
32
4.98M
  } while (*p++ >= 128);
33
4.51M
  if (n)
34
4.51M
    *n = (unsigned)(p - orig_p);
35
4.51M
  return Value;
36
4.51M
}
AArch64Disassembler.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.40M
  do {
30
1.40M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.40M
    Shift += 7;
32
1.40M
  } while (*p++ >= 128);
33
1.27M
  if (n)
34
1.27M
    *n = (unsigned)(p - orig_p);
35
1.27M
  return Value;
36
1.27M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
702k
{
26
702k
  const uint8_t *orig_p = p;
27
702k
  uint64_t Value = 0;
28
702k
  unsigned Shift = 0;
29
737k
  do {
30
737k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
737k
    Shift += 7;
32
737k
  } while (*p++ >= 128);
33
702k
  if (n)
34
702k
    *n = (unsigned)(p - orig_p);
35
702k
  return Value;
36
702k
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
603k
{
26
603k
  const uint8_t *orig_p = p;
27
603k
  uint64_t Value = 0;
28
603k
  unsigned Shift = 0;
29
625k
  do {
30
625k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
625k
    Shift += 7;
32
625k
  } while (*p++ >= 128);
33
603k
  if (n)
34
603k
    *n = (unsigned)(p - orig_p);
35
603k
  return Value;
36
603k
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
277k
{
26
277k
  const uint8_t *orig_p = p;
27
277k
  uint64_t Value = 0;
28
277k
  unsigned Shift = 0;
29
284k
  do {
30
284k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
284k
    Shift += 7;
32
284k
  } while (*p++ >= 128);
33
277k
  if (n)
34
277k
    *n = (unsigned)(p - orig_p);
35
277k
  return Value;
36
277k
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
1.73M
{
26
1.73M
  const uint8_t *orig_p = p;
27
1.73M
  uint64_t Value = 0;
28
1.73M
  unsigned Shift = 0;
29
2.47M
  do {
30
2.47M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.47M
    Shift += 7;
32
2.47M
  } while (*p++ >= 128);
33
1.73M
  if (n)
34
1.73M
    *n = (unsigned)(p - orig_p);
35
1.73M
  return Value;
36
1.73M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
366k
{
26
366k
  const uint8_t *orig_p = p;
27
366k
  uint64_t Value = 0;
28
366k
  unsigned Shift = 0;
29
473k
  do {
30
473k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
473k
    Shift += 7;
32
473k
  } while (*p++ >= 128);
33
366k
  if (n)
34
366k
    *n = (unsigned)(p - orig_p);
35
366k
  return Value;
36
366k
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H