Coverage Report

Created: 2022-08-24 06:35

/src/orbit/third_party/libunwindstack/RegsInfo.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (C) 2018 The Android Open Source Project
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
17
#pragma once
18
19
#include <stdint.h>
20
21
#include <unwindstack/Regs.h>
22
23
namespace unwindstack {
24
25
template <typename AddressType>
26
struct RegsInfo {
27
  static constexpr size_t MAX_REGISTERS = 64;
28
29
0
  RegsInfo(RegsImpl<AddressType>* regs) : regs(regs) {}
Unexecuted instantiation: unwindstack::RegsInfo<unsigned int>::RegsInfo(unwindstack::RegsImpl<unsigned int>*)
Unexecuted instantiation: unwindstack::RegsInfo<unsigned long>::RegsInfo(unwindstack::RegsImpl<unsigned long>*)
30
31
  RegsImpl<AddressType>* regs = nullptr;
32
  uint64_t saved_reg_map = 0;
33
  AddressType saved_regs[MAX_REGISTERS];
34
35
0
  inline AddressType Get(uint32_t reg) {
36
0
    if (IsSaved(reg)) {
37
0
      return saved_regs[reg];
38
0
    }
39
0
    return (*regs)[reg];
40
0
  }
Unexecuted instantiation: unwindstack::RegsInfo<unsigned int>::Get(unsigned int)
Unexecuted instantiation: unwindstack::RegsInfo<unsigned long>::Get(unsigned int)
41
42
0
  inline AddressType* Save(uint32_t reg) {
43
0
    if (reg >= MAX_REGISTERS) {
44
      // This should never happen since all currently supported
45
      // architectures have < 64 total registers.
46
0
      abort();
47
0
    }
48
0
    saved_reg_map |= 1ULL << reg;
49
0
    saved_regs[reg] = (*regs)[reg];
50
0
    return &(*regs)[reg];
51
0
  }
Unexecuted instantiation: unwindstack::RegsInfo<unsigned int>::Save(unsigned int)
Unexecuted instantiation: unwindstack::RegsInfo<unsigned long>::Save(unsigned int)
52
53
0
  inline bool IsSaved(uint32_t reg) {
54
0
    if (reg > MAX_REGISTERS) {
55
      // This should never happen since all currently supported
56
      // architectures have < 64 total registers.
57
0
      abort();
58
0
    }
59
0
    return saved_reg_map & (1ULL << reg);
60
0
  }
Unexecuted instantiation: unwindstack::RegsInfo<unsigned int>::IsSaved(unsigned int)
Unexecuted instantiation: unwindstack::RegsInfo<unsigned long>::IsSaved(unsigned int)
61
62
0
  inline uint16_t Total() { return regs->total_regs(); }
Unexecuted instantiation: unwindstack::RegsInfo<unsigned int>::Total()
Unexecuted instantiation: unwindstack::RegsInfo<unsigned long>::Total()
63
};
64
65
}  // namespace unwindstack