10516c503SGreg Clayton //===-- RegisterContextMach_i386.cpp ----------------------------*- C++ -*-===// 20516c503SGreg Clayton // 30516c503SGreg Clayton // The LLVM Compiler Infrastructure 40516c503SGreg Clayton // 50516c503SGreg Clayton // This file is distributed under the University of Illinois Open Source 60516c503SGreg Clayton // License. See LICENSE.TXT for details. 70516c503SGreg Clayton // 80516c503SGreg Clayton //===----------------------------------------------------------------------===// 90516c503SGreg Clayton 10*f044a1e7SJohnny Chen #if defined(__APPLE__) 110516c503SGreg Clayton 120516c503SGreg Clayton // C Includes 130516c503SGreg Clayton #include <mach/thread_act.h> 140516c503SGreg Clayton 150516c503SGreg Clayton // C++ Includes 160516c503SGreg Clayton // Other libraries and framework includes 170516c503SGreg Clayton // Project includes 180516c503SGreg Clayton #include "RegisterContextMach_i386.h" 190516c503SGreg Clayton 200516c503SGreg Clayton using namespace lldb; 210516c503SGreg Clayton using namespace lldb_private; 220516c503SGreg Clayton 230516c503SGreg Clayton 240516c503SGreg Clayton RegisterContextMach_i386::RegisterContextMach_i386(Thread &thread, uint32_t concrete_frame_idx) : 250516c503SGreg Clayton RegisterContextDarwin_i386 (thread, concrete_frame_idx) 260516c503SGreg Clayton { 270516c503SGreg Clayton } 280516c503SGreg Clayton 290516c503SGreg Clayton RegisterContextMach_i386::~RegisterContextMach_i386() 300516c503SGreg Clayton { 310516c503SGreg Clayton } 320516c503SGreg Clayton 330516c503SGreg Clayton int 340516c503SGreg Clayton RegisterContextMach_i386::DoReadGPR (lldb::tid_t tid, int flavor, GPR &gpr) 350516c503SGreg Clayton { 360516c503SGreg Clayton mach_msg_type_number_t count = GPRWordCount; 370516c503SGreg Clayton return ::thread_get_state(tid, flavor, (thread_state_t)&gpr, &count); 380516c503SGreg Clayton } 390516c503SGreg Clayton 400516c503SGreg Clayton int 410516c503SGreg Clayton RegisterContextMach_i386::DoReadFPU (lldb::tid_t tid, int flavor, FPU &fpu) 420516c503SGreg Clayton { 430516c503SGreg Clayton mach_msg_type_number_t count = FPUWordCount; 440516c503SGreg Clayton return ::thread_get_state(tid, flavor, (thread_state_t)&fpu, &count); 450516c503SGreg Clayton } 460516c503SGreg Clayton 470516c503SGreg Clayton int 480516c503SGreg Clayton RegisterContextMach_i386::DoReadEXC (lldb::tid_t tid, int flavor, EXC &exc) 490516c503SGreg Clayton { 500516c503SGreg Clayton mach_msg_type_number_t count = EXCWordCount; 510516c503SGreg Clayton return ::thread_get_state(tid, flavor, (thread_state_t)&exc, &count); 520516c503SGreg Clayton } 530516c503SGreg Clayton 540516c503SGreg Clayton int 550516c503SGreg Clayton RegisterContextMach_i386::DoWriteGPR (lldb::tid_t tid, int flavor, const GPR &gpr) 560516c503SGreg Clayton { 570516c503SGreg Clayton return ::thread_set_state(tid, flavor, (thread_state_t)&gpr, GPRWordCount); 580516c503SGreg Clayton } 590516c503SGreg Clayton 600516c503SGreg Clayton int 610516c503SGreg Clayton RegisterContextMach_i386::DoWriteFPU (lldb::tid_t tid, int flavor, const FPU &fpu) 620516c503SGreg Clayton { 630516c503SGreg Clayton return ::thread_set_state(tid, flavor, (thread_state_t)&fpu, FPUWordCount); 640516c503SGreg Clayton } 650516c503SGreg Clayton 660516c503SGreg Clayton int 670516c503SGreg Clayton RegisterContextMach_i386::DoWriteEXC (lldb::tid_t tid, int flavor, const EXC &exc) 680516c503SGreg Clayton { 690516c503SGreg Clayton return ::thread_set_state(tid, flavor, (thread_state_t)&exc, EXCWordCount); 700516c503SGreg Clayton } 710516c503SGreg Clayton 72*f044a1e7SJohnny Chen #endif 73