64 lines · cpp
1//===-- RegisterContextMach_x86_64.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-exception6//7//===----------------------------------------------------------------------===//8 9#if defined(__APPLE__)10 11#include <mach/thread_act.h>12 13#include "RegisterContextMach_x86_64.h"14 15using namespace lldb;16using namespace lldb_private;17 18RegisterContextMach_x86_64::RegisterContextMach_x86_64(19 Thread &thread, uint32_t concrete_frame_idx)20 : RegisterContextDarwin_x86_64(thread, concrete_frame_idx) {}21 22RegisterContextMach_x86_64::~RegisterContextMach_x86_64() = default;23 24int RegisterContextMach_x86_64::DoReadGPR(lldb::tid_t tid, int flavor,25 GPR &gpr) {26 mach_msg_type_number_t count = GPRWordCount;27 return ::thread_get_state(tid, flavor, (thread_state_t)&gpr, &count);28}29 30int RegisterContextMach_x86_64::DoReadFPU(lldb::tid_t tid, int flavor,31 FPU &fpu) {32 mach_msg_type_number_t count = FPUWordCount;33 return ::thread_get_state(tid, flavor, (thread_state_t)&fpu, &count);34}35 36int RegisterContextMach_x86_64::DoReadEXC(lldb::tid_t tid, int flavor,37 EXC &exc) {38 mach_msg_type_number_t count = EXCWordCount;39 return ::thread_get_state(tid, flavor, (thread_state_t)&exc, &count);40}41 42int RegisterContextMach_x86_64::DoWriteGPR(lldb::tid_t tid, int flavor,43 const GPR &gpr) {44 return ::thread_set_state(45 tid, flavor, reinterpret_cast<thread_state_t>(const_cast<GPR *>(&gpr)),46 GPRWordCount);47}48 49int RegisterContextMach_x86_64::DoWriteFPU(lldb::tid_t tid, int flavor,50 const FPU &fpu) {51 return ::thread_set_state(52 tid, flavor, reinterpret_cast<thread_state_t>(const_cast<FPU *>(&fpu)),53 FPUWordCount);54}55 56int RegisterContextMach_x86_64::DoWriteEXC(lldb::tid_t tid, int flavor,57 const EXC &exc) {58 return ::thread_set_state(59 tid, flavor, reinterpret_cast<thread_state_t>(const_cast<EXC *>(&exc)),60 EXCWordCount);61}62 63#endif64