Coverage Report

Created: 2026-03-03 06:14

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
26.6M
{
26
26.6M
  const uint8_t *orig_p = p;
27
26.6M
  uint64_t Value = 0;
28
26.6M
  unsigned Shift = 0;
29
30.3M
  do {
30
30.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
30.3M
    Shift += 7;
32
30.3M
  } while (*p++ >= 128);
33
26.6M
  if (n)
34
26.6M
    *n = (unsigned)(p - orig_p);
35
26.6M
  return Value;
36
26.6M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
431k
{
26
431k
  const uint8_t *orig_p = p;
27
431k
  uint64_t Value = 0;
28
431k
  unsigned Shift = 0;
29
483k
  do {
30
483k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
483k
    Shift += 7;
32
483k
  } while (*p++ >= 128);
33
431k
  if (n)
34
431k
    *n = (unsigned)(p - orig_p);
35
431k
  return Value;
36
431k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
284k
{
26
284k
  const uint8_t *orig_p = p;
27
284k
  uint64_t Value = 0;
28
284k
  unsigned Shift = 0;
29
292k
  do {
30
292k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
292k
    Shift += 7;
32
292k
  } while (*p++ >= 128);
33
284k
  if (n)
34
284k
    *n = (unsigned)(p - orig_p);
35
284k
  return Value;
36
284k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
465k
{
26
465k
  const uint8_t *orig_p = p;
27
465k
  uint64_t Value = 0;
28
465k
  unsigned Shift = 0;
29
486k
  do {
30
486k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
486k
    Shift += 7;
32
486k
  } while (*p++ >= 128);
33
465k
  if (n)
34
465k
    *n = (unsigned)(p - orig_p);
35
465k
  return Value;
36
465k
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
13.4M
{
26
13.4M
  const uint8_t *orig_p = p;
27
13.4M
  uint64_t Value = 0;
28
13.4M
  unsigned Shift = 0;
29
14.8M
  do {
30
14.8M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
14.8M
    Shift += 7;
32
14.8M
  } while (*p++ >= 128);
33
13.4M
  if (n)
34
13.4M
    *n = (unsigned)(p - orig_p);
35
13.4M
  return Value;
36
13.4M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
3.51M
{
26
3.51M
  const uint8_t *orig_p = p;
27
3.51M
  uint64_t Value = 0;
28
3.51M
  unsigned Shift = 0;
29
3.87M
  do {
30
3.87M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.87M
    Shift += 7;
32
3.87M
  } while (*p++ >= 128);
33
3.51M
  if (n)
34
3.51M
    *n = (unsigned)(p - orig_p);
35
3.51M
  return Value;
36
3.51M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
1.95M
{
26
1.95M
  const uint8_t *orig_p = p;
27
1.95M
  uint64_t Value = 0;
28
1.95M
  unsigned Shift = 0;
29
2.04M
  do {
30
2.04M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.04M
    Shift += 7;
32
2.04M
  } while (*p++ >= 128);
33
1.95M
  if (n)
34
1.95M
    *n = (unsigned)(p - orig_p);
35
1.95M
  return Value;
36
1.95M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
987k
{
26
987k
  const uint8_t *orig_p = p;
27
987k
  uint64_t Value = 0;
28
987k
  unsigned Shift = 0;
29
1.02M
  do {
30
1.02M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.02M
    Shift += 7;
32
1.02M
  } while (*p++ >= 128);
33
987k
  if (n)
34
987k
    *n = (unsigned)(p - orig_p);
35
987k
  return Value;
36
987k
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
985k
{
26
985k
  const uint8_t *orig_p = p;
27
985k
  uint64_t Value = 0;
28
985k
  unsigned Shift = 0;
29
1.01M
  do {
30
1.01M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.01M
    Shift += 7;
32
1.01M
  } while (*p++ >= 128);
33
985k
  if (n)
34
985k
    *n = (unsigned)(p - orig_p);
35
985k
  return Value;
36
985k
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
3.87M
{
26
3.87M
  const uint8_t *orig_p = p;
27
3.87M
  uint64_t Value = 0;
28
3.87M
  unsigned Shift = 0;
29
5.37M
  do {
30
5.37M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.37M
    Shift += 7;
32
5.37M
  } while (*p++ >= 128);
33
3.87M
  if (n)
34
3.87M
    *n = (unsigned)(p - orig_p);
35
3.87M
  return Value;
36
3.87M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
705k
{
26
705k
  const uint8_t *orig_p = p;
27
705k
  uint64_t Value = 0;
28
705k
  unsigned Shift = 0;
29
881k
  do {
30
881k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
881k
    Shift += 7;
32
881k
  } while (*p++ >= 128);
33
705k
  if (n)
34
705k
    *n = (unsigned)(p - orig_p);
35
705k
  return Value;
36
705k
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H