Coverage Report

Created: 2023-11-11 10:31

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- RegisterContextKDP_arm64.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_arm64.h"
10
11
#include "ProcessKDP.h"
12
#include "ThreadKDP.h"
13
14
using namespace lldb;
15
using namespace lldb_private;
16
17
RegisterContextKDP_arm64::RegisterContextKDP_arm64(ThreadKDP &thread,
18
                                                   uint32_t concrete_frame_idx)
19
0
    : RegisterContextDarwin_arm64(thread, concrete_frame_idx),
20
0
      m_kdp_thread(thread) {}
21
22
0
RegisterContextKDP_arm64::~RegisterContextKDP_arm64() = default;
23
24
0
int RegisterContextKDP_arm64::DoReadGPR(lldb::tid_t tid, int flavor, GPR &gpr) {
25
0
  ProcessSP process_sp(CalculateProcess());
26
0
  if (process_sp) {
27
0
    Status error;
28
0
    if (static_cast<ProcessKDP *>(process_sp.get())
29
0
            ->GetCommunication()
30
0
            .SendRequestReadRegisters(tid, GPRRegSet, &gpr, sizeof(gpr),
31
0
                                      error)) {
32
0
      if (error.Success())
33
0
        return 0;
34
0
    }
35
0
  }
36
0
  return -1;
37
0
}
38
39
0
int RegisterContextKDP_arm64::DoReadFPU(lldb::tid_t tid, int flavor, FPU &fpu) {
40
0
  ProcessSP process_sp(CalculateProcess());
41
0
  if (process_sp) {
42
0
    Status error;
43
0
    if (static_cast<ProcessKDP *>(process_sp.get())
44
0
            ->GetCommunication()
45
0
            .SendRequestReadRegisters(tid, FPURegSet, &fpu, sizeof(fpu),
46
0
                                      error)) {
47
0
      if (error.Success())
48
0
        return 0;
49
0
    }
50
0
  }
51
0
  return -1;
52
0
}
53
54
0
int RegisterContextKDP_arm64::DoReadEXC(lldb::tid_t tid, int flavor, EXC &exc) {
55
0
  ProcessSP process_sp(CalculateProcess());
56
0
  if (process_sp) {
57
0
    Status error;
58
0
    if (static_cast<ProcessKDP *>(process_sp.get())
59
0
            ->GetCommunication()
60
0
            .SendRequestReadRegisters(tid, EXCRegSet, &exc, sizeof(exc),
61
0
                                      error)) {
62
0
      if (error.Success())
63
0
        return 0;
64
0
    }
65
0
  }
66
0
  return -1;
67
0
}
68
69
0
int RegisterContextKDP_arm64::DoReadDBG(lldb::tid_t tid, int flavor, DBG &dbg) {
70
0
  ProcessSP process_sp(CalculateProcess());
71
0
  if (process_sp) {
72
0
    Status error;
73
0
    if (static_cast<ProcessKDP *>(process_sp.get())
74
0
            ->GetCommunication()
75
0
            .SendRequestReadRegisters(tid, DBGRegSet, &dbg, sizeof(dbg),
76
0
                                      error)) {
77
0
      if (error.Success())
78
0
        return 0;
79
0
    }
80
0
  }
81
0
  return -1;
82
0
}
83
84
int RegisterContextKDP_arm64::DoWriteGPR(lldb::tid_t tid, int flavor,
85
0
                                         const GPR &gpr) {
86
0
  ProcessSP process_sp(CalculateProcess());
87
0
  if (process_sp) {
88
0
    Status error;
89
0
    if (static_cast<ProcessKDP *>(process_sp.get())
90
0
            ->GetCommunication()
91
0
            .SendRequestWriteRegisters(tid, GPRRegSet, &gpr, sizeof(gpr),
92
0
                                       error)) {
93
0
      if (error.Success())
94
0
        return 0;
95
0
    }
96
0
  }
97
0
  return -1;
98
0
}
99
100
int RegisterContextKDP_arm64::DoWriteFPU(lldb::tid_t tid, int flavor,
101
0
                                         const FPU &fpu) {
102
0
  ProcessSP process_sp(CalculateProcess());
103
0
  if (process_sp) {
104
0
    Status error;
105
0
    if (static_cast<ProcessKDP *>(process_sp.get())
106
0
            ->GetCommunication()
107
0
            .SendRequestWriteRegisters(tid, FPURegSet, &fpu, sizeof(fpu),
108
0
                                       error)) {
109
0
      if (error.Success())
110
0
        return 0;
111
0
    }
112
0
  }
113
0
  return -1;
114
0
}
115
116
int RegisterContextKDP_arm64::DoWriteEXC(lldb::tid_t tid, int flavor,
117
0
                                         const EXC &exc) {
118
0
  ProcessSP process_sp(CalculateProcess());
119
0
  if (process_sp) {
120
0
    Status error;
121
0
    if (static_cast<ProcessKDP *>(process_sp.get())
122
0
            ->GetCommunication()
123
0
            .SendRequestWriteRegisters(tid, EXCRegSet, &exc, sizeof(exc),
124
0
                                       error)) {
125
0
      if (error.Success())
126
0
        return 0;
127
0
    }
128
0
  }
129
0
  return -1;
130
0
}
131
132
int RegisterContextKDP_arm64::DoWriteDBG(lldb::tid_t tid, int flavor,
133
0
                                         const DBG &dbg) {
134
0
  ProcessSP process_sp(CalculateProcess());
135
0
  if (process_sp) {
136
0
    Status error;
137
0
    if (static_cast<ProcessKDP *>(process_sp.get())
138
0
            ->GetCommunication()
139
0
            .SendRequestWriteRegisters(tid, DBGRegSet, &dbg, sizeof(dbg),
140
0
                                       error)) {
141
0
      if (error.Success())
142
0
        return 0;
143
0
    }
144
0
  }
145
0
  return -1;
146
0
}