Coverage Report

Created: 2026-02-26 07:11

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
37.9M
{
26
37.9M
  const uint8_t *orig_p = p;
27
37.9M
  uint64_t Value = 0;
28
37.9M
  unsigned Shift = 0;
29
42.6M
  do {
30
42.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
42.6M
    Shift += 7;
32
42.6M
  } while (*p++ >= 128);
33
37.9M
  if (n)
34
37.9M
    *n = (unsigned)(p - orig_p);
35
37.9M
  return Value;
36
37.9M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
15.0M
{
26
15.0M
  const uint8_t *orig_p = p;
27
15.0M
  uint64_t Value = 0;
28
15.0M
  unsigned Shift = 0;
29
16.5M
  do {
30
16.5M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
16.5M
    Shift += 7;
32
16.5M
  } while (*p++ >= 128);
33
15.0M
  if (n)
34
15.0M
    *n = (unsigned)(p - orig_p);
35
15.0M
  return Value;
36
15.0M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
5.71M
{
26
5.71M
  const uint8_t *orig_p = p;
27
5.71M
  uint64_t Value = 0;
28
5.71M
  unsigned Shift = 0;
29
6.25M
  do {
30
6.25M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.25M
    Shift += 7;
32
6.25M
  } while (*p++ >= 128);
33
5.71M
  if (n)
34
5.71M
    *n = (unsigned)(p - orig_p);
35
5.71M
  return Value;
36
5.71M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
2.89M
{
26
2.89M
  const uint8_t *orig_p = p;
27
2.89M
  uint64_t Value = 0;
28
2.89M
  unsigned Shift = 0;
29
2.99M
  do {
30
2.99M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.99M
    Shift += 7;
32
2.99M
  } while (*p++ >= 128);
33
2.89M
  if (n)
34
2.89M
    *n = (unsigned)(p - orig_p);
35
2.89M
  return Value;
36
2.89M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
4.06M
{
26
4.06M
  const uint8_t *orig_p = p;
27
4.06M
  uint64_t Value = 0;
28
4.06M
  unsigned Shift = 0;
29
4.23M
  do {
30
4.23M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.23M
    Shift += 7;
32
4.23M
  } while (*p++ >= 128);
33
4.06M
  if (n)
34
4.06M
    *n = (unsigned)(p - orig_p);
35
4.06M
  return Value;
36
4.06M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.26M
{
26
1.26M
  const uint8_t *orig_p = p;
27
1.26M
  uint64_t Value = 0;
28
1.26M
  unsigned Shift = 0;
29
1.30M
  do {
30
1.30M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.30M
    Shift += 7;
32
1.30M
  } while (*p++ >= 128);
33
1.26M
  if (n)
34
1.26M
    *n = (unsigned)(p - orig_p);
35
1.26M
  return Value;
36
1.26M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
5.41M
{
26
5.41M
  const uint8_t *orig_p = p;
27
5.41M
  uint64_t Value = 0;
28
5.41M
  unsigned Shift = 0;
29
7.53M
  do {
30
7.53M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.53M
    Shift += 7;
32
7.53M
  } while (*p++ >= 128);
33
5.41M
  if (n)
34
5.41M
    *n = (unsigned)(p - orig_p);
35
5.41M
  return Value;
36
5.41M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
593k
{
26
593k
  const uint8_t *orig_p = p;
27
593k
  uint64_t Value = 0;
28
593k
  unsigned Shift = 0;
29
653k
  do {
30
653k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
653k
    Shift += 7;
32
653k
  } while (*p++ >= 128);
33
593k
  if (n)
34
593k
    *n = (unsigned)(p - orig_p);
35
593k
  return Value;
36
593k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
791k
{
26
791k
  const uint8_t *orig_p = p;
27
791k
  uint64_t Value = 0;
28
791k
  unsigned Shift = 0;
29
808k
  do {
30
808k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
808k
    Shift += 7;
32
808k
  } while (*p++ >= 128);
33
791k
  if (n)
34
791k
    *n = (unsigned)(p - orig_p);
35
791k
  return Value;
36
791k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
2.14M
{
26
2.14M
  const uint8_t *orig_p = p;
27
2.14M
  uint64_t Value = 0;
28
2.14M
  unsigned Shift = 0;
29
2.24M
  do {
30
2.24M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.24M
    Shift += 7;
32
2.24M
  } while (*p++ >= 128);
33
2.14M
  if (n)
34
2.14M
    *n = (unsigned)(p - orig_p);
35
2.14M
  return Value;
36
2.14M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H