Coverage Report

Created: 2025-10-10 06:20

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
23.1M
{
26
23.1M
  const uint8_t *orig_p = p;
27
23.1M
  uint64_t Value = 0;
28
23.1M
  unsigned Shift = 0;
29
26.4M
  do {
30
26.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
26.4M
    Shift += 7;
32
26.4M
  } while (*p++ >= 128);
33
23.1M
  if (n)
34
23.1M
    *n = (unsigned)(p - orig_p);
35
23.1M
  return Value;
36
23.1M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
311k
{
26
311k
  const uint8_t *orig_p = p;
27
311k
  uint64_t Value = 0;
28
311k
  unsigned Shift = 0;
29
339k
  do {
30
339k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
339k
    Shift += 7;
32
339k
  } while (*p++ >= 128);
33
311k
  if (n)
34
311k
    *n = (unsigned)(p - orig_p);
35
311k
  return Value;
36
311k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
357k
{
26
357k
  const uint8_t *orig_p = p;
27
357k
  uint64_t Value = 0;
28
357k
  unsigned Shift = 0;
29
365k
  do {
30
365k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
365k
    Shift += 7;
32
365k
  } while (*p++ >= 128);
33
357k
  if (n)
34
357k
    *n = (unsigned)(p - orig_p);
35
357k
  return Value;
36
357k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
911k
{
26
911k
  const uint8_t *orig_p = p;
27
911k
  uint64_t Value = 0;
28
911k
  unsigned Shift = 0;
29
954k
  do {
30
954k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
954k
    Shift += 7;
32
954k
  } while (*p++ >= 128);
33
911k
  if (n)
34
911k
    *n = (unsigned)(p - orig_p);
35
911k
  return Value;
36
911k
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
10.5M
{
26
10.5M
  const uint8_t *orig_p = p;
27
10.5M
  uint64_t Value = 0;
28
10.5M
  unsigned Shift = 0;
29
11.7M
  do {
30
11.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
11.7M
    Shift += 7;
32
11.7M
  } while (*p++ >= 128);
33
10.5M
  if (n)
34
10.5M
    *n = (unsigned)(p - orig_p);
35
10.5M
  return Value;
36
10.5M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
2.78M
{
26
2.78M
  const uint8_t *orig_p = p;
27
2.78M
  uint64_t Value = 0;
28
2.78M
  unsigned Shift = 0;
29
3.07M
  do {
30
3.07M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.07M
    Shift += 7;
32
3.07M
  } while (*p++ >= 128);
33
2.78M
  if (n)
34
2.78M
    *n = (unsigned)(p - orig_p);
35
2.78M
  return Value;
36
2.78M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
1.65M
{
26
1.65M
  const uint8_t *orig_p = p;
27
1.65M
  uint64_t Value = 0;
28
1.65M
  unsigned Shift = 0;
29
1.73M
  do {
30
1.73M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.73M
    Shift += 7;
32
1.73M
  } while (*p++ >= 128);
33
1.65M
  if (n)
34
1.65M
    *n = (unsigned)(p - orig_p);
35
1.65M
  return Value;
36
1.65M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
1.49M
{
26
1.49M
  const uint8_t *orig_p = p;
27
1.49M
  uint64_t Value = 0;
28
1.49M
  unsigned Shift = 0;
29
1.55M
  do {
30
1.55M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.55M
    Shift += 7;
32
1.55M
  } while (*p++ >= 128);
33
1.49M
  if (n)
34
1.49M
    *n = (unsigned)(p - orig_p);
35
1.49M
  return Value;
36
1.49M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
777k
{
26
777k
  const uint8_t *orig_p = p;
27
777k
  uint64_t Value = 0;
28
777k
  unsigned Shift = 0;
29
805k
  do {
30
805k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
805k
    Shift += 7;
32
805k
  } while (*p++ >= 128);
33
777k
  if (n)
34
777k
    *n = (unsigned)(p - orig_p);
35
777k
  return Value;
36
777k
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
3.47M
{
26
3.47M
  const uint8_t *orig_p = p;
27
3.47M
  uint64_t Value = 0;
28
3.47M
  unsigned Shift = 0;
29
4.85M
  do {
30
4.85M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.85M
    Shift += 7;
32
4.85M
  } while (*p++ >= 128);
33
3.47M
  if (n)
34
3.47M
    *n = (unsigned)(p - orig_p);
35
3.47M
  return Value;
36
3.47M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
835k
{
26
835k
  const uint8_t *orig_p = p;
27
835k
  uint64_t Value = 0;
28
835k
  unsigned Shift = 0;
29
1.07M
  do {
30
1.07M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.07M
    Shift += 7;
32
1.07M
  } while (*p++ >= 128);
33
835k
  if (n)
34
835k
    *n = (unsigned)(p - orig_p);
35
835k
  return Value;
36
835k
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H