Changeset 1378b2b in mainline for kernel/generic/src/udebug/udebug_ops.c
- Timestamp:
- 2008-11-21T14:04:08Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 384c488
- Parents:
- 18c485a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/udebug/udebug_ops.c
r18c485a r1378b2b 58 58 * Specifically, verifies that thread t exists, is a userspace thread, 59 59 * and belongs to the current task (TASK). Verifies, that the thread 60 * has (or hasn't) go according to having_go (typically false).60 * is (or is not) go according to being_go (typically false). 61 61 * It also locks t->udebug.lock, making sure that t->udebug.debug_active 62 62 * is true - that the thread is in a valid debugging session. … … 71 71 * 72 72 * @param t Pointer, need not at all be valid. 73 * @param having_go Required thread state.73 * @param being_go Required thread state. 74 74 * 75 75 * Returns EOK if all went well, or an error code otherwise. 76 76 */ 77 static int _thread_op_begin(thread_t *t, bool having_go)77 static int _thread_op_begin(thread_t *t, bool being_go) 78 78 { 79 79 task_id_t taskid; … … 99 99 spinlock_unlock(&threads_lock); 100 100 101 /* Verify that 't' is a userspace thread */101 /* Verify that 't' is a userspace thread. */ 102 102 if ((t->flags & THREAD_FLAG_USPACE) == 0) { 103 103 /* It's not, deny its existence */ … … 108 108 } 109 109 110 /* Verify debugging state */110 /* Verify debugging state. */ 111 111 if (t->udebug.debug_active != true) { 112 112 /* Not in debugging session or undesired GO state */ … … 125 125 interrupts_restore(ipl); 126 126 127 /* Only mutex TASK->udebug.lock left */127 /* Only mutex TASK->udebug.lock left. */ 128 128 129 /* Now verify that the thread belongs to the current task */129 /* Now verify that the thread belongs to the current task. */ 130 130 if (t->task != TASK) { 131 131 /* No such thread belonging this task*/ … … 140 140 mutex_lock(&t->udebug.lock); 141 141 142 /* The big task mutex is no longer needed */143 mutex_unlock(&TASK->udebug.lock); 144 145 if (!t->udebug.stop != having_go) {146 /* Not in debugging session or undesired GO state */142 /* The big task mutex is no longer needed. */ 143 mutex_unlock(&TASK->udebug.lock); 144 145 if (!t->udebug.stop != being_go) { 146 /* Not in debugging session or undesired GO state. */ 147 147 mutex_unlock(&t->udebug.lock); 148 148 return EINVAL; 149 149 } 150 150 151 /* Only t->udebug.lock left */152 153 return EOK; /* All went well */151 /* Only t->udebug.lock left. */ 152 153 return EOK; /* All went well. */ 154 154 } 155 155 … … 205 205 } 206 206 207 /* Set udebug.debug_active on all of the task's userspace threads */207 /* Set udebug.debug_active on all of the task's userspace threads. */ 208 208 209 209 for (cur = TASK->th_head.next; cur != &TASK->th_head; cur = cur->next) { … … 274 274 /** Give thread GO. 275 275 * 276 * Upon recieving a go message, the thread is given GO. Having GO276 * Upon recieving a go message, the thread is given GO. Being GO 277 277 * means the thread is allowed to execute userspace code (until 278 278 * a debugging event or STOP occurs, at which point the thread loses GO. … … 285 285 int rc; 286 286 287 /* On success, this will lock t->udebug.lock */287 /* On success, this will lock t->udebug.lock. */ 288 288 rc = _thread_op_begin(t, false); 289 289 if (rc != EOK) { … … 296 296 297 297 /* 298 * Neither t's lock nor threads_lock may be held during wakeup 298 * Neither t's lock nor threads_lock may be held during wakeup. 299 299 */ 300 300 waitq_wakeup(&t->udebug.go_wq, WAKEUP_FIRST); … … 329 329 } 330 330 331 /* Take GO away from the thread */331 /* Take GO away from the thread. */ 332 332 t->udebug.stop = true; 333 333 334 334 if (!t->udebug.stoppable) { 335 /* Answer will be sent when the thread becomes stoppable */335 /* Answer will be sent when the thread becomes stoppable. */ 336 336 _thread_op_end(t); 337 337 return 0; … … 339 339 340 340 /* 341 * Answer GO call 341 * Answer GO call. 342 342 */ 343 343 LOG("udebug_stop - answering go call\n"); 344 344 345 /* Make sure nobody takes this call away from us */345 /* Make sure nobody takes this call away from us. */ 346 346 call = t->udebug.go_call; 347 347 t->udebug.go_call = NULL; … … 423 423 spinlock_unlock(&t->lock); 424 424 425 /* Not interested in kernel threads */425 /* Not interested in kernel threads. */ 426 426 if ((flags & THREAD_FLAG_USPACE) != 0) { 427 427 /* Using thread struct pointer as identification hash */ … … 459 459 unative_t *arg_buffer; 460 460 461 /* Prepare a buffer to hold the arguments */461 /* Prepare a buffer to hold the arguments. */ 462 462 arg_buffer = malloc(6 * sizeof(unative_t), 0); 463 463 464 /* On success, this will lock t->udebug.lock */464 /* On success, this will lock t->udebug.lock. */ 465 465 rc = _thread_op_begin(t, false); 466 466 if (rc != EOK) { … … 468 468 } 469 469 470 /* Additionally we need to verify that we are inside a syscall */470 /* Additionally we need to verify that we are inside a syscall. */ 471 471 if (t->udebug.cur_event != UDEBUG_EVENT_SYSCALL_B && 472 472 t->udebug.cur_event != UDEBUG_EVENT_SYSCALL_E) { … … 475 475 } 476 476 477 /* Copy to a local buffer before releasing the lock */477 /* Copy to a local buffer before releasing the lock. */ 478 478 memcpy(arg_buffer, t->udebug.syscall_args, 6 * sizeof(unative_t)); 479 479
Note:
See TracChangeset
for help on using the changeset viewer.