9 #if defined(__aarch64__) || defined(_M_ARM64)
22 #include "llvm/ADT/STLExtras.h"
27 #define REG_CONTEXT_SIZE sizeof(::CONTEXT)
51 "g_gpr_regnums_arm64 has wrong number of register infos");
53 static const uint32_t g_fpr_regnums_arm64[] = {
82 static_assert(((
sizeof g_fpr_regnums_arm64 /
sizeof g_fpr_regnums_arm64[0]) -
84 "g_fpu_regnums_arm64 has wrong number of register infos");
87 {
"General Purpose Registers",
"gpr",
89 {
"Floating Point Registers",
"fpr",
90 llvm::array_lengthof(g_fpr_regnums_arm64) - 1, g_fpr_regnums_arm64},
98 CreateRegisterInfoInterface(
const ArchSpec &target_arch) {
99 assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) &&
100 "Register setting path assumes this is a 64-bit host");
106 PCONTEXT context_ptr,
107 const DWORD control_flag) {
108 Log *log =
GetLog(WindowsLog::Registers);
111 memset(context_ptr, 0,
sizeof(::CONTEXT));
112 context_ptr->ContextFlags = control_flag;
113 if (!::GetThreadContext(thread_handle, context_ptr)) {
115 LLDB_LOG(log,
"{0} GetThreadContext failed with error {1}", __FUNCTION__,
123 PCONTEXT context_ptr) {
124 Log *log =
GetLog(WindowsLog::Registers);
127 if (!::SetThreadContext(thread_handle, context_ptr)) {
129 LLDB_LOG(log,
"{0} SetThreadContext failed with error {1}", __FUNCTION__,
136 std::unique_ptr<NativeRegisterContextWindows>
137 NativeRegisterContextWindows::CreateHostNativeRegisterContextWindows(
140 return std::make_unique<NativeRegisterContextWindows_arm64>(target_arch,
144 NativeRegisterContextWindows_arm64::NativeRegisterContextWindows_arm64(
147 CreateRegisterInfoInterface(target_arch)) {}
149 bool NativeRegisterContextWindows_arm64::IsGPR(
uint32_t reg_index)
const {
153 bool NativeRegisterContextWindows_arm64::IsFPR(
uint32_t reg_index)
const {
157 uint32_t NativeRegisterContextWindows_arm64::GetRegisterSetCount()
const {
162 NativeRegisterContextWindows_arm64::GetRegisterSet(
uint32_t set_index)
const {
168 Status NativeRegisterContextWindows_arm64::GPRRead(
const uint32_t reg,
170 ::CONTEXT tls_context;
171 DWORD context_flag = CONTEXT_CONTROL | CONTEXT_INTEGER;
173 GetThreadContextHelper(GetThreadHandle(), &tls_context, context_flag);
264 NativeRegisterContextWindows_arm64::GPRWrite(
const uint32_t reg,
266 ::CONTEXT tls_context;
267 DWORD context_flag = CONTEXT_CONTROL | CONTEXT_INTEGER;
268 auto thread_handle = GetThreadHandle();
270 GetThreadContextHelper(thread_handle, &tls_context, context_flag);
356 return SetThreadContextHelper(thread_handle, &tls_context);
359 Status NativeRegisterContextWindows_arm64::FPRRead(
const uint32_t reg,
361 ::CONTEXT tls_context;
362 DWORD context_flag = CONTEXT_CONTROL | CONTEXT_FLOATING_POINT;
364 GetThreadContextHelper(GetThreadHandle(), &tls_context, context_flag);
488 NativeRegisterContextWindows_arm64::FPRWrite(
const uint32_t reg,
490 ::CONTEXT tls_context;
491 DWORD context_flag = CONTEXT_CONTROL | CONTEXT_FLOATING_POINT;
492 auto thread_handle = GetThreadHandle();
494 GetThreadContextHelper(thread_handle, &tls_context, context_flag);
613 return SetThreadContextHelper(thread_handle, &tls_context);
617 NativeRegisterContextWindows_arm64::ReadRegister(
const RegisterInfo *reg_info,
621 error.SetErrorString(
"reg_info NULL");
629 error.SetErrorStringWithFormat(
"register \"%s\" is an internal-only lldb "
630 "register, cannot read directly",
636 return GPRRead(reg, reg_value);
639 return FPRRead(reg, reg_value);
641 return Status(
"unimplemented");
644 Status NativeRegisterContextWindows_arm64::WriteRegister(
645 const RegisterInfo *reg_info,
const RegisterValue ®_value) {
649 error.SetErrorString(
"reg_info NULL");
657 error.SetErrorStringWithFormat(
"register \"%s\" is an internal-only lldb "
658 "register, cannot write directly",
664 return GPRWrite(reg, reg_value);
667 return FPRWrite(reg, reg_value);
669 return Status(
"unimplemented");
672 Status NativeRegisterContextWindows_arm64::ReadAllRegisterValues(
673 lldb::WritableDataBufferSP &data_sp) {
675 data_sp = std::make_shared<DataBufferHeap>(data_size, 0);
676 ::CONTEXT tls_context;
678 GetThreadContextHelper(GetThreadHandle(), &tls_context, CONTEXT_ALL);
682 uint8_t *dst = data_sp->GetBytes();
683 ::memcpy(dst, &tls_context, data_size);
687 Status NativeRegisterContextWindows_arm64::WriteAllRegisterValues(
688 const lldb::DataBufferSP &data_sp) {
692 error.SetErrorStringWithFormat(
693 "NativeRegisterContextWindows_arm64::%s invalid data_sp provided",
698 if (data_sp->GetByteSize() != data_size) {
699 error.SetErrorStringWithFormatv(
700 "data_sp contained mismatched data size, expected {0}, actual {1}",
701 data_size, data_sp->GetByteSize());
705 ::CONTEXT tls_context;
706 memcpy(&tls_context, data_sp->GetBytes(), data_size);
707 return SetThreadContextHelper(GetThreadHandle(), &tls_context);
710 Status NativeRegisterContextWindows_arm64::IsWatchpointHit(
uint32_t wp_index,
712 return Status(
"unimplemented");
715 Status NativeRegisterContextWindows_arm64::GetWatchpointHitIndex(
717 return Status(
"unimplemented");
720 Status NativeRegisterContextWindows_arm64::IsWatchpointVacant(
uint32_t wp_index,
722 return Status(
"unimplemented");
725 Status NativeRegisterContextWindows_arm64::SetHardwareWatchpointWithIndex(
727 return Status(
"unimplemented");
730 bool NativeRegisterContextWindows_arm64::ClearHardwareWatchpoint(
735 Status NativeRegisterContextWindows_arm64::ClearAllHardwareWatchpoints() {
736 return Status(
"unimplemented");
739 uint32_t NativeRegisterContextWindows_arm64::SetHardwareWatchpoint(
745 NativeRegisterContextWindows_arm64::GetWatchpointAddress(
uint32_t wp_index) {
749 uint32_t NativeRegisterContextWindows_arm64::NumSupportedHardwareWatchpoints() {
754 #endif // defined(__aarch64__) || defined(_M_ARM64)