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 
10f044a1e7SJohnny 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 
23*b9c1b51eSKate Stone RegisterContextMach_i386::RegisterContextMach_i386(Thread &thread,
24*b9c1b51eSKate Stone                                                    uint32_t concrete_frame_idx)
25*b9c1b51eSKate Stone     : RegisterContextDarwin_i386(thread, concrete_frame_idx) {}
260516c503SGreg Clayton 
27*b9c1b51eSKate Stone RegisterContextMach_i386::~RegisterContextMach_i386() {}
280516c503SGreg Clayton 
29*b9c1b51eSKate Stone int RegisterContextMach_i386::DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr) {
300516c503SGreg Clayton   mach_msg_type_number_t count = GPRWordCount;
310516c503SGreg Clayton   return ::thread_get_state(tid, flavor, (thread_state_t)&gpr, &count);
320516c503SGreg Clayton }
330516c503SGreg Clayton 
34*b9c1b51eSKate Stone int RegisterContextMach_i386::DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu) {
350516c503SGreg Clayton   mach_msg_type_number_t count = FPUWordCount;
360516c503SGreg Clayton   return ::thread_get_state(tid, flavor, (thread_state_t)&fpu, &count);
370516c503SGreg Clayton }
380516c503SGreg Clayton 
39*b9c1b51eSKate Stone int RegisterContextMach_i386::DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc) {
400516c503SGreg Clayton   mach_msg_type_number_t count = EXCWordCount;
410516c503SGreg Clayton   return ::thread_get_state(tid, flavor, (thread_state_t)&exc, &count);
420516c503SGreg Clayton }
430516c503SGreg Clayton 
44*b9c1b51eSKate Stone int RegisterContextMach_i386::DoWriteGPR(lldb::tid_t tid, int flavor,
45*b9c1b51eSKate Stone                                          const GPR &gpr) {
460516c503SGreg Clayton   return ::thread_set_state(tid, flavor, (thread_state_t)&gpr, GPRWordCount);
470516c503SGreg Clayton }
480516c503SGreg Clayton 
49*b9c1b51eSKate Stone int RegisterContextMach_i386::DoWriteFPU(lldb::tid_t tid, int flavor,
50*b9c1b51eSKate Stone                                          const FPU &fpu) {
510516c503SGreg Clayton   return ::thread_set_state(tid, flavor, (thread_state_t)&fpu, FPUWordCount);
520516c503SGreg Clayton }
530516c503SGreg Clayton 
54*b9c1b51eSKate Stone int RegisterContextMach_i386::DoWriteEXC(lldb::tid_t tid, int flavor,
55*b9c1b51eSKate Stone                                          const EXC &exc) {
560516c503SGreg Clayton   return ::thread_set_state(tid, flavor, (thread_state_t)&exc, EXCWordCount);
570516c503SGreg Clayton }
580516c503SGreg Clayton 
59f044a1e7SJohnny Chen #endif
60