Coverage Report

Created: 2026-06-15 06:41

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
39.0M
{
26
39.0M
  const uint8_t *orig_p = p;
27
39.0M
  uint64_t Value = 0;
28
39.0M
  unsigned Shift = 0;
29
44.2M
  do {
30
44.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
44.2M
    Shift += 7;
32
44.2M
  } while (*p++ >= 128);
33
39.0M
  if (n)
34
39.0M
    *n = (unsigned)(p - orig_p);
35
39.0M
  return Value;
36
39.0M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
556k
{
26
556k
  const uint8_t *orig_p = p;
27
556k
  uint64_t Value = 0;
28
556k
  unsigned Shift = 0;
29
617k
  do {
30
617k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
617k
    Shift += 7;
32
617k
  } while (*p++ >= 128);
33
556k
  if (n)
34
556k
    *n = (unsigned)(p - orig_p);
35
556k
  return Value;
36
556k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
579k
{
26
579k
  const uint8_t *orig_p = p;
27
579k
  uint64_t Value = 0;
28
579k
  unsigned Shift = 0;
29
591k
  do {
30
591k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
591k
    Shift += 7;
32
591k
  } while (*p++ >= 128);
33
579k
  if (n)
34
579k
    *n = (unsigned)(p - orig_p);
35
579k
  return Value;
36
579k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
1.35M
{
26
1.35M
  const uint8_t *orig_p = p;
27
1.35M
  uint64_t Value = 0;
28
1.35M
  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.35M
  if (n)
34
1.35M
    *n = (unsigned)(p - orig_p);
35
1.35M
  return Value;
36
1.35M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
19.1M
{
26
19.1M
  const uint8_t *orig_p = p;
27
19.1M
  uint64_t Value = 0;
28
19.1M
  unsigned Shift = 0;
29
21.2M
  do {
30
21.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
21.2M
    Shift += 7;
32
21.2M
  } while (*p++ >= 128);
33
19.1M
  if (n)
34
19.1M
    *n = (unsigned)(p - orig_p);
35
19.1M
  return Value;
36
19.1M
}
AArch64Disassembler.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.78M
  do {
30
4.78M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.78M
    Shift += 7;
32
4.78M
  } while (*p++ >= 128);
33
4.34M
  if (n)
34
4.34M
    *n = (unsigned)(p - orig_p);
35
4.34M
  return Value;
36
4.34M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.14M
{
26
3.14M
  const uint8_t *orig_p = p;
27
3.14M
  uint64_t Value = 0;
28
3.14M
  unsigned Shift = 0;
29
3.28M
  do {
30
3.28M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.28M
    Shift += 7;
32
3.28M
  } while (*p++ >= 128);
33
3.14M
  if (n)
34
3.14M
    *n = (unsigned)(p - orig_p);
35
3.14M
  return Value;
36
3.14M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
2.24M
{
26
2.24M
  const uint8_t *orig_p = p;
27
2.24M
  uint64_t Value = 0;
28
2.24M
  unsigned Shift = 0;
29
2.33M
  do {
30
2.33M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.33M
    Shift += 7;
32
2.33M
  } while (*p++ >= 128);
33
2.24M
  if (n)
34
2.24M
    *n = (unsigned)(p - orig_p);
35
2.24M
  return Value;
36
2.24M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.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.11M
  do {
30
1.11M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.11M
    Shift += 7;
32
1.11M
  } while (*p++ >= 128);
33
1.07M
  if (n)
34
1.07M
    *n = (unsigned)(p - orig_p);
35
1.07M
  return Value;
36
1.07M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
4.93M
{
26
4.93M
  const uint8_t *orig_p = p;
27
4.93M
  uint64_t Value = 0;
28
4.93M
  unsigned Shift = 0;
29
6.82M
  do {
30
6.82M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.82M
    Shift += 7;
32
6.82M
  } while (*p++ >= 128);
33
4.93M
  if (n)
34
4.93M
    *n = (unsigned)(p - orig_p);
35
4.93M
  return Value;
36
4.93M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
1.69M
{
26
1.69M
  const uint8_t *orig_p = p;
27
1.69M
  uint64_t Value = 0;
28
1.69M
  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.69M
  if (n)
34
1.69M
    *n = (unsigned)(p - orig_p);
35
1.69M
  return Value;
36
1.69M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H