LLDB  mainline
RegisterContextKDP_x86_64.cpp
Go to the documentation of this file.
1 //===-- RegisterContextKDP_x86_64.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 
10 #include "ProcessKDP.h"
11 #include "ThreadKDP.h"
12 
13 using namespace lldb;
14 using namespace lldb_private;
15 
17  ThreadKDP &thread, uint32_t concrete_frame_idx)
18  : RegisterContextDarwin_x86_64(thread, concrete_frame_idx),
19  m_kdp_thread(thread) {}
20 
22 
24  GPR &gpr) {
25  ProcessSP process_sp(CalculateProcess());
26  if (process_sp) {
27  Status error;
28  if (static_cast<ProcessKDP *>(process_sp.get())
30  .SendRequestReadRegisters(tid, GPRRegSet, &gpr, sizeof(gpr),
31  error)) {
32  if (error.Success())
33  return 0;
34  }
35  }
36  return -1;
37 }
38 
40  FPU &fpu) {
41  ProcessSP process_sp(CalculateProcess());
42  if (process_sp) {
43  Status error;
44  if (static_cast<ProcessKDP *>(process_sp.get())
46  .SendRequestReadRegisters(tid, FPURegSet, &fpu, sizeof(fpu),
47  error)) {
48  if (error.Success())
49  return 0;
50  }
51  }
52  return -1;
53 }
54 
56  EXC &exc) {
57  ProcessSP process_sp(CalculateProcess());
58  if (process_sp) {
59  Status error;
60  if (static_cast<ProcessKDP *>(process_sp.get())
62  .SendRequestReadRegisters(tid, EXCRegSet, &exc, sizeof(exc),
63  error)) {
64  if (error.Success())
65  return 0;
66  }
67  }
68  return -1;
69 }
70 
72  const GPR &gpr) {
73  ProcessSP process_sp(CalculateProcess());
74  if (process_sp) {
75  Status error;
76  if (static_cast<ProcessKDP *>(process_sp.get())
78  .SendRequestWriteRegisters(tid, GPRRegSet, &gpr, sizeof(gpr),
79  error)) {
80  if (error.Success())
81  return 0;
82  }
83  }
84  return -1;
85 }
86 
88  const FPU &fpu) {
89  ProcessSP process_sp(CalculateProcess());
90  if (process_sp) {
91  Status error;
92  if (static_cast<ProcessKDP *>(process_sp.get())
94  .SendRequestWriteRegisters(tid, FPURegSet, &fpu, sizeof(fpu),
95  error)) {
96  if (error.Success())
97  return 0;
98  }
99  }
100  return -1;
101 }
102 
104  const EXC &exc) {
105  ProcessSP process_sp(CalculateProcess());
106  if (process_sp) {
107  Status error;
108  if (static_cast<ProcessKDP *>(process_sp.get())
109  ->GetCommunication()
110  .SendRequestWriteRegisters(tid, EXCRegSet, &exc, sizeof(exc),
111  error)) {
112  if (error.Success())
113  return 0;
114  }
115  }
116  return -1;
117 }
CommunicationKDP::SendRequestReadRegisters
uint32_t SendRequestReadRegisters(uint32_t cpu, uint32_t flavor, void *dst, uint32_t dst_size, lldb_private::Status &error)
Definition: CommunicationKDP.cpp:1167
RegisterContextDarwin_x86_64::fpu
FPU fpu
Definition: RegisterContextDarwin_x86_64.h:119
ProcessKDP
Definition: ProcessKDP.h:30
ProcessKDP.h
ThreadKDP.h
RegisterContextDarwin_x86_64::GPR
Definition: RegisterContextDarwin_x86_64.h:47
RegisterContextKDP_x86_64::DoReadFPU
int DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu) override
Definition: RegisterContextKDP_x86_64.cpp:39
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
CommunicationKDP::SendRequestWriteRegisters
uint32_t SendRequestWriteRegisters(uint32_t cpu, uint32_t flavor, const void *src, uint32_t src_size, lldb_private::Status &error)
Definition: CommunicationKDP.cpp:1209
lldb_private::RegisterContext::CalculateProcess
lldb::ProcessSP CalculateProcess() override
Definition: RegisterContext.cpp:457
RegisterContextKDP_x86_64::DoWriteFPU
int DoWriteFPU(lldb::tid_t tid, int flavor, const FPU &fpu) override
Definition: RegisterContextKDP_x86_64.cpp:87
RegisterContextDarwin_x86_64::GPRRegSet
@ GPRRegSet
Definition: RegisterContextDarwin_x86_64.h:108
ThreadKDP
Definition: ThreadKDP.h:19
RegisterContextDarwin_x86_64::EXC
Definition: RegisterContextDarwin_x86_64.h:101
lldb_private::Status
Definition: Status.h:44
uint32_t
RegisterContextKDP_x86_64::DoReadGPR
int DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr) override
Definition: RegisterContextKDP_x86_64.cpp:23
RegisterContextKDP_x86_64::RegisterContextKDP_x86_64
RegisterContextKDP_x86_64(ThreadKDP &thread, uint32_t concrete_frame_idx)
Definition: RegisterContextKDP_x86_64.cpp:16
RegisterContextDarwin_x86_64
Definition: RegisterContextDarwin_x86_64.h:15
RegisterContextKDP_x86_64::DoWriteGPR
int DoWriteGPR(lldb::tid_t tid, int flavor, const GPR &gpr) override
Definition: RegisterContextKDP_x86_64.cpp:71
RegisterContextKDP_x86_64::DoReadEXC
int DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc) override
Definition: RegisterContextKDP_x86_64.cpp:55
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
RegisterContextKDP_x86_64::~RegisterContextKDP_x86_64
virtual ~RegisterContextKDP_x86_64()
RegisterContextKDP_x86_64.h
RegisterContextDarwin_x86_64::exc
EXC exc
Definition: RegisterContextDarwin_x86_64.h:120
RegisterContextDarwin_x86_64::EXCRegSet
@ EXCRegSet
Definition: RegisterContextDarwin_x86_64.h:108
RegisterContextDarwin_x86_64::FPU
Definition: RegisterContextDarwin_x86_64.h:80
RegisterContextDarwin_x86_64::FPURegSet
@ FPURegSet
Definition: RegisterContextDarwin_x86_64.h:108
lldb
Definition: SBAddress.h:15
RegisterContextDarwin_x86_64::gpr
GPR gpr
Definition: RegisterContextDarwin_x86_64.h:118
RegisterContextKDP_x86_64::DoWriteEXC
int DoWriteEXC(lldb::tid_t tid, int flavor, const EXC &exc) override
Definition: RegisterContextKDP_x86_64.cpp:103
ProcessKDP::GetCommunication
CommunicationKDP & GetCommunication()
Definition: ProcessKDP.h:136
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86