Coverage Report

Created: 2026-01-09 06:55

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
127M
  do {
30
127M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
127M
    Shift += 7;
32
127M
  } 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
47.8M
{
26
47.8M
  const uint8_t *orig_p = p;
27
47.8M
  uint64_t Value = 0;
28
47.8M
  unsigned Shift = 0;
29
52.7M
  do {
30
52.7M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
52.7M
    Shift += 7;
32
52.7M
  } while (*p++ >= 128);
33
47.8M
  if (n)
34
47.8M
    *n = (unsigned)(p - orig_p);
35
47.8M
  return Value;
36
47.8M
}
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
8.00M
{
26
8.00M
  const uint8_t *orig_p = p;
27
8.00M
  uint64_t Value = 0;
28
8.00M
  unsigned Shift = 0;
29
8.33M
  do {
30
8.33M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
8.33M
    Shift += 7;
32
8.33M
  } while (*p++ >= 128);
33
8.00M
  if (n)
34
8.00M
    *n = (unsigned)(p - orig_p);
35
8.00M
  return Value;
36
8.00M
}
PPCDisassembler.c:decodeULEB128
Line
Count
Source
25
10.6M
{
26
10.6M
  const uint8_t *orig_p = p;
27
10.6M
  uint64_t Value = 0;
28
10.6M
  unsigned Shift = 0;
29
11.0M
  do {
30
11.0M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
11.0M
    Shift += 7;
32
11.0M
  } while (*p++ >= 128);
33
10.6M
  if (n)
34
10.6M
    *n = (unsigned)(p - orig_p);
35
10.6M
  return Value;
36
10.6M
}
SparcDisassembler.c:decodeULEB128
Line
Count
Source
25
3.75M
{
26
3.75M
  const uint8_t *orig_p = p;
27
3.75M
  uint64_t Value = 0;
28
3.75M
  unsigned Shift = 0;
29
3.85M
  do {
30
3.85M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
3.85M
    Shift += 7;
32
3.85M
  } while (*p++ >= 128);
33
3.75M
  if (n)
34
3.75M
    *n = (unsigned)(p - orig_p);
35
3.75M
  return Value;
36
3.75M
}
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
22.9M
  do {
30
22.9M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
22.9M
    Shift += 7;
32
22.9M
  } 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.61M
{
26
1.61M
  const uint8_t *orig_p = p;
27
1.61M
  uint64_t Value = 0;
28
1.61M
  unsigned Shift = 0;
29
1.77M
  do {
30
1.77M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
1.77M
    Shift += 7;
32
1.77M
  } while (*p++ >= 128);
33
1.61M
  if (n)
34
1.61M
    *n = (unsigned)(p - orig_p);
35
1.61M
  return Value;
36
1.61M
}
TMS320C64xDisassembler.c:decodeULEB128
Line
Count
Source
25
1.99M
{
26
1.99M
  const uint8_t *orig_p = p;
27
1.99M
  uint64_t Value = 0;
28
1.99M
  unsigned Shift = 0;
29
2.04M
  do {
30
2.04M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
2.04M
    Shift += 7;
32
2.04M
  } while (*p++ >= 128);
33
1.99M
  if (n)
34
1.99M
    *n = (unsigned)(p - orig_p);
35
1.99M
  return Value;
36
1.99M
}
RISCVDisassembler.c:decodeULEB128
Line
Count
Source
25
5.93M
{
26
5.93M
  const uint8_t *orig_p = p;
27
5.93M
  uint64_t Value = 0;
28
5.93M
  unsigned Shift = 0;
29
6.20M
  do {
30
6.20M
    Value += (uint64_t)(*p & 0x7f) << Shift;
31
6.20M
    Shift += 7;
32
6.20M
  } while (*p++ >= 128);
33
5.93M
  if (n)
34
5.93M
    *n = (unsigned)(p - orig_p);
35
5.93M
  return Value;
36
5.93M
}
Unexecuted instantiation: TriCoreDisassembler.c:decodeULEB128
37
38
#endif  // LLVM_SYSTEM_LEB128_H