Coverage Report

Created: 2026-09-01 07:20

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
39.1M
{
26
39.1M
  const uint8_t *orig_p = p;
27
39.1M
  uint64_t Value = 0;
28
39.1M
  unsigned Shift = 0;
29
43.9M
  do {
30
43.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
43.9M
    Shift += 7;
32
43.9M
  } while (*p++ >= 128);
33
39.1M
  if (n)
34
39.1M
    *n = (unsigned)(p - orig_p);
35
39.1M
  return Value;
36
39.1M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
15.2M
{
26
15.2M
  const uint8_t *orig_p = p;
27
15.2M
  uint64_t Value = 0;
28
15.2M
  unsigned Shift = 0;
29
16.9M
  do {
30
16.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
16.9M
    Shift += 7;
32
16.9M
  } while (*p++ >= 128);
33
15.2M
  if (n)
34
15.2M
    *n = (unsigned)(p - orig_p);
35
15.2M
  return Value;
36
15.2M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
5.40M
{
26
5.40M
  const uint8_t *orig_p = p;
27
5.40M
  uint64_t Value = 0;
28
5.40M
  unsigned Shift = 0;
29
5.91M
  do {
30
5.91M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.91M
    Shift += 7;
32
5.91M
  } while (*p++ >= 128);
33
5.40M
  if (n)
34
5.40M
    *n = (unsigned)(p - orig_p);
35
5.40M
  return Value;
36
5.40M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.29M
{
26
3.29M
  const uint8_t *orig_p = p;
27
3.29M
  uint64_t Value = 0;
28
3.29M
  unsigned Shift = 0;
29
3.41M
  do {
30
3.41M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.41M
    Shift += 7;
32
3.41M
  } while (*p++ >= 128);
33
3.29M
  if (n)
34
3.29M
    *n = (unsigned)(p - orig_p);
35
3.29M
  return Value;
36
3.29M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
4.62M
{
26
4.62M
  const uint8_t *orig_p = p;
27
4.62M
  uint64_t Value = 0;
28
4.62M
  unsigned Shift = 0;
29
4.80M
  do {
30
4.80M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.80M
    Shift += 7;
32
4.80M
  } while (*p++ >= 128);
33
4.62M
  if (n)
34
4.62M
    *n = (unsigned)(p - orig_p);
35
4.62M
  return Value;
36
4.62M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.48M
{
26
1.48M
  const uint8_t *orig_p = p;
27
1.48M
  uint64_t Value = 0;
28
1.48M
  unsigned Shift = 0;
29
1.52M
  do {
30
1.52M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.52M
    Shift += 7;
32
1.52M
  } while (*p++ >= 128);
33
1.48M
  if (n)
34
1.48M
    *n = (unsigned)(p - orig_p);
35
1.48M
  return Value;
36
1.48M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
5.47M
{
26
5.47M
  const uint8_t *orig_p = p;
27
5.47M
  uint64_t Value = 0;
28
5.47M
  unsigned Shift = 0;
29
7.58M
  do {
30
7.58M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.58M
    Shift += 7;
32
7.58M
  } while (*p++ >= 128);
33
5.47M
  if (n)
34
5.47M
    *n = (unsigned)(p - orig_p);
35
5.47M
  return Value;
36
5.47M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
647k
{
26
647k
  const uint8_t *orig_p = p;
27
647k
  uint64_t Value = 0;
28
647k
  unsigned Shift = 0;
29
706k
  do {
30
706k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
706k
    Shift += 7;
32
706k
  } while (*p++ >= 128);
33
647k
  if (n)
34
647k
    *n = (unsigned)(p - orig_p);
35
647k
  return Value;
36
647k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
707k
{
26
707k
  const uint8_t *orig_p = p;
27
707k
  uint64_t Value = 0;
28
707k
  unsigned Shift = 0;
29
722k
  do {
30
722k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
722k
    Shift += 7;
32
722k
  } while (*p++ >= 128);
33
707k
  if (n)
34
707k
    *n = (unsigned)(p - orig_p);
35
707k
  return Value;
36
707k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.25M
{
26
2.25M
  const uint8_t *orig_p = p;
27
2.25M
  uint64_t Value = 0;
28
2.25M
  unsigned Shift = 0;
29
2.35M
  do {
30
2.35M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.35M
    Shift += 7;
32
2.35M
  } while (*p++ >= 128);
33
2.25M
  if (n)
34
2.25M
    *n = (unsigned)(p - orig_p);
35
2.25M
  return Value;
36
2.25M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H