/src/perfetto/buildtools/android-unwinding/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 | 1.46k | RegsInfo(RegsImpl<AddressType>* regs) : regs(regs) {} Unexecuted instantiation: unwindstack::RegsInfo<unsigned int>::RegsInfo(unwindstack::RegsImpl<unsigned int>*) unwindstack::RegsInfo<unsigned long>::RegsInfo(unwindstack::RegsImpl<unsigned long>*) Line | Count | Source | 29 | 1.46k | RegsInfo(RegsImpl<AddressType>* regs) : regs(regs) {} |
|
30 | | |
31 | | RegsImpl<AddressType>* regs = nullptr; |
32 | | uint64_t saved_reg_map = 0; |
33 | | AddressType saved_regs[MAX_REGISTERS]; |
34 | | |
35 | 10.0k | inline AddressType Get(uint32_t reg) { |
36 | 10.0k | if (IsSaved(reg)) { |
37 | 9 | return saved_regs[reg]; |
38 | 9 | } |
39 | 10.0k | return (*regs)[reg]; |
40 | 10.0k | } Unexecuted instantiation: unwindstack::RegsInfo<unsigned int>::Get(unsigned int) unwindstack::RegsInfo<unsigned long>::Get(unsigned int) Line | Count | Source | 35 | 10.0k | inline AddressType Get(uint32_t reg) { | 36 | 10.0k | if (IsSaved(reg)) { | 37 | 9 | return saved_regs[reg]; | 38 | 9 | } | 39 | 10.0k | return (*regs)[reg]; | 40 | 10.0k | } |
|
41 | | |
42 | 919 | inline AddressType* Save(uint32_t reg) { |
43 | 919 | 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 | 919 | saved_reg_map |= 1ULL << reg; |
49 | 919 | saved_regs[reg] = (*regs)[reg]; |
50 | 919 | return &(*regs)[reg]; |
51 | 919 | } Unexecuted instantiation: unwindstack::RegsInfo<unsigned int>::Save(unsigned int) unwindstack::RegsInfo<unsigned long>::Save(unsigned int) Line | Count | Source | 42 | 919 | inline AddressType* Save(uint32_t reg) { | 43 | 919 | 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 | 919 | saved_reg_map |= 1ULL << reg; | 49 | 919 | saved_regs[reg] = (*regs)[reg]; | 50 | 919 | return &(*regs)[reg]; | 51 | 919 | } |
|
52 | | |
53 | 10.0k | inline bool IsSaved(uint32_t reg) { |
54 | 10.0k | 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 | 10.0k | return saved_reg_map & (1ULL << reg); |
60 | 10.0k | } Unexecuted instantiation: unwindstack::RegsInfo<unsigned int>::IsSaved(unsigned int) unwindstack::RegsInfo<unsigned long>::IsSaved(unsigned int) Line | Count | Source | 53 | 10.0k | inline bool IsSaved(uint32_t reg) { | 54 | 10.0k | 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 | 10.0k | return saved_reg_map & (1ULL << reg); | 60 | 10.0k | } |
|
61 | | |
62 | 10.0k | inline uint16_t Total() { return regs->total_regs(); } Unexecuted instantiation: unwindstack::RegsInfo<unsigned int>::Total() unwindstack::RegsInfo<unsigned long>::Total() Line | Count | Source | 62 | 10.0k | inline uint16_t Total() { return regs->total_regs(); } |
|
63 | | }; |
64 | | |
65 | | } // namespace unwindstack |