Coverage Report

Created: 2026-03-13 06:50

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
87.0M
{
26
87.0M
  const uint8_t *orig_p = p;
27
87.0M
  uint64_t Value = 0;
28
87.0M
  unsigned Shift = 0;
29
97.8M
  do {
30
97.8M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
97.8M
    Shift += 7;
32
97.8M
  } while (*p++ >= 128);
33
87.0M
  if (n)
34
87.0M
    *n = (unsigned)(p - orig_p);
35
87.0M
  return Value;
36
87.0M
}
ARMDisassembler.c:decodeULEB128
Line
Count
Source
25
39.9M
{
26
39.9M
  const uint8_t *orig_p = p;
27
39.9M
  uint64_t Value = 0;
28
39.9M
  unsigned Shift = 0;
29
44.2M
  do {
30
44.2M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
44.2M
    Shift += 7;
32
44.2M
  } while (*p++ >= 128);
33
39.9M
  if (n)
34
39.9M
    *n = (unsigned)(p - orig_p);
35
39.9M
  return Value;
36
39.9M
}
AArch64Disassembler.c:decodeULEB128
Line
Count
Source
25
11.2M
{
26
11.2M
  const uint8_t *orig_p = p;
27
11.2M
  uint64_t Value = 0;
28
11.2M
  unsigned Shift = 0;
29
12.3M
  do {
30
12.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
12.3M
    Shift += 7;
32
12.3M
  } while (*p++ >= 128);
33
11.2M
  if (n)
34
11.2M
    *n = (unsigned)(p - orig_p);
35
11.2M
  return Value;
36
11.2M
}
MipsDisassembler.c:decodeULEB128
Line
Count
Source
25
7.15M
{
26
7.15M
  const uint8_t *orig_p = p;
27
7.15M
  uint64_t Value = 0;
28
7.15M
  unsigned Shift = 0;
29
7.45M
  do {
30
7.45M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.45M
    Shift += 7;
32
7.45M
  } while (*p++ >= 128);
33
7.15M
  if (n)
34
7.15M
    *n = (unsigned)(p - orig_p);
35
7.15M
  return Value;
36
7.15M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
7.34M
{
26
7.34M
  const uint8_t *orig_p = p;
27
7.34M
  uint64_t Value = 0;
28
7.34M
  unsigned Shift = 0;
29
7.64M
  do {
30
7.64M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
7.64M
    Shift += 7;
32
7.64M
  } while (*p++ >= 128);
33
7.34M
  if (n)
34
7.34M
    *n = (unsigned)(p - orig_p);
35
7.34M
  return Value;
36
7.34M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
2.98M
{
26
2.98M
  const uint8_t *orig_p = p;
27
2.98M
  uint64_t Value = 0;
28
2.98M
  unsigned Shift = 0;
29
3.06M
  do {
30
3.06M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.06M
    Shift += 7;
32
3.06M
  } while (*p++ >= 128);
33
2.98M
  if (n)
34
2.98M
    *n = (unsigned)(p - orig_p);
35
2.98M
  return Value;
36
2.98M
}
SystemZDisassembler.c:decodeULEB128
Line
Count
Source
25
11.0M
{
26
11.0M
  const uint8_t *orig_p = p;
27
11.0M
  uint64_t Value = 0;
28
11.0M
  unsigned Shift = 0;
29
15.3M
  do {
30
15.3M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
15.3M
    Shift += 7;
32
15.3M
  } while (*p++ >= 128);
33
11.0M
  if (n)
34
11.0M
    *n = (unsigned)(p - orig_p);
35
11.0M
  return Value;
36
11.0M
}
XCoreDisassembler.c:decodeULEB128
Line
Count
Source
25
1.51M
{
26
1.51M
  const uint8_t *orig_p = p;
27
1.51M
  uint64_t Value = 0;
28
1.51M
  unsigned Shift = 0;
29
1.67M
  do {
30
1.67M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.67M
    Shift += 7;
32
1.67M
  } while (*p++ >= 128);
33
1.51M
  if (n)
34
1.51M
    *n = (unsigned)(p - orig_p);
35
1.51M
  return Value;
36
1.51M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.80M
{
26
1.80M
  const uint8_t *orig_p = p;
27
1.80M
  uint64_t Value = 0;
28
1.80M
  unsigned Shift = 0;
29
1.84M
  do {
30
1.84M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.84M
    Shift += 7;
32
1.84M
  } while (*p++ >= 128);
33
1.80M
  if (n)
34
1.80M
    *n = (unsigned)(p - orig_p);
35
1.80M
  return Value;
36
1.80M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
3.98M
{
26
3.98M
  const uint8_t *orig_p = p;
27
3.98M
  uint64_t Value = 0;
28
3.98M
  unsigned Shift = 0;
29
4.15M
  do {
30
4.15M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
4.15M
    Shift += 7;
32
4.15M
  } while (*p++ >= 128);
33
3.98M
  if (n)
34
3.98M
    *n = (unsigned)(p - orig_p);
35
3.98M
  return Value;
36
3.98M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H