Coverage Report

Created: 2026-01-09 06:55

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
116M
{
26
116M
  const uint8_t *orig_p = p;
27
116M
  uint64_t Value = 0;
28
116M
  unsigned Shift = 0;
29
131M
  do {
30
131M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
131M
    Shift += 7;
32
131M
  } while (*p++ >= 128);
33
116M
  if (n)
34
116M
    *n = (unsigned)(p - orig_p);
35
116M
  return Value;
36
116M
}
Unexecuted instantiation: SparcModule.c:decodeULEB128
Unexecuted instantiation: PPCMapping.c:decodeULEB128
Unexecuted instantiation: SparcMapping.c:decodeULEB128
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.61M
{
26
1.61M
  const uint8_t *orig_p = p;
27
1.61M
  uint64_t Value = 0;
28
1.61M
  unsigned Shift = 0;
29
1.77M
  do {
30
1.77M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.77M
    Shift += 7;
32
1.77M
  } while (*p++ >= 128);
33
1.61M
  if (n)
34
1.61M
    *n = (unsigned)(p - orig_p);
35
1.61M
  return Value;
36
1.61M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.99M
{
26
1.99M
  const uint8_t *orig_p = p;
27
1.99M
  uint64_t Value = 0;
28
1.99M
  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.99M
  if (n)
34
1.99M
    *n = (unsigned)(p - orig_p);
35
1.99M
  return Value;
36
1.99M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
5.93M
{
26
5.93M
  const uint8_t *orig_p = p;
27
5.93M
  uint64_t Value = 0;
28
5.93M
  unsigned Shift = 0;
29
6.20M
  do {
30
6.20M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.20M
    Shift += 7;
32
6.20M
  } while (*p++ >= 128);
33
5.93M
  if (n)
34
5.93M
    *n = (unsigned)(p - orig_p);
35
5.93M
  return Value;
36
5.93M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
Unexecuted instantiation: AlphaDisassembler.c:decodeULEB128
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
47.8M
{
26
47.8M
  const uint8_t *orig_p = p;
27
47.8M
  uint64_t Value = 0;
28
47.8M
  unsigned Shift = 0;
29
52.7M
  do {
30
52.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
52.7M
    Shift += 7;
32
52.7M
  } while (*p++ >= 128);
33
47.8M
  if (n)
34
47.8M
    *n = (unsigned)(p - orig_p);
35
47.8M
  return Value;
36
47.8M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
17.2M
{
26
17.2M
  const uint8_t *orig_p = p;
27
17.2M
  uint64_t Value = 0;
28
17.2M
  unsigned Shift = 0;
29
18.9M
  do {
30
18.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
18.9M
    Shift += 7;
32
18.9M
  } while (*p++ >= 128);
33
17.2M
  if (n)
34
17.2M
    *n = (unsigned)(p - orig_p);
35
17.2M
  return Value;
36
17.2M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
8.00M
{
26
8.00M
  const uint8_t *orig_p = p;
27
8.00M
  uint64_t Value = 0;
28
8.00M
  unsigned Shift = 0;
29
8.33M
  do {
30
8.33M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.33M
    Shift += 7;
32
8.33M
  } while (*p++ >= 128);
33
8.00M
  if (n)
34
8.00M
    *n = (unsigned)(p - orig_p);
35
8.00M
  return Value;
36
8.00M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
10.6M
{
26
10.6M
  const uint8_t *orig_p = p;
27
10.6M
  uint64_t Value = 0;
28
10.6M
  unsigned Shift = 0;
29
11.0M
  do {
30
11.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
11.0M
    Shift += 7;
32
11.0M
  } while (*p++ >= 128);
33
10.6M
  if (n)
34
10.6M
    *n = (unsigned)(p - orig_p);
35
10.6M
  return Value;
36
10.6M
}
Unexecuted instantiation: PPCInstPrinter.c:decodeULEB128
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.75M
{
26
3.75M
  const uint8_t *orig_p = p;
27
3.75M
  uint64_t Value = 0;
28
3.75M
  unsigned Shift = 0;
29
3.85M
  do {
30
3.85M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.85M
    Shift += 7;
32
3.85M
  } while (*p++ >= 128);
33
3.75M
  if (n)
34
3.75M
    *n = (unsigned)(p - orig_p);
35
3.75M
  return Value;
36
3.75M
}
Unexecuted instantiation: SparcDisassemblerExtension.c:decodeULEB128
Unexecuted instantiation: SparcInstPrinter.c:decodeULEB128
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
16.4M
{
26
16.4M
  const uint8_t *orig_p = p;
27
16.4M
  uint64_t Value = 0;
28
16.4M
  unsigned Shift = 0;
29
22.9M
  do {
30
22.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
22.9M
    Shift += 7;
32
22.9M
  } while (*p++ >= 128);
33
16.4M
  if (n)
34
16.4M
    *n = (unsigned)(p - orig_p);
35
16.4M
  return Value;
36
16.4M
}
Unexecuted instantiation: LoongArchDisassembler.c:decodeULEB128
XtensaDisassembler.c:decodeULEB128
Line
Count
Source
25
2.65M
{
26
2.65M
  const uint8_t *orig_p = p;
27
2.65M
  uint64_t Value = 0;
28
2.65M
  unsigned Shift = 0;
29
3.27M
  do {
30
3.27M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.27M
    Shift += 7;
32
3.27M
  } while (*p++ >= 128);
33
2.65M
  if (n)
34
2.65M
    *n = (unsigned)(p - orig_p);
35
2.65M
  return Value;
36
2.65M
}
Unexecuted instantiation: ARCDisassembler.c:decodeULEB128
37
38
#endif // LLVM_SYSTEM_LEB128_H