Coverage Report

Created: 2026-01-12 07:13

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
48.9M
{
26
48.9M
  const uint8_t *orig_p = p;
27
48.9M
  uint64_t Value = 0;
28
48.9M
  unsigned Shift = 0;
29
54.0M
  do {
30
54.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
54.0M
    Shift += 7;
32
54.0M
  } while (*p++ >= 128);
33
48.9M
  if (n)
34
48.9M
    *n = (unsigned)(p - orig_p);
35
48.9M
  return Value;
36
48.9M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
17.2M
{
26
17.2M
  const uint8_t *orig_p = p;
27
17.2M
  uint64_t Value = 0;
28
17.2M
  unsigned Shift = 0;
29
18.9M
  do {
30
18.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
18.9M
    Shift += 7;
32
18.9M
  } while (*p++ >= 128);
33
17.2M
  if (n)
34
17.2M
    *n = (unsigned)(p - orig_p);
35
17.2M
  return Value;
36
17.2M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
7.89M
{
26
7.89M
  const uint8_t *orig_p = p;
27
7.89M
  uint64_t Value = 0;
28
7.89M
  unsigned Shift = 0;
29
8.21M
  do {
30
8.21M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.21M
    Shift += 7;
32
8.21M
  } while (*p++ >= 128);
33
7.89M
  if (n)
34
7.89M
    *n = (unsigned)(p - orig_p);
35
7.89M
  return Value;
36
7.89M
}
PPCDisassembler.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.4M
  do {
30
10.4M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
10.4M
    Shift += 7;
32
10.4M
  } while (*p++ >= 128);
33
10.0M
  if (n)
34
10.0M
    *n = (unsigned)(p - orig_p);
35
10.0M
  return Value;
36
10.0M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.57M
{
26
3.57M
  const uint8_t *orig_p = p;
27
3.57M
  uint64_t Value = 0;
28
3.57M
  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.57M
  if (n)
34
3.57M
    *n = (unsigned)(p - orig_p);
35
3.57M
  return Value;
36
3.57M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
16.4M
{
26
16.4M
  const uint8_t *orig_p = p;
27
16.4M
  uint64_t Value = 0;
28
16.4M
  unsigned Shift = 0;
29
23.0M
  do {
30
23.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
23.0M
    Shift += 7;
32
23.0M
  } while (*p++ >= 128);
33
16.4M
  if (n)
34
16.4M
    *n = (unsigned)(p - orig_p);
35
16.4M
  return Value;
36
16.4M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.58M
{
26
1.58M
  const uint8_t *orig_p = p;
27
1.58M
  uint64_t Value = 0;
28
1.58M
  unsigned Shift = 0;
29
1.73M
  do {
30
1.73M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.73M
    Shift += 7;
32
1.73M
  } while (*p++ >= 128);
33
1.58M
  if (n)
34
1.58M
    *n = (unsigned)(p - orig_p);
35
1.58M
  return Value;
36
1.58M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
2.02M
{
26
2.02M
  const uint8_t *orig_p = p;
27
2.02M
  uint64_t Value = 0;
28
2.02M
  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.02M
  if (n)
34
2.02M
    *n = (unsigned)(p - orig_p);
35
2.02M
  return Value;
36
2.02M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
6.03M
{
26
6.03M
  const uint8_t *orig_p = p;
27
6.03M
  uint64_t Value = 0;
28
6.03M
  unsigned Shift = 0;
29
6.30M
  do {
30
6.30M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.30M
    Shift += 7;
32
6.30M
  } while (*p++ >= 128);
33
6.03M
  if (n)
34
6.03M
    *n = (unsigned)(p - orig_p);
35
6.03M
  return Value;
36
6.03M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H