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
25using namespace lldb;
26using namespace lldb_private;
27
28bool 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
35bool 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
42bool RegisterContextPOSIX_arm64::IsSVE(unsigned reg) const {
43 return m_register_info_up->IsSVEReg(reg);
44}
45
46bool RegisterContextPOSIX_arm64::IsSME(unsigned reg) const {
47 return m_register_info_up->IsSMEReg(reg);
48}
49
50bool RegisterContextPOSIX_arm64::IsPAuth(unsigned reg) const {
51 return m_register_info_up->IsPAuthReg(reg);
52}
53
54bool RegisterContextPOSIX_arm64::IsTLS(unsigned reg) const {
55 return m_register_info_up->IsTLSReg(reg);
56}
57
58bool RegisterContextPOSIX_arm64::IsMTE(unsigned reg) const {
59 return m_register_info_up->IsMTEReg(reg);
60}
61
62RegisterContextPOSIX_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
68RegisterContextPOSIX_arm64::~RegisterContextPOSIX_arm64() = default;
69
70void RegisterContextPOSIX_arm64::Invalidate() {}
71
72void RegisterContextPOSIX_arm64::InvalidateAllRegisters() {}
73
74unsigned RegisterContextPOSIX_arm64::GetRegisterOffset(unsigned reg) {
75 return m_register_info_up->GetRegisterInfo()[reg].byte_offset;
76}
77
78unsigned RegisterContextPOSIX_arm64::GetRegisterSize(unsigned reg) {
79 return m_register_info_up->GetRegisterInfo()[reg].byte_size;
80}
81
82size_t RegisterContextPOSIX_arm64::GetRegisterCount() {
83 return m_register_info_up->GetRegisterCount();
84}
85
86size_t RegisterContextPOSIX_arm64::GetGPRSize() {
87 return m_register_info_up->GetGPRSize();
88}
89
90const lldb_private::RegisterInfo *
91RegisterContextPOSIX_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
98const lldb_private::RegisterInfo *
99RegisterContextPOSIX_arm64::GetRegisterInfoAtIndex(size_t reg) {
100 if (reg < GetRegisterCount())
101 return &GetRegisterInfo()[reg];
102
103 return nullptr;
104}
105
106size_t RegisterContextPOSIX_arm64::GetRegisterSetCount() {
107 return m_register_info_up->GetRegisterSetCount();
108}
109
110const lldb_private::RegisterSet *
111RegisterContextPOSIX_arm64::GetRegisterSet(size_t set) {
112 return m_register_info_up->GetRegisterSet(reg_set: set);
113}
114
115const char *RegisterContextPOSIX_arm64::GetRegisterName(unsigned reg) {
116 if (reg < GetRegisterCount())
117 return GetRegisterInfo()[reg].name;
118 return nullptr;
119}
120

source code of lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp