Coverage Report

Created: 2025-10-28 07:02

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
54.5M
{
26
54.5M
  const uint8_t *orig_p = p;
27
54.5M
  uint64_t Value = 0;
28
54.5M
  unsigned Shift = 0;
29
61.0M
  do {
30
61.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
61.0M
    Shift += 7;
32
61.0M
  } while (*p++ >= 128);
33
54.5M
  if (n)
34
54.5M
    *n = (unsigned)(p - orig_p);
35
54.5M
  return Value;
36
54.5M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
19.6M
{
26
19.6M
  const uint8_t *orig_p = p;
27
19.6M
  uint64_t Value = 0;
28
19.6M
  unsigned Shift = 0;
29
21.6M
  do {
30
21.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
21.6M
    Shift += 7;
32
21.6M
  } while (*p++ >= 128);
33
19.6M
  if (n)
34
19.6M
    *n = (unsigned)(p - orig_p);
35
19.6M
  return Value;
36
19.6M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
10.0M
{
26
10.0M
  const uint8_t *orig_p = p;
27
10.0M
  uint64_t Value = 0;
28
10.0M
  unsigned Shift = 0;
29
10.9M
  do {
30
10.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.9M
    Shift += 7;
32
10.9M
  } while (*p++ >= 128);
33
10.0M
  if (n)
34
10.0M
    *n = (unsigned)(p - orig_p);
35
10.0M
  return Value;
36
10.0M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.49M
{
26
3.49M
  const uint8_t *orig_p = p;
27
3.49M
  uint64_t Value = 0;
28
3.49M
  unsigned Shift = 0;
29
3.61M
  do {
30
3.61M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.61M
    Shift += 7;
32
3.61M
  } while (*p++ >= 128);
33
3.49M
  if (n)
34
3.49M
    *n = (unsigned)(p - orig_p);
35
3.49M
  return Value;
36
3.49M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
6.32M
{
26
6.32M
  const uint8_t *orig_p = p;
27
6.32M
  uint64_t Value = 0;
28
6.32M
  unsigned Shift = 0;
29
6.57M
  do {
30
6.57M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.57M
    Shift += 7;
32
6.57M
  } while (*p++ >= 128);
33
6.32M
  if (n)
34
6.32M
    *n = (unsigned)(p - orig_p);
35
6.32M
  return Value;
36
6.32M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.05M
{
26
2.05M
  const uint8_t *orig_p = p;
27
2.05M
  uint64_t Value = 0;
28
2.05M
  unsigned Shift = 0;
29
2.09M
  do {
30
2.09M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.09M
    Shift += 7;
32
2.09M
  } while (*p++ >= 128);
33
2.05M
  if (n)
34
2.05M
    *n = (unsigned)(p - orig_p);
35
2.05M
  return Value;
36
2.05M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
7.13M
{
26
7.13M
  const uint8_t *orig_p = p;
27
7.13M
  uint64_t Value = 0;
28
7.13M
  unsigned Shift = 0;
29
9.93M
  do {
30
9.93M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.93M
    Shift += 7;
32
9.93M
  } while (*p++ >= 128);
33
7.13M
  if (n)
34
7.13M
    *n = (unsigned)(p - orig_p);
35
7.13M
  return Value;
36
7.13M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
699k
{
26
699k
  const uint8_t *orig_p = p;
27
699k
  uint64_t Value = 0;
28
699k
  unsigned Shift = 0;
29
772k
  do {
30
772k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
772k
    Shift += 7;
32
772k
  } while (*p++ >= 128);
33
699k
  if (n)
34
699k
    *n = (unsigned)(p - orig_p);
35
699k
  return Value;
36
699k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.10M
{
26
1.10M
  const uint8_t *orig_p = p;
27
1.10M
  uint64_t Value = 0;
28
1.10M
  unsigned Shift = 0;
29
1.12M
  do {
30
1.12M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.12M
    Shift += 7;
32
1.12M
  } while (*p++ >= 128);
33
1.10M
  if (n)
34
1.10M
    *n = (unsigned)(p - orig_p);
35
1.10M
  return Value;
36
1.10M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
4.07M
{
26
4.07M
  const uint8_t *orig_p = p;
27
4.07M
  uint64_t Value = 0;
28
4.07M
  unsigned Shift = 0;
29
4.25M
  do {
30
4.25M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.25M
    Shift += 7;
32
4.25M
  } while (*p++ >= 128);
33
4.07M
  if (n)
34
4.07M
    *n = (unsigned)(p - orig_p);
35
4.07M
  return Value;
36
4.07M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H