1ac7ddfbfSEd Maste //===-- RegisterContextMach_i386.cpp ----------------------------*- C++ -*-===//
2ac7ddfbfSEd Maste //
3ac7ddfbfSEd Maste // The LLVM Compiler Infrastructure
4ac7ddfbfSEd Maste //
5ac7ddfbfSEd Maste // This file is distributed under the University of Illinois Open Source
6ac7ddfbfSEd Maste // License. See LICENSE.TXT for details.
7ac7ddfbfSEd Maste //
8ac7ddfbfSEd Maste //===----------------------------------------------------------------------===//
9ac7ddfbfSEd Maste
10ac7ddfbfSEd Maste #if defined(__APPLE__)
11ac7ddfbfSEd Maste
12ac7ddfbfSEd Maste #include <mach/thread_act.h>
13ac7ddfbfSEd Maste
14ac7ddfbfSEd Maste #include "RegisterContextMach_i386.h"
15ac7ddfbfSEd Maste
16ac7ddfbfSEd Maste using namespace lldb;
17ac7ddfbfSEd Maste using namespace lldb_private;
18ac7ddfbfSEd Maste
RegisterContextMach_i386(Thread & thread,uint32_t concrete_frame_idx)19435933ddSDimitry Andric RegisterContextMach_i386::RegisterContextMach_i386(Thread &thread,
20435933ddSDimitry Andric uint32_t concrete_frame_idx)
21435933ddSDimitry Andric : RegisterContextDarwin_i386(thread, concrete_frame_idx) {}
22ac7ddfbfSEd Maste
~RegisterContextMach_i386()23435933ddSDimitry Andric RegisterContextMach_i386::~RegisterContextMach_i386() {}
24ac7ddfbfSEd Maste
DoReadGPR(lldb::tid_t tid,int flavor,GPR & gpr)25435933ddSDimitry Andric int RegisterContextMach_i386::DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr) {
26ac7ddfbfSEd Maste mach_msg_type_number_t count = GPRWordCount;
27ac7ddfbfSEd Maste return ::thread_get_state(tid, flavor, (thread_state_t)&gpr, &count);
28ac7ddfbfSEd Maste }
29ac7ddfbfSEd Maste
DoReadFPU(lldb::tid_t tid,int flavor,FPU & fpu)30435933ddSDimitry Andric int RegisterContextMach_i386::DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu) {
31ac7ddfbfSEd Maste mach_msg_type_number_t count = FPUWordCount;
32ac7ddfbfSEd Maste return ::thread_get_state(tid, flavor, (thread_state_t)&fpu, &count);
33ac7ddfbfSEd Maste }
34ac7ddfbfSEd Maste
DoReadEXC(lldb::tid_t tid,int flavor,EXC & exc)35435933ddSDimitry Andric int RegisterContextMach_i386::DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc) {
36ac7ddfbfSEd Maste mach_msg_type_number_t count = EXCWordCount;
37ac7ddfbfSEd Maste return ::thread_get_state(tid, flavor, (thread_state_t)&exc, &count);
38ac7ddfbfSEd Maste }
39ac7ddfbfSEd Maste
DoWriteGPR(lldb::tid_t tid,int flavor,const GPR & gpr)40435933ddSDimitry Andric int RegisterContextMach_i386::DoWriteGPR(lldb::tid_t tid, int flavor,
41435933ddSDimitry Andric const GPR &gpr) {
42acac075bSDimitry Andric return ::thread_set_state(
43acac075bSDimitry Andric tid, flavor, reinterpret_cast<thread_state_t>(const_cast<GPR *>(&gpr)),
44acac075bSDimitry Andric GPRWordCount);
45ac7ddfbfSEd Maste }
46ac7ddfbfSEd Maste
DoWriteFPU(lldb::tid_t tid,int flavor,const FPU & fpu)47435933ddSDimitry Andric int RegisterContextMach_i386::DoWriteFPU(lldb::tid_t tid, int flavor,
48435933ddSDimitry Andric const FPU &fpu) {
49acac075bSDimitry Andric return ::thread_set_state(
50acac075bSDimitry Andric tid, flavor, reinterpret_cast<thread_state_t>(const_cast<FPU *>(&fpu)),
51acac075bSDimitry Andric FPUWordCount);
52ac7ddfbfSEd Maste }
53ac7ddfbfSEd Maste
DoWriteEXC(lldb::tid_t tid,int flavor,const EXC & exc)54435933ddSDimitry Andric int RegisterContextMach_i386::DoWriteEXC(lldb::tid_t tid, int flavor,
55435933ddSDimitry Andric const EXC &exc) {
56acac075bSDimitry Andric return ::thread_set_state(
57acac075bSDimitry Andric tid, flavor, reinterpret_cast<thread_state_t>(const_cast<EXC *>(&exc)),
58acac075bSDimitry Andric EXCWordCount);
59ac7ddfbfSEd Maste }
60ac7ddfbfSEd Maste
61ac7ddfbfSEd Maste #endif
62