Coverage Report

Created: 2026-08-14 06:51

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/capstonev5/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
94.0M
{
26
94.0M
  const uint8_t *orig_p = p;
27
94.0M
  uint64_t Value = 0;
28
94.0M
  unsigned Shift = 0;
29
105M
  do {
30
105M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
105M
    Shift += 7;
32
105M
  } while (*p++ >= 128);
33
94.0M
  if (n)
34
94.0M
    *n = (unsigned)(p - orig_p);
35
94.0M
  return Value;
36
94.0M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
42.0M
{
26
42.0M
  const uint8_t *orig_p = p;
27
42.0M
  uint64_t Value = 0;
28
42.0M
  unsigned Shift = 0;
29
46.5M
  do {
30
46.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
46.5M
    Shift += 7;
32
46.5M
  } while (*p++ >= 128);
33
42.0M
  if (n)
34
42.0M
    *n = (unsigned)(p - orig_p);
35
42.0M
  return Value;
36
42.0M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
11.0M
{
26
11.0M
  const uint8_t *orig_p = p;
27
11.0M
  uint64_t Value = 0;
28
11.0M
  unsigned Shift = 0;
29
12.1M
  do {
30
12.1M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
12.1M
    Shift += 7;
32
12.1M
  } while (*p++ >= 128);
33
11.0M
  if (n)
34
11.0M
    *n = (unsigned)(p - orig_p);
35
11.0M
  return Value;
36
11.0M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
8.52M
{
26
8.52M
  const uint8_t *orig_p = p;
27
8.52M
  uint64_t Value = 0;
28
8.52M
  unsigned Shift = 0;
29
8.87M
  do {
30
8.87M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.87M
    Shift += 7;
32
8.87M
  } while (*p++ >= 128);
33
8.52M
  if (n)
34
8.52M
    *n = (unsigned)(p - orig_p);
35
8.52M
  return Value;
36
8.52M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
8.49M
{
26
8.49M
  const uint8_t *orig_p = p;
27
8.49M
  uint64_t Value = 0;
28
8.49M
  unsigned Shift = 0;
29
8.82M
  do {
30
8.82M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.82M
    Shift += 7;
32
8.82M
  } while (*p++ >= 128);
33
8.49M
  if (n)
34
8.49M
    *n = (unsigned)(p - orig_p);
35
8.49M
  return Value;
36
8.49M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.11M
{
26
3.11M
  const uint8_t *orig_p = p;
27
3.11M
  uint64_t Value = 0;
28
3.11M
  unsigned Shift = 0;
29
3.19M
  do {
30
3.19M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.19M
    Shift += 7;
32
3.19M
  } while (*p++ >= 128);
33
3.11M
  if (n)
34
3.11M
    *n = (unsigned)(p - orig_p);
35
3.11M
  return Value;
36
3.11M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
13.2M
{
26
13.2M
  const uint8_t *orig_p = p;
27
13.2M
  uint64_t Value = 0;
28
13.2M
  unsigned Shift = 0;
29
18.4M
  do {
30
18.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
18.4M
    Shift += 7;
32
18.4M
  } while (*p++ >= 128);
33
13.2M
  if (n)
34
13.2M
    *n = (unsigned)(p - orig_p);
35
13.2M
  return Value;
36
13.2M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.37M
{
26
1.37M
  const uint8_t *orig_p = p;
27
1.37M
  uint64_t Value = 0;
28
1.37M
  unsigned Shift = 0;
29
1.51M
  do {
30
1.51M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.51M
    Shift += 7;
32
1.51M
  } while (*p++ >= 128);
33
1.37M
  if (n)
34
1.37M
    *n = (unsigned)(p - orig_p);
35
1.37M
  return Value;
36
1.37M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.63M
{
26
1.63M
  const uint8_t *orig_p = p;
27
1.63M
  uint64_t Value = 0;
28
1.63M
  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.63M
  if (n)
34
1.63M
    *n = (unsigned)(p - orig_p);
35
1.63M
  return Value;
36
1.63M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
4.54M
{
26
4.54M
  const uint8_t *orig_p = p;
27
4.54M
  uint64_t Value = 0;
28
4.54M
  unsigned Shift = 0;
29
4.73M
  do {
30
4.73M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.73M
    Shift += 7;
32
4.73M
  } while (*p++ >= 128);
33
4.54M
  if (n)
34
4.54M
    *n = (unsigned)(p - orig_p);
35
4.54M
  return Value;
36
4.54M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H