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