1 | //===-- RegisterContextPOSIX_arm64.cpp ------------------------------------===// |
---|---|
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include <cerrno> |
10 | #include <cstdint> |
11 | #include <cstring> |
12 | |
13 | #include "lldb/Target/Process.h" |
14 | #include "lldb/Target/Target.h" |
15 | #include "lldb/Target/Thread.h" |
16 | #include "lldb/Utility/DataBufferHeap.h" |
17 | #include "lldb/Utility/DataExtractor.h" |
18 | #include "lldb/Utility/Endian.h" |
19 | #include "lldb/Utility/RegisterValue.h" |
20 | #include "lldb/Utility/Scalar.h" |
21 | #include "llvm/Support/Compiler.h" |
22 | |
23 | #include "RegisterContextPOSIX_arm64.h" |
24 | |
25 | using namespace lldb; |
26 | using namespace lldb_private; |
27 | |
28 | bool RegisterContextPOSIX_arm64::IsGPR(unsigned reg) { |
29 | if (m_register_info_up->GetRegisterSetFromRegisterIndex(reg_index: reg) == |
30 | RegisterInfoPOSIX_arm64::GPRegSet) |
31 | return true; |
32 | return false; |
33 | } |
34 | |
35 | bool RegisterContextPOSIX_arm64::IsFPR(unsigned reg) { |
36 | if (m_register_info_up->GetRegisterSetFromRegisterIndex(reg_index: reg) == |
37 | RegisterInfoPOSIX_arm64::FPRegSet) |
38 | return true; |
39 | return false; |
40 | } |
41 | |
42 | bool RegisterContextPOSIX_arm64::IsSVE(unsigned reg) const { |
43 | return m_register_info_up->IsSVEReg(reg); |
44 | } |
45 | |
46 | bool RegisterContextPOSIX_arm64::IsSME(unsigned reg) const { |
47 | return m_register_info_up->IsSMEReg(reg); |
48 | } |
49 | |
50 | bool RegisterContextPOSIX_arm64::IsPAuth(unsigned reg) const { |
51 | return m_register_info_up->IsPAuthReg(reg); |
52 | } |
53 | |
54 | bool RegisterContextPOSIX_arm64::IsTLS(unsigned reg) const { |
55 | return m_register_info_up->IsTLSReg(reg); |
56 | } |
57 | |
58 | bool RegisterContextPOSIX_arm64::IsMTE(unsigned reg) const { |
59 | return m_register_info_up->IsMTEReg(reg); |
60 | } |
61 | |
62 | RegisterContextPOSIX_arm64::RegisterContextPOSIX_arm64( |
63 | lldb_private::Thread &thread, |
64 | std::unique_ptr<RegisterInfoPOSIX_arm64> register_info) |
65 | : lldb_private::RegisterContext(thread, 0), |
66 | m_register_info_up(std::move(register_info)) {} |
67 | |
68 | RegisterContextPOSIX_arm64::~RegisterContextPOSIX_arm64() = default; |
69 | |
70 | void RegisterContextPOSIX_arm64::Invalidate() {} |
71 | |
72 | void RegisterContextPOSIX_arm64::InvalidateAllRegisters() {} |
73 | |
74 | unsigned RegisterContextPOSIX_arm64::GetRegisterOffset(unsigned reg) { |
75 | return m_register_info_up->GetRegisterInfo()[reg].byte_offset; |
76 | } |
77 | |
78 | unsigned RegisterContextPOSIX_arm64::GetRegisterSize(unsigned reg) { |
79 | return m_register_info_up->GetRegisterInfo()[reg].byte_size; |
80 | } |
81 | |
82 | size_t RegisterContextPOSIX_arm64::GetRegisterCount() { |
83 | return m_register_info_up->GetRegisterCount(); |
84 | } |
85 | |
86 | size_t RegisterContextPOSIX_arm64::GetGPRSize() { |
87 | return m_register_info_up->GetGPRSize(); |
88 | } |
89 | |
90 | const lldb_private::RegisterInfo * |
91 | RegisterContextPOSIX_arm64::GetRegisterInfo() { |
92 | // Commonly, this method is overridden and g_register_infos is copied and |
93 | // specialized. So, use GetRegisterInfo() rather than g_register_infos in |
94 | // this scope. |
95 | return m_register_info_up->GetRegisterInfo(); |
96 | } |
97 | |
98 | const lldb_private::RegisterInfo * |
99 | RegisterContextPOSIX_arm64::GetRegisterInfoAtIndex(size_t reg) { |
100 | if (reg < GetRegisterCount()) |
101 | return &GetRegisterInfo()[reg]; |
102 | |
103 | return nullptr; |
104 | } |
105 | |
106 | size_t RegisterContextPOSIX_arm64::GetRegisterSetCount() { |
107 | return m_register_info_up->GetRegisterSetCount(); |
108 | } |
109 | |
110 | const lldb_private::RegisterSet * |
111 | RegisterContextPOSIX_arm64::GetRegisterSet(size_t set) { |
112 | return m_register_info_up->GetRegisterSet(reg_set: set); |
113 | } |
114 | |
115 | const char *RegisterContextPOSIX_arm64::GetRegisterName(unsigned reg) { |
116 | if (reg < GetRegisterCount()) |
117 | return GetRegisterInfo()[reg].name; |
118 | return nullptr; |
119 | } |
120 |