Coverage Report

Created: 2026-12-01 07:03

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
113M
{
26
113M
  const uint8_t *orig_p = p;
27
113M
  uint64_t Value = 0;
28
113M
  unsigned Shift = 0;
29
128M
  do {
30
128M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
128M
    Shift += 7;
32
128M
  } while (*p++ >= 128);
33
113M
  if (n)
34
113M
    *n = (unsigned)(p - orig_p);
35
113M
  return Value;
36
113M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
43.6M
{
26
43.6M
  const uint8_t *orig_p = p;
27
43.6M
  uint64_t Value = 0;
28
43.6M
  unsigned Shift = 0;
29
47.9M
  do {
30
47.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
47.9M
    Shift += 7;
32
47.9M
  } while (*p++ >= 128);
33
43.6M
  if (n)
34
43.6M
    *n = (unsigned)(p - orig_p);
35
43.6M
  return Value;
36
43.6M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
17.8M
{
26
17.8M
  const uint8_t *orig_p = p;
27
17.8M
  uint64_t Value = 0;
28
17.8M
  unsigned Shift = 0;
29
19.6M
  do {
30
19.6M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
19.6M
    Shift += 7;
32
19.6M
  } while (*p++ >= 128);
33
17.8M
  if (n)
34
17.8M
    *n = (unsigned)(p - orig_p);
35
17.8M
  return Value;
36
17.8M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
9.48M
{
26
9.48M
  const uint8_t *orig_p = p;
27
9.48M
  uint64_t Value = 0;
28
9.48M
  unsigned Shift = 0;
29
9.89M
  do {
30
9.89M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
9.89M
    Shift += 7;
32
9.89M
  } while (*p++ >= 128);
33
9.48M
  if (n)
34
9.48M
    *n = (unsigned)(p - orig_p);
35
9.48M
  return Value;
36
9.48M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
10.5M
{
26
10.5M
  const uint8_t *orig_p = p;
27
10.5M
  uint64_t Value = 0;
28
10.5M
  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.5M
  if (n)
34
10.5M
    *n = (unsigned)(p - orig_p);
35
10.5M
  return Value;
36
10.5M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.93M
{
26
3.93M
  const uint8_t *orig_p = p;
27
3.93M
  uint64_t Value = 0;
28
3.93M
  unsigned Shift = 0;
29
4.04M
  do {
30
4.04M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.04M
    Shift += 7;
32
4.04M
  } while (*p++ >= 128);
33
3.93M
  if (n)
34
3.93M
    *n = (unsigned)(p - orig_p);
35
3.93M
  return Value;
36
3.93M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
18.4M
{
26
18.4M
  const uint8_t *orig_p = p;
27
18.4M
  uint64_t Value = 0;
28
18.4M
  unsigned Shift = 0;
29
26.0M
  do {
30
26.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
26.0M
    Shift += 7;
32
26.0M
  } while (*p++ >= 128);
33
18.4M
  if (n)
34
18.4M
    *n = (unsigned)(p - orig_p);
35
18.4M
  return Value;
36
18.4M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.41M
{
26
1.41M
  const uint8_t *orig_p = p;
27
1.41M
  uint64_t Value = 0;
28
1.41M
  unsigned Shift = 0;
29
1.53M
  do {
30
1.53M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.53M
    Shift += 7;
32
1.53M
  } while (*p++ >= 128);
33
1.41M
  if (n)
34
1.41M
    *n = (unsigned)(p - orig_p);
35
1.41M
  return Value;
36
1.41M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.50M
{
26
1.50M
  const uint8_t *orig_p = p;
27
1.50M
  uint64_t Value = 0;
28
1.50M
  unsigned Shift = 0;
29
1.53M
  do {
30
1.53M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.53M
    Shift += 7;
32
1.53M
  } while (*p++ >= 128);
33
1.50M
  if (n)
34
1.50M
    *n = (unsigned)(p - orig_p);
35
1.50M
  return Value;
36
1.50M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
6.53M
{
26
6.53M
  const uint8_t *orig_p = p;
27
6.53M
  uint64_t Value = 0;
28
6.53M
  unsigned Shift = 0;
29
6.76M
  do {
30
6.76M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.76M
    Shift += 7;
32
6.76M
  } while (*p++ >= 128);
33
6.53M
  if (n)
34
6.53M
    *n = (unsigned)(p - orig_p);
35
6.53M
  return Value;
36
6.53M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H