Coverage Report

Created: 2026-01-17 06:58

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
115M
{
26
115M
  const uint8_t *orig_p = p;
27
115M
  uint64_t Value = 0;
28
115M
  unsigned Shift = 0;
29
130M
  do {
30
130M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
130M
    Shift += 7;
32
130M
  } while (*p++ >= 128);
33
115M
  if (n)
34
115M
    *n = (unsigned)(p - orig_p);
35
115M
  return Value;
36
115M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
51.1M
{
26
51.1M
  const uint8_t *orig_p = p;
27
51.1M
  uint64_t Value = 0;
28
51.1M
  unsigned Shift = 0;
29
56.5M
  do {
30
56.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
56.5M
    Shift += 7;
32
56.5M
  } while (*p++ >= 128);
33
51.1M
  if (n)
34
51.1M
    *n = (unsigned)(p - orig_p);
35
51.1M
  return Value;
36
51.1M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
16.0M
{
26
16.0M
  const uint8_t *orig_p = p;
27
16.0M
  uint64_t Value = 0;
28
16.0M
  unsigned Shift = 0;
29
17.5M
  do {
30
17.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
17.5M
    Shift += 7;
32
17.5M
  } while (*p++ >= 128);
33
16.0M
  if (n)
34
16.0M
    *n = (unsigned)(p - orig_p);
35
16.0M
  return Value;
36
16.0M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
8.75M
{
26
8.75M
  const uint8_t *orig_p = p;
27
8.75M
  uint64_t Value = 0;
28
8.75M
  unsigned Shift = 0;
29
9.10M
  do {
30
9.10M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.10M
    Shift += 7;
32
9.10M
  } while (*p++ >= 128);
33
8.75M
  if (n)
34
8.75M
    *n = (unsigned)(p - orig_p);
35
8.75M
  return Value;
36
8.75M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
10.8M
{
26
10.8M
  const uint8_t *orig_p = p;
27
10.8M
  uint64_t Value = 0;
28
10.8M
  unsigned Shift = 0;
29
11.2M
  do {
30
11.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
11.2M
    Shift += 7;
32
11.2M
  } while (*p++ >= 128);
33
10.8M
  if (n)
34
10.8M
    *n = (unsigned)(p - orig_p);
35
10.8M
  return Value;
36
10.8M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.81M
{
26
3.81M
  const uint8_t *orig_p = p;
27
3.81M
  uint64_t Value = 0;
28
3.81M
  unsigned Shift = 0;
29
3.91M
  do {
30
3.91M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.91M
    Shift += 7;
32
3.91M
  } while (*p++ >= 128);
33
3.81M
  if (n)
34
3.81M
    *n = (unsigned)(p - orig_p);
35
3.81M
  return Value;
36
3.81M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
15.8M
{
26
15.8M
  const uint8_t *orig_p = p;
27
15.8M
  uint64_t Value = 0;
28
15.8M
  unsigned Shift = 0;
29
22.0M
  do {
30
22.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
22.0M
    Shift += 7;
32
22.0M
  } while (*p++ >= 128);
33
15.8M
  if (n)
34
15.8M
    *n = (unsigned)(p - orig_p);
35
15.8M
  return Value;
36
15.8M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.52M
{
26
1.52M
  const uint8_t *orig_p = p;
27
1.52M
  uint64_t Value = 0;
28
1.52M
  unsigned Shift = 0;
29
1.69M
  do {
30
1.69M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.69M
    Shift += 7;
32
1.69M
  } while (*p++ >= 128);
33
1.52M
  if (n)
34
1.52M
    *n = (unsigned)(p - orig_p);
35
1.52M
  return Value;
36
1.52M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
2.10M
{
26
2.10M
  const uint8_t *orig_p = p;
27
2.10M
  uint64_t Value = 0;
28
2.10M
  unsigned Shift = 0;
29
2.15M
  do {
30
2.15M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.15M
    Shift += 7;
32
2.15M
  } while (*p++ >= 128);
33
2.10M
  if (n)
34
2.10M
    *n = (unsigned)(p - orig_p);
35
2.10M
  return Value;
36
2.10M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
5.77M
{
26
5.77M
  const uint8_t *orig_p = p;
27
5.77M
  uint64_t Value = 0;
28
5.77M
  unsigned Shift = 0;
29
6.03M
  do {
30
6.03M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.03M
    Shift += 7;
32
6.03M
  } while (*p++ >= 128);
33
5.77M
  if (n)
34
5.77M
    *n = (unsigned)(p - orig_p);
35
5.77M
  return Value;
36
5.77M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H