Coverage Report

Created: 2025-10-14 06:42

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
50.5M
{
26
50.5M
  const uint8_t *orig_p = p;
27
50.5M
  uint64_t Value = 0;
28
50.5M
  unsigned Shift = 0;
29
56.4M
  do {
30
56.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
56.4M
    Shift += 7;
32
56.4M
  } while (*p++ >= 128);
33
50.5M
  if (n)
34
50.5M
    *n = (unsigned)(p - orig_p);
35
50.5M
  return Value;
36
50.5M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
20.0M
{
26
20.0M
  const uint8_t *orig_p = p;
27
20.0M
  uint64_t Value = 0;
28
20.0M
  unsigned Shift = 0;
29
22.2M
  do {
30
22.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
22.2M
    Shift += 7;
32
22.2M
  } while (*p++ >= 128);
33
20.0M
  if (n)
34
20.0M
    *n = (unsigned)(p - orig_p);
35
20.0M
  return Value;
36
20.0M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
8.79M
{
26
8.79M
  const uint8_t *orig_p = p;
27
8.79M
  uint64_t Value = 0;
28
8.79M
  unsigned Shift = 0;
29
9.63M
  do {
30
9.63M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.63M
    Shift += 7;
32
9.63M
  } while (*p++ >= 128);
33
8.79M
  if (n)
34
8.79M
    *n = (unsigned)(p - orig_p);
35
8.79M
  return Value;
36
8.79M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.41M
{
26
3.41M
  const uint8_t *orig_p = p;
27
3.41M
  uint64_t Value = 0;
28
3.41M
  unsigned Shift = 0;
29
3.53M
  do {
30
3.53M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.53M
    Shift += 7;
32
3.53M
  } while (*p++ >= 128);
33
3.41M
  if (n)
34
3.41M
    *n = (unsigned)(p - orig_p);
35
3.41M
  return Value;
36
3.41M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
5.75M
{
26
5.75M
  const uint8_t *orig_p = p;
27
5.75M
  uint64_t Value = 0;
28
5.75M
  unsigned Shift = 0;
29
5.98M
  do {
30
5.98M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
5.98M
    Shift += 7;
32
5.98M
  } while (*p++ >= 128);
33
5.75M
  if (n)
34
5.75M
    *n = (unsigned)(p - orig_p);
35
5.75M
  return Value;
36
5.75M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
1.87M
{
26
1.87M
  const uint8_t *orig_p = p;
27
1.87M
  uint64_t Value = 0;
28
1.87M
  unsigned Shift = 0;
29
1.92M
  do {
30
1.92M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.92M
    Shift += 7;
32
1.92M
  } while (*p++ >= 128);
33
1.87M
  if (n)
34
1.87M
    *n = (unsigned)(p - orig_p);
35
1.87M
  return Value;
36
1.87M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
5.80M
{
26
5.80M
  const uint8_t *orig_p = p;
27
5.80M
  uint64_t Value = 0;
28
5.80M
  unsigned Shift = 0;
29
8.03M
  do {
30
8.03M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.03M
    Shift += 7;
32
8.03M
  } while (*p++ >= 128);
33
5.80M
  if (n)
34
5.80M
    *n = (unsigned)(p - orig_p);
35
5.80M
  return Value;
36
5.80M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
644k
{
26
644k
  const uint8_t *orig_p = p;
27
644k
  uint64_t Value = 0;
28
644k
  unsigned Shift = 0;
29
717k
  do {
30
717k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
717k
    Shift += 7;
32
717k
  } while (*p++ >= 128);
33
644k
  if (n)
34
644k
    *n = (unsigned)(p - orig_p);
35
644k
  return Value;
36
644k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
977k
{
26
977k
  const uint8_t *orig_p = p;
27
977k
  uint64_t Value = 0;
28
977k
  unsigned Shift = 0;
29
999k
  do {
30
999k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
999k
    Shift += 7;
32
999k
  } while (*p++ >= 128);
33
977k
  if (n)
34
977k
    *n = (unsigned)(p - orig_p);
35
977k
  return Value;
36
977k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.20M
{
26
3.20M
  const uint8_t *orig_p = p;
27
3.20M
  uint64_t Value = 0;
28
3.20M
  unsigned Shift = 0;
29
3.35M
  do {
30
3.35M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.35M
    Shift += 7;
32
3.35M
  } while (*p++ >= 128);
33
3.20M
  if (n)
34
3.20M
    *n = (unsigned)(p - orig_p);
35
3.20M
  return Value;
36
3.20M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H