1 //===-- RegisterContextKDP_i386.cpp ---------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "RegisterContextKDP_i386.h"
10 #include "ProcessKDP.h"
11 #include "ThreadKDP.h"
12
13 using namespace lldb;
14 using namespace lldb_private;
15
RegisterContextKDP_i386(ThreadKDP & thread,uint32_t concrete_frame_idx)16 RegisterContextKDP_i386::RegisterContextKDP_i386(ThreadKDP &thread,
17 uint32_t concrete_frame_idx)
18 : RegisterContextDarwin_i386(thread, concrete_frame_idx),
19 m_kdp_thread(thread) {}
20
21 RegisterContextKDP_i386::~RegisterContextKDP_i386() = default;
22
DoReadGPR(lldb::tid_t tid,int flavor,GPR & gpr)23 int RegisterContextKDP_i386::DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr) {
24 ProcessSP process_sp(CalculateProcess());
25 if (process_sp) {
26 Status error;
27 if (static_cast<ProcessKDP *>(process_sp.get())
28 ->GetCommunication()
29 .SendRequestReadRegisters(tid, GPRRegSet, &gpr, sizeof(gpr),
30 error)) {
31 if (error.Success())
32 return 0;
33 }
34 }
35 return -1;
36 }
37
DoReadFPU(lldb::tid_t tid,int flavor,FPU & fpu)38 int RegisterContextKDP_i386::DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu) {
39 ProcessSP process_sp(CalculateProcess());
40 if (process_sp) {
41 Status error;
42 if (static_cast<ProcessKDP *>(process_sp.get())
43 ->GetCommunication()
44 .SendRequestReadRegisters(tid, FPURegSet, &fpu, sizeof(fpu),
45 error)) {
46 if (error.Success())
47 return 0;
48 }
49 }
50 return -1;
51 }
52
DoReadEXC(lldb::tid_t tid,int flavor,EXC & exc)53 int RegisterContextKDP_i386::DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc) {
54 ProcessSP process_sp(CalculateProcess());
55 if (process_sp) {
56 Status error;
57 if (static_cast<ProcessKDP *>(process_sp.get())
58 ->GetCommunication()
59 .SendRequestReadRegisters(tid, EXCRegSet, &exc, sizeof(exc),
60 error)) {
61 if (error.Success())
62 return 0;
63 }
64 }
65 return -1;
66 }
67
DoWriteGPR(lldb::tid_t tid,int flavor,const GPR & gpr)68 int RegisterContextKDP_i386::DoWriteGPR(lldb::tid_t tid, int flavor,
69 const GPR &gpr) {
70 ProcessSP process_sp(CalculateProcess());
71 if (process_sp) {
72 Status error;
73 if (static_cast<ProcessKDP *>(process_sp.get())
74 ->GetCommunication()
75 .SendRequestWriteRegisters(tid, GPRRegSet, &gpr, sizeof(gpr),
76 error)) {
77 if (error.Success())
78 return 0;
79 }
80 }
81 return -1;
82 }
83
DoWriteFPU(lldb::tid_t tid,int flavor,const FPU & fpu)84 int RegisterContextKDP_i386::DoWriteFPU(lldb::tid_t tid, int flavor,
85 const FPU &fpu) {
86 ProcessSP process_sp(CalculateProcess());
87 if (process_sp) {
88 Status error;
89 if (static_cast<ProcessKDP *>(process_sp.get())
90 ->GetCommunication()
91 .SendRequestWriteRegisters(tid, FPURegSet, &fpu, sizeof(fpu),
92 error)) {
93 if (error.Success())
94 return 0;
95 }
96 }
97 return -1;
98 }
99
DoWriteEXC(lldb::tid_t tid,int flavor,const EXC & exc)100 int RegisterContextKDP_i386::DoWriteEXC(lldb::tid_t tid, int flavor,
101 const EXC &exc) {
102 ProcessSP process_sp(CalculateProcess());
103 if (process_sp) {
104 Status error;
105 if (static_cast<ProcessKDP *>(process_sp.get())
106 ->GetCommunication()
107 .SendRequestWriteRegisters(tid, EXCRegSet, &exc, sizeof(exc),
108 error)) {
109 if (error.Success())
110 return 0;
111 }
112 }
113 return -1;
114 }
115