Coverage Report

Created: 2025-10-28 07:02

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.50M
{
26
1.50M
  const uint8_t *orig_p = p;
27
1.50M
  uint64_t Value = 0;
28
1.50M
  unsigned Shift = 0;
29
1.67M
  do {
30
1.67M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.67M
    Shift += 7;
32
1.67M
  } while (*p++ >= 128);
33
1.50M
  if (n)
34
1.50M
    *n = (unsigned)(p - orig_p);
35
1.50M
  return Value;
36
1.50M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
2.00M
{
26
2.00M
  const uint8_t *orig_p = p;
27
2.00M
  uint64_t Value = 0;
28
2.00M
  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
2.00M
  if (n)
34
2.00M
    *n = (unsigned)(p - orig_p);
35
2.00M
  return Value;
36
2.00M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
7.21M
{
26
7.21M
  const uint8_t *orig_p = p;
27
7.21M
  uint64_t Value = 0;
28
7.21M
  unsigned Shift = 0;
29
7.53M
  do {
30
7.53M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.53M
    Shift += 7;
32
7.53M
  } while (*p++ >= 128);
33
7.21M
  if (n)
34
7.21M
    *n = (unsigned)(p - orig_p);
35
7.21M
  return Value;
36
7.21M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
48.4M
{
26
48.4M
  const uint8_t *orig_p = p;
27
48.4M
  uint64_t Value = 0;
28
48.4M
  unsigned Shift = 0;
29
53.5M
  do {
30
53.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
53.5M
    Shift += 7;
32
53.5M
  } while (*p++ >= 128);
33
48.4M
  if (n)
34
48.4M
    *n = (unsigned)(p - orig_p);
35
48.4M
  return Value;
36
48.4M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
18.5M
{
26
18.5M
  const uint8_t *orig_p = p;
27
18.5M
  uint64_t Value = 0;
28
18.5M
  unsigned Shift = 0;
29
20.4M
  do {
30
20.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
20.4M
    Shift += 7;
32
20.4M
  } while (*p++ >= 128);
33
18.5M
  if (n)
34
18.5M
    *n = (unsigned)(p - orig_p);
35
18.5M
  return Value;
36
18.5M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
8.04M
{
26
8.04M
  const uint8_t *orig_p = p;
27
8.04M
  uint64_t Value = 0;
28
8.04M
  unsigned Shift = 0;
29
8.37M
  do {
30
8.37M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.37M
    Shift += 7;
32
8.37M
  } while (*p++ >= 128);
33
8.04M
  if (n)
34
8.04M
    *n = (unsigned)(p - orig_p);
35
8.04M
  return Value;
36
8.04M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
10.7M
{
26
10.7M
  const uint8_t *orig_p = p;
27
10.7M
  uint64_t Value = 0;
28
10.7M
  unsigned Shift = 0;
29
11.1M
  do {
30
11.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
11.1M
    Shift += 7;
32
11.1M
  } while (*p++ >= 128);
33
10.7M
  if (n)
34
10.7M
    *n = (unsigned)(p - orig_p);
35
10.7M
  return Value;
36
10.7M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.86M
{
26
3.86M
  const uint8_t *orig_p = p;
27
3.86M
  uint64_t Value = 0;
28
3.86M
  unsigned Shift = 0;
29
3.97M
  do {
30
3.97M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.97M
    Shift += 7;
32
3.97M
  } while (*p++ >= 128);
33
3.86M
  if (n)
34
3.86M
    *n = (unsigned)(p - orig_p);
35
3.86M
  return Value;
36
3.86M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
16.9M
{
26
16.9M
  const uint8_t *orig_p = p;
27
16.9M
  uint64_t Value = 0;
28
16.9M
  unsigned Shift = 0;
29
23.6M
  do {
30
23.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
23.6M
    Shift += 7;
32
23.6M
  } while (*p++ >= 128);
33
16.9M
  if (n)
34
16.9M
    *n = (unsigned)(p - orig_p);
35
16.9M
  return Value;
36
16.9M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
2.22M
{
26
2.22M
  const uint8_t *orig_p = p;
27
2.22M
  uint64_t Value = 0;
28
2.22M
  unsigned Shift = 0;
29
2.82M
  do {
30
2.82M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.82M
    Shift += 7;
32
2.82M
  } while (*p++ >= 128);
33
2.22M
  if (n)
34
2.22M
    *n = (unsigned)(p - orig_p);
35
2.22M
  return Value;
36
2.22M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H