Rev 3424 | Rev 3611 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3424 | Rev 3471 | ||
---|---|---|---|
Line 31... | Line 31... | ||
31 | */ |
31 | */ |
32 | 32 | ||
33 | /** |
33 | /** |
34 | * @file |
34 | * @file |
35 | * @brief Udebug IPC message handling. |
35 | * @brief Udebug IPC message handling. |
- | 36 | * |
|
- | 37 | * This module handles udebug IPC messages and calls the appropriate |
|
- | 38 | * functions from the udebug_ops module which implement them. |
|
36 | */ |
39 | */ |
37 | 40 | ||
38 | #include <print.h> |
- | |
39 | #include <proc/task.h> |
41 | #include <proc/task.h> |
40 | #include <proc/thread.h> |
42 | #include <proc/thread.h> |
41 | #include <arch.h> |
43 | #include <arch.h> |
42 | #include <errno.h> |
44 | #include <errno.h> |
43 | #include <ipc/ipc.h> |
45 | #include <ipc/ipc.h> |
Line 114... | Line 116... | ||
114 | } |
116 | } |
115 | 117 | ||
116 | return 0; |
118 | return 0; |
117 | } |
119 | } |
118 | 120 | ||
- | 121 | /** Process a BEGIN call. |
|
- | 122 | * |
|
- | 123 | * Initiates a debugging session for the current task. The reply |
|
- | 124 | * to this call may or may not be sent before this function returns. |
|
- | 125 | * |
|
- | 126 | * @param call The call structure. |
|
- | 127 | */ |
|
119 | static void udebug_receive_begin(call_t *call) |
128 | static void udebug_receive_begin(call_t *call) |
120 | { |
129 | { |
121 | int rc; |
130 | int rc; |
122 | 131 | ||
123 | rc = udebug_begin(call); |
132 | rc = udebug_begin(call); |
Line 125... | Line 134... | ||
125 | IPC_SET_RETVAL(call->data, rc); |
134 | IPC_SET_RETVAL(call->data, rc); |
126 | ipc_answer(&TASK->kernel_box, call); |
135 | ipc_answer(&TASK->kernel_box, call); |
127 | return; |
136 | return; |
128 | } |
137 | } |
129 | 138 | ||
- | 139 | /* |
|
- | 140 | * If the initialization of the debugging session has finished, |
|
- | 141 | * send a reply. |
|
- | 142 | */ |
|
130 | if (rc != 0) { |
143 | if (rc != 0) { |
131 | IPC_SET_RETVAL(call->data, 0); |
144 | IPC_SET_RETVAL(call->data, 0); |
132 | ipc_answer(&TASK->kernel_box, call); |
145 | ipc_answer(&TASK->kernel_box, call); |
133 | } |
146 | } |
134 | } |
147 | } |
135 | 148 | ||
- | 149 | /** Process an END call. |
|
- | 150 | * |
|
- | 151 | * Terminates the debugging session for the current task. |
|
- | 152 | * @param call The call structure. |
|
- | 153 | */ |
|
136 | static void udebug_receive_end(call_t *call) |
154 | static void udebug_receive_end(call_t *call) |
137 | { |
155 | { |
138 | int rc; |
156 | int rc; |
139 | 157 | ||
140 | rc = udebug_end(); |
158 | rc = udebug_end(); |
141 | 159 | ||
142 | IPC_SET_RETVAL(call->data, rc); |
160 | IPC_SET_RETVAL(call->data, rc); |
143 | ipc_answer(&TASK->kernel_box, call); |
161 | ipc_answer(&TASK->kernel_box, call); |
144 | } |
162 | } |
145 | 163 | ||
- | 164 | /** Process a SET_EVMASK call. |
|
- | 165 | * |
|
- | 166 | * Sets an event mask for the current debugging session. |
|
- | 167 | * @param call The call structure. |
|
- | 168 | */ |
|
146 | static void udebug_receive_set_evmask(call_t *call) |
169 | static void udebug_receive_set_evmask(call_t *call) |
147 | { |
170 | { |
148 | int rc; |
171 | int rc; |
149 | udebug_evmask_t mask; |
172 | udebug_evmask_t mask; |
150 | 173 | ||
Line 154... | Line 177... | ||
154 | IPC_SET_RETVAL(call->data, rc); |
177 | IPC_SET_RETVAL(call->data, rc); |
155 | ipc_answer(&TASK->kernel_box, call); |
178 | ipc_answer(&TASK->kernel_box, call); |
156 | } |
179 | } |
157 | 180 | ||
158 | 181 | ||
- | 182 | /** Process a GO call. |
|
- | 183 | * |
|
- | 184 | * Resumes execution of the specified thread. |
|
- | 185 | * @param call The call structure. |
|
- | 186 | */ |
|
159 | static void udebug_receive_go(call_t *call) |
187 | static void udebug_receive_go(call_t *call) |
160 | { |
188 | { |
161 | thread_t *t; |
189 | thread_t *t; |
162 | int rc; |
190 | int rc; |
163 | 191 | ||
164 | //printf("debug_go()\n"); |
- | |
165 | - | ||
166 | t = (thread_t *)IPC_GET_ARG2(call->data); |
192 | t = (thread_t *)IPC_GET_ARG2(call->data); |
167 | 193 | ||
168 | rc = udebug_go(t, call); |
194 | rc = udebug_go(t, call); |
169 | if (rc < 0) { |
195 | if (rc < 0) { |
170 | IPC_SET_RETVAL(call->data, rc); |
196 | IPC_SET_RETVAL(call->data, rc); |
171 | ipc_answer(&TASK->kernel_box, call); |
197 | ipc_answer(&TASK->kernel_box, call); |
172 | return; |
198 | return; |
173 | } |
199 | } |
174 | } |
200 | } |
175 | 201 | ||
- | 202 | /** Process a STOP call. |
|
- | 203 | * |
|
- | 204 | * Suspends execution of the specified thread. |
|
- | 205 | * @param call The call structure. |
|
- | 206 | */ |
|
176 | static void udebug_receive_stop(call_t *call) |
207 | static void udebug_receive_stop(call_t *call) |
177 | { |
208 | { |
178 | thread_t *t; |
209 | thread_t *t; |
179 | int rc; |
210 | int rc; |
180 | 211 | ||
181 | printf("debug_stop()\n"); |
- | |
182 | - | ||
183 | t = (thread_t *)IPC_GET_ARG2(call->data); |
212 | t = (thread_t *)IPC_GET_ARG2(call->data); |
184 | 213 | ||
185 | rc = udebug_stop(t, call); |
214 | rc = udebug_stop(t, call); |
186 | IPC_SET_RETVAL(call->data, rc); |
215 | IPC_SET_RETVAL(call->data, rc); |
187 | ipc_answer(&TASK->kernel_box, call); |
216 | ipc_answer(&TASK->kernel_box, call); |
188 | } |
217 | } |
189 | 218 | ||
- | 219 | /** Process a THREAD_READ call. |
|
- | 220 | * |
|
- | 221 | * Reads the list of hashes of the (userspace) threads in the current task. |
|
- | 222 | * @param call The call structure. |
|
- | 223 | */ |
|
190 | static void udebug_receive_thread_read(call_t *call) |
224 | static void udebug_receive_thread_read(call_t *call) |
191 | { |
225 | { |
192 | unative_t uspace_addr; |
226 | unative_t uspace_addr; |
193 | unative_t to_copy; |
227 | unative_t to_copy; |
194 | unsigned total_bytes; |
228 | unsigned total_bytes; |
Line 235... | Line 269... | ||
235 | call->buffer = buffer; |
269 | call->buffer = buffer; |
236 | 270 | ||
237 | ipc_answer(&TASK->kernel_box, call); |
271 | ipc_answer(&TASK->kernel_box, call); |
238 | } |
272 | } |
239 | 273 | ||
- | 274 | /** Process an ARGS_READ call. |
|
- | 275 | * |
|
- | 276 | * Reads the argument of a current syscall event (SYSCALL_B or SYSCALL_E). |
|
- | 277 | * @param call The call structure. |
|
- | 278 | */ |
|
240 | static void udebug_receive_args_read(call_t *call) |
279 | static void udebug_receive_args_read(call_t *call) |
241 | { |
280 | { |
242 | thread_t *t; |
281 | thread_t *t; |
243 | unative_t uspace_addr; |
282 | unative_t uspace_addr; |
244 | int rc; |
283 | int rc; |
Line 332... | Line 371... | ||
332 | call->buffer = NULL; |
371 | call->buffer = NULL; |
333 | 372 | ||
334 | ipc_answer(&TASK->kernel_box, call); |
373 | ipc_answer(&TASK->kernel_box, call); |
335 | } |
374 | } |
336 | 375 | ||
- | 376 | /** Process an MEM_READ call. |
|
337 | 377 | * |
|
- | 378 | * Reads memory of the current (debugged) task. |
|
- | 379 | * @param call The call structure. |
|
- | 380 | */ |
|
338 | static void udebug_receive_mem_read(call_t *call) |
381 | static void udebug_receive_mem_read(call_t *call) |
339 | { |
382 | { |
340 | unative_t uspace_dst; |
383 | unative_t uspace_dst; |
341 | unative_t uspace_src; |
384 | unative_t uspace_src; |
342 | unsigned size; |
385 | unsigned size; |
Line 389... | Line 432... | ||
389 | 432 | ||
390 | ipc_answer(&TASK->kernel_box, call); |
433 | ipc_answer(&TASK->kernel_box, call); |
391 | } |
434 | } |
392 | 435 | ||
393 | 436 | ||
394 | /** |
- | |
395 | * Handle a debug call received on the kernel answerbox. |
437 | /** Handle a debug call received on the kernel answerbox. |
396 | * |
438 | * |
397 | * This is called by the kbox servicing thread. |
439 | * This is called by the kbox servicing thread. Verifies that the sender |
- | 440 | * is indeed the debugger and calls the appropriate processing function. |
|
398 | */ |
441 | */ |
399 | void udebug_call_receive(call_t *call) |
442 | void udebug_call_receive(call_t *call) |
400 | { |
443 | { |
401 | int debug_method; |
444 | int debug_method; |
402 | 445 |