]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Plugins / Process / Utility / RegisterContextMach_i386.cpp
1 //===-- RegisterContextMach_i386.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 <mach/thread_act.h>
13
14 #include "RegisterContextMach_i386.h"
15
16 using namespace lldb;
17 using namespace lldb_private;
18
19 RegisterContextMach_i386::RegisterContextMach_i386(Thread &thread,
20                                                    uint32_t concrete_frame_idx)
21     : RegisterContextDarwin_i386(thread, concrete_frame_idx) {}
22
23 RegisterContextMach_i386::~RegisterContextMach_i386() {}
24
25 int RegisterContextMach_i386::DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr) {
26   mach_msg_type_number_t count = GPRWordCount;
27   return ::thread_get_state(tid, flavor, (thread_state_t)&gpr, &count);
28 }
29
30 int RegisterContextMach_i386::DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu) {
31   mach_msg_type_number_t count = FPUWordCount;
32   return ::thread_get_state(tid, flavor, (thread_state_t)&fpu, &count);
33 }
34
35 int RegisterContextMach_i386::DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc) {
36   mach_msg_type_number_t count = EXCWordCount;
37   return ::thread_get_state(tid, flavor, (thread_state_t)&exc, &count);
38 }
39
40 int RegisterContextMach_i386::DoWriteGPR(lldb::tid_t tid, int flavor,
41                                          const GPR &gpr) {
42   return ::thread_set_state(
43       tid, flavor, reinterpret_cast<thread_state_t>(const_cast<GPR *>(&gpr)),
44       GPRWordCount);
45 }
46
47 int RegisterContextMach_i386::DoWriteFPU(lldb::tid_t tid, int flavor,
48                                          const FPU &fpu) {
49   return ::thread_set_state(
50       tid, flavor, reinterpret_cast<thread_state_t>(const_cast<FPU *>(&fpu)),
51       FPUWordCount);
52 }
53
54 int RegisterContextMach_i386::DoWriteEXC(lldb::tid_t tid, int flavor,
55                                          const EXC &exc) {
56   return ::thread_set_state(
57       tid, flavor, reinterpret_cast<thread_state_t>(const_cast<EXC *>(&exc)),
58       EXCWordCount);
59 }
60
61 #endif