10516c503SGreg Clayton //===-- RegisterContextMach_i386.cpp ----------------------------*- C++ -*-===// 20516c503SGreg Clayton // 3*2946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*2946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 5*2946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60516c503SGreg Clayton // 70516c503SGreg Clayton //===----------------------------------------------------------------------===// 80516c503SGreg Clayton 9f044a1e7SJohnny Chen #if defined(__APPLE__) 100516c503SGreg Clayton 110516c503SGreg Clayton #include <mach/thread_act.h> 120516c503SGreg Clayton 130516c503SGreg Clayton #include "RegisterContextMach_i386.h" 140516c503SGreg Clayton 150516c503SGreg Clayton using namespace lldb; 160516c503SGreg Clayton using namespace lldb_private; 170516c503SGreg Clayton 18b9c1b51eSKate Stone RegisterContextMach_i386::RegisterContextMach_i386(Thread &thread, 19b9c1b51eSKate Stone uint32_t concrete_frame_idx) 20b9c1b51eSKate Stone : RegisterContextDarwin_i386(thread, concrete_frame_idx) {} 210516c503SGreg Clayton 22b9c1b51eSKate Stone RegisterContextMach_i386::~RegisterContextMach_i386() {} 230516c503SGreg Clayton 24b9c1b51eSKate Stone int RegisterContextMach_i386::DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr) { 250516c503SGreg Clayton mach_msg_type_number_t count = GPRWordCount; 260516c503SGreg Clayton return ::thread_get_state(tid, flavor, (thread_state_t)&gpr, &count); 270516c503SGreg Clayton } 280516c503SGreg Clayton 29b9c1b51eSKate Stone int RegisterContextMach_i386::DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu) { 300516c503SGreg Clayton mach_msg_type_number_t count = FPUWordCount; 310516c503SGreg Clayton return ::thread_get_state(tid, flavor, (thread_state_t)&fpu, &count); 320516c503SGreg Clayton } 330516c503SGreg Clayton 34b9c1b51eSKate Stone int RegisterContextMach_i386::DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc) { 350516c503SGreg Clayton mach_msg_type_number_t count = EXCWordCount; 360516c503SGreg Clayton return ::thread_get_state(tid, flavor, (thread_state_t)&exc, &count); 370516c503SGreg Clayton } 380516c503SGreg Clayton 39b9c1b51eSKate Stone int RegisterContextMach_i386::DoWriteGPR(lldb::tid_t tid, int flavor, 40b9c1b51eSKate Stone const GPR &gpr) { 4194d788faSVedant Kumar return ::thread_set_state( 4294d788faSVedant Kumar tid, flavor, reinterpret_cast<thread_state_t>(const_cast<GPR *>(&gpr)), 4394d788faSVedant Kumar GPRWordCount); 440516c503SGreg Clayton } 450516c503SGreg Clayton 46b9c1b51eSKate Stone int RegisterContextMach_i386::DoWriteFPU(lldb::tid_t tid, int flavor, 47b9c1b51eSKate Stone const FPU &fpu) { 4894d788faSVedant Kumar return ::thread_set_state( 4994d788faSVedant Kumar tid, flavor, reinterpret_cast<thread_state_t>(const_cast<FPU *>(&fpu)), 5094d788faSVedant Kumar FPUWordCount); 510516c503SGreg Clayton } 520516c503SGreg Clayton 53b9c1b51eSKate Stone int RegisterContextMach_i386::DoWriteEXC(lldb::tid_t tid, int flavor, 54b9c1b51eSKate Stone const EXC &exc) { 5594d788faSVedant Kumar return ::thread_set_state( 5694d788faSVedant Kumar tid, flavor, reinterpret_cast<thread_state_t>(const_cast<EXC *>(&exc)), 5794d788faSVedant Kumar EXCWordCount); 580516c503SGreg Clayton } 590516c503SGreg Clayton 60f044a1e7SJohnny Chen #endif 61