Coverage Report

Created: 2025-11-09 07:00

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
53.0M
{
26
53.0M
  const uint8_t *orig_p = p;
27
53.0M
  uint64_t Value = 0;
28
53.0M
  unsigned Shift = 0;
29
59.3M
  do {
30
59.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
59.3M
    Shift += 7;
32
59.3M
  } while (*p++ >= 128);
33
53.0M
  if (n)
34
53.0M
    *n = (unsigned)(p - orig_p);
35
53.0M
  return Value;
36
53.0M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
18.8M
{
26
18.8M
  const uint8_t *orig_p = p;
27
18.8M
  uint64_t Value = 0;
28
18.8M
  unsigned Shift = 0;
29
20.8M
  do {
30
20.8M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
20.8M
    Shift += 7;
32
20.8M
  } while (*p++ >= 128);
33
18.8M
  if (n)
34
18.8M
    *n = (unsigned)(p - orig_p);
35
18.8M
  return Value;
36
18.8M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
9.78M
{
26
9.78M
  const uint8_t *orig_p = p;
27
9.78M
  uint64_t Value = 0;
28
9.78M
  unsigned Shift = 0;
29
10.7M
  do {
30
10.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.7M
    Shift += 7;
32
10.7M
  } while (*p++ >= 128);
33
9.78M
  if (n)
34
9.78M
    *n = (unsigned)(p - orig_p);
35
9.78M
  return Value;
36
9.78M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
3.54M
{
26
3.54M
  const uint8_t *orig_p = p;
27
3.54M
  uint64_t Value = 0;
28
3.54M
  unsigned Shift = 0;
29
3.67M
  do {
30
3.67M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.67M
    Shift += 7;
32
3.67M
  } while (*p++ >= 128);
33
3.54M
  if (n)
34
3.54M
    *n = (unsigned)(p - orig_p);
35
3.54M
  return Value;
36
3.54M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
6.11M
{
26
6.11M
  const uint8_t *orig_p = p;
27
6.11M
  uint64_t Value = 0;
28
6.11M
  unsigned Shift = 0;
29
6.36M
  do {
30
6.36M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.36M
    Shift += 7;
32
6.36M
  } while (*p++ >= 128);
33
6.11M
  if (n)
34
6.11M
    *n = (unsigned)(p - orig_p);
35
6.11M
  return Value;
36
6.11M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.03M
{
26
2.03M
  const uint8_t *orig_p = p;
27
2.03M
  uint64_t Value = 0;
28
2.03M
  unsigned Shift = 0;
29
2.07M
  do {
30
2.07M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.07M
    Shift += 7;
32
2.07M
  } while (*p++ >= 128);
33
2.03M
  if (n)
34
2.03M
    *n = (unsigned)(p - orig_p);
35
2.03M
  return Value;
36
2.03M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
6.99M
{
26
6.99M
  const uint8_t *orig_p = p;
27
6.99M
  uint64_t Value = 0;
28
6.99M
  unsigned Shift = 0;
29
9.72M
  do {
30
9.72M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.72M
    Shift += 7;
32
9.72M
  } while (*p++ >= 128);
33
6.99M
  if (n)
34
6.99M
    *n = (unsigned)(p - orig_p);
35
6.99M
  return Value;
36
6.99M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
852k
{
26
852k
  const uint8_t *orig_p = p;
27
852k
  uint64_t Value = 0;
28
852k
  unsigned Shift = 0;
29
949k
  do {
30
949k
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
949k
    Shift += 7;
32
949k
  } while (*p++ >= 128);
33
852k
  if (n)
34
852k
    *n = (unsigned)(p - orig_p);
35
852k
  return Value;
36
852k
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
978k
{
26
978k
  const uint8_t *orig_p = p;
27
978k
  uint64_t Value = 0;
28
978k
  unsigned Shift = 0;
29
1.00M
  do {
30
1.00M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.00M
    Shift += 7;
32
1.00M
  } while (*p++ >= 128);
33
978k
  if (n)
34
978k
    *n = (unsigned)(p - orig_p);
35
978k
  return Value;
36
978k
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.89M
{
26
3.89M
  const uint8_t *orig_p = p;
27
3.89M
  uint64_t Value = 0;
28
3.89M
  unsigned Shift = 0;
29
4.07M
  do {
30
4.07M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.07M
    Shift += 7;
32
4.07M
  } while (*p++ >= 128);
33
3.89M
  if (n)
34
3.89M
    *n = (unsigned)(p - orig_p);
35
3.89M
  return Value;
36
3.89M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H