Rev 2838 | Rev 2842 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2838 | Rev 2841 | ||
|---|---|---|---|
| Line 63... | Line 63... | ||
| 63 | interrupts_restore(ipl); |
63 | interrupts_restore(ipl); |
| 64 | 64 | ||
| 65 | return ta; |
65 | return ta; |
| 66 | } |
66 | } |
| 67 | 67 | ||
| - | 68 | static int verify_thread(thread_t *t) |
|
| - | 69 | { |
|
| - | 70 | /* Verify that 't' exists and belongs to task 'ta' */ |
|
| - | 71 | if (!thread_exists(t) || (t->task != ta)) { |
|
| - | 72 | spinlock_unlock(&threads_lock); |
|
| - | 73 | interrupts_restore(ipl); |
|
| - | 74 | return ENOENT; |
|
| - | 75 | } |
|
| - | 76 | ||
| - | 77 | /* Verify that 't' is a userspace thread */ |
|
| - | 78 | if ((t->flags & THREAD_FLAG_USPACE) == 0) { |
|
| - | 79 | /* It's not, deny its existence */ |
|
| - | 80 | return ENOENT; |
|
| - | 81 | } |
|
| - | 82 | ||
| - | 83 | if ((t->debug_active != true) || (t->debug_stop != true)) { |
|
| - | 84 | /* Not in debugging session or already has GO */ |
|
| - | 85 | spinlock_unlock(&threads_lock); |
|
| - | 86 | interrupts_restore(ipl); |
|
| - | 87 | return EBUSY; |
|
| - | 88 | } |
|
| - | 89 | ||
| - | 90 | return EOK; |
|
| - | 91 | } |
|
| - | 92 | ||
| 68 | static int udebug_rp_begin(call_t *call, phone_t *phone) |
93 | static int udebug_rp_begin(call_t *call, phone_t *phone) |
| 69 | { |
94 | { |
| 70 | task_t *ta; |
95 | task_t *ta; |
| 71 | ipl_t ipl; |
96 | ipl_t ipl; |
| 72 | int rc; |
97 | int rc; |
| Line 203... | Line 228... | ||
| 203 | t = (thread_t *) IPC_GET_ARG2(call->data); |
228 | t = (thread_t *) IPC_GET_ARG2(call->data); |
| 204 | 229 | ||
| 205 | ipl = interrupts_disable(); |
230 | ipl = interrupts_disable(); |
| 206 | spinlock_lock(&threads_lock); |
231 | spinlock_lock(&threads_lock); |
| 207 | 232 | ||
| 208 | /* Verify that 't' exists and belongs to task 'ta' */ |
- | |
| 209 | if (!thread_exists(t) || (t->task != ta)) { |
- | |
| 210 | spinlock_unlock(&threads_lock); |
- | |
| 211 | interrupts_restore(ipl); |
- | |
| 212 | return ENOENT; |
- | |
| 213 | } |
- | |
| 214 | - | ||
| 215 | if ((t->debug_active != true) || (t->debug_stop != true)) { |
- | |
| 216 | /* Not in debugging session or already has GO */ |
- | |
| 217 | spinlock_unlock(&threads_lock); |
- | |
| 218 | interrupts_restore(ipl); |
- | |
| 219 | return EBUSY; |
- | |
| 220 | } |
- | |
| 221 | 233 | ||
| 222 | t->debug_go_call = call; |
234 | t->debug_go_call = call; |
| 223 | t->debug_stop = false; |
235 | t->debug_stop = false; |
| 224 | waitq_wakeup(&t->go_wq, WAKEUP_FIRST); |
236 | waitq_wakeup(&t->go_wq, WAKEUP_FIRST); |
| 225 | 237 | ||
| Line 247... | Line 259... | ||
| 247 | t = (thread_t *) IPC_GET_ARG2(call->data); |
259 | t = (thread_t *) IPC_GET_ARG2(call->data); |
| 248 | 260 | ||
| 249 | ipl = interrupts_disable(); |
261 | ipl = interrupts_disable(); |
| 250 | spinlock_lock(&threads_lock); |
262 | spinlock_lock(&threads_lock); |
| 251 | 263 | ||
| 252 | /* Verify that 't' exists and belongs to task 'ta' */ |
264 | /* Verify that thread t exists and may be operated on */ |
| - | 265 | rc = verify_thread(t); |
|
| 253 | if (!thread_exists(t) || (t->task != ta)) { |
266 | if (rc != EOK) { |
| 254 | spinlock_unlock(&threads_lock); |
267 | spinlock_unlock(&threads_lock); |
| 255 | interrupts_restore(ipl); |
268 | interrupts_restore(ipl); |
| 256 | return ENOENT; |
269 | return rc; |
| 257 | } |
270 | } |
| 258 | 271 | ||
| 259 | //FIXME: additionally we need to verify that we are inside a syscall |
272 | //FIXME: additionally we need to verify that we are inside a syscall |
| 260 | if ((t->debug_active != true) || (t->debug_stop != true)) { |
- | |
| 261 | /* Not in debugging session or has GO */ |
- | |
| 262 | spinlock_unlock(&threads_lock); |
- | |
| 263 | interrupts_restore(ipl); |
- | |
| 264 | return EBUSY; |
- | |
| 265 | } |
- | |
| 266 | 273 | ||
| 267 | /* Copy to a local buffer before releasing the lock */ |
274 | /* Copy to a local buffer before releasing the lock */ |
| 268 | memcpy(buffer, t->syscall_args, 6 * sizeof(unative_t)); |
275 | memcpy(buffer, t->syscall_args, 6 * sizeof(unative_t)); |
| 269 | 276 | ||
| 270 | spinlock_unlock(&threads_lock); |
277 | spinlock_unlock(&threads_lock); |
| Line 305... | Line 312... | ||
| 305 | ipl = interrupts_disable(); |
312 | ipl = interrupts_disable(); |
| 306 | spinlock_lock(&threads_lock); |
313 | spinlock_lock(&threads_lock); |
| 307 | 314 | ||
| 308 | t = (thread_t *) IPC_GET_ARG2(call->data); |
315 | t = (thread_t *) IPC_GET_ARG2(call->data); |
| 309 | 316 | ||
| 310 | /* Verify that 't' exists and belongs to task 'ta' */ |
317 | /* Verify that thread t exists and may be operated on */ |
| - | 318 | rc = verify_thread(t); |
|
| 311 | if (!thread_exists(t) || (t->task != ta)) { |
319 | if (rc != EOK) { |
| 312 | spinlock_unlock(&threads_lock); |
320 | spinlock_unlock(&threads_lock); |
| 313 | interrupts_restore(ipl); |
321 | interrupts_restore(ipl); |
| 314 | return ENOENT; |
- | |
| 315 | } |
- | |
| 316 | - | ||
| 317 | if ((t->debug_active != true) || (t->debug_stop != true)) { |
- | |
| 318 | /* Not in debugging session or has GO */ |
- | |
| 319 | spinlock_unlock(&threads_lock); |
- | |
| 320 | interrupts_restore(ipl); |
- | |
| 321 | return EBUSY; |
322 | return rc; |
| 322 | } |
323 | } |
| 323 | 324 | ||
| 324 | state = t->uspace_state; |
325 | state = t->uspace_state; |
| 325 | if (state == NULL) { |
326 | if (state == NULL) { |
| 326 | spinlock_unlock(&threads_lock); |
327 | spinlock_unlock(&threads_lock); |
| Line 386... | Line 387... | ||
| 386 | ipl = interrupts_disable(); |
387 | ipl = interrupts_disable(); |
| 387 | spinlock_lock(&threads_lock); |
388 | spinlock_lock(&threads_lock); |
| 388 | 389 | ||
| 389 | t = (thread_t *) IPC_GET_ARG2(call->data); |
390 | t = (thread_t *) IPC_GET_ARG2(call->data); |
| 390 | 391 | ||
| 391 | /* Verify that 't' exists and belongs to task 'ta' */ |
392 | /* Verify that thread t exists and may be operated on */ |
| - | 393 | rc = verify_thread(t); |
|
| 392 | if (!thread_exists(t) || (t->task != ta)) { |
394 | if (rc != EOK) { |
| 393 | spinlock_unlock(&threads_lock); |
395 | spinlock_unlock(&threads_lock); |
| 394 | interrupts_restore(ipl); |
396 | interrupts_restore(ipl); |
| 395 | return ENOENT; |
- | |
| 396 | } |
- | |
| 397 | - | ||
| 398 | if ((t->debug_active != true) || (t->debug_stop != true)) { |
- | |
| 399 | /* Not in debugging session or has GO */ |
- | |
| 400 | spinlock_unlock(&threads_lock); |
- | |
| 401 | interrupts_restore(ipl); |
- | |
| 402 | return EBUSY; |
397 | return rc; |
| 403 | } |
398 | } |
| 404 | 399 | ||
| 405 | state = t->uspace_state; |
400 | state = t->uspace_state; |
| 406 | if (state == NULL) { |
401 | if (state == NULL) { |
| 407 | spinlock_unlock(&threads_lock); |
402 | spinlock_unlock(&threads_lock); |