1 //===-- RegisterContextMach_arm.cpp -----------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #if defined(__APPLE__) 11 12 #include "RegisterContextMach_arm.h" 13 14 #include <mach/mach_types.h> 15 #include <mach/thread_act.h> 16 17 18 using namespace lldb; 19 using namespace lldb_private; 20 21 RegisterContextMach_arm::RegisterContextMach_arm(Thread &thread, 22 uint32_t concrete_frame_idx) 23 : RegisterContextDarwin_arm(thread, concrete_frame_idx) {} 24 25 RegisterContextMach_arm::~RegisterContextMach_arm() {} 26 27 int RegisterContextMach_arm::DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr) { 28 mach_msg_type_number_t count = GPRWordCount; 29 return ::thread_get_state(tid, flavor, (thread_state_t)&gpr, &count); 30 } 31 32 int RegisterContextMach_arm::DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu) { 33 mach_msg_type_number_t count = FPUWordCount; 34 return ::thread_get_state(tid, flavor, (thread_state_t)&fpu, &count); 35 } 36 37 int RegisterContextMach_arm::DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc) { 38 mach_msg_type_number_t count = EXCWordCount; 39 return ::thread_get_state(tid, flavor, (thread_state_t)&exc, &count); 40 } 41 42 int RegisterContextMach_arm::DoReadDBG(lldb::tid_t tid, int flavor, DBG &dbg) { 43 mach_msg_type_number_t count = DBGWordCount; 44 return ::thread_get_state(tid, flavor, (thread_state_t)&dbg, &count); 45 } 46 47 int RegisterContextMach_arm::DoWriteGPR(lldb::tid_t tid, int flavor, 48 const GPR &gpr) { 49 return ::thread_set_state( 50 tid, flavor, reinterpret_cast<thread_state_t>(const_cast<GPR *>(&gpr)), 51 GPRWordCount); 52 } 53 54 int RegisterContextMach_arm::DoWriteFPU(lldb::tid_t tid, int flavor, 55 const FPU &fpu) { 56 return ::thread_set_state( 57 tid, flavor, reinterpret_cast<thread_state_t>(const_cast<FPU *>(&fpu)), 58 FPUWordCount); 59 } 60 61 int RegisterContextMach_arm::DoWriteEXC(lldb::tid_t tid, int flavor, 62 const EXC &exc) { 63 return ::thread_set_state( 64 tid, flavor, reinterpret_cast<thread_state_t>(const_cast<EXC *>(&exc)), 65 EXCWordCount); 66 } 67 68 int RegisterContextMach_arm::DoWriteDBG(lldb::tid_t tid, int flavor, 69 const DBG &dbg) { 70 return ::thread_set_state( 71 tid, flavor, reinterpret_cast<thread_state_t>(const_cast<DBG *>(&dbg)), 72 DBGWordCount); 73 } 74 75 #endif 76