Changeset 1378b2b in mainline
- Timestamp:
- 2008-11-21T14:04:08Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 384c488
- Parents:
- 18c485a
- Location:
- kernel/generic
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/udebug/udebug.h
r18c485a r1378b2b 177 177 atomic_t int_lock; 178 178 179 /** Synchronize debug ops on this thread / access to this structure */179 /** Synchronize debug ops on this thread / access to this structure. */ 180 180 mutex_t lock; 181 181 … … 184 184 unative_t syscall_args[6]; 185 185 186 /** What type of event are we stopped in or 0 if none */186 /** What type of event are we stopped in or 0 if none. */ 187 187 udebug_event_t cur_event; 188 188 bool stop; 189 189 bool stoppable; 190 bool debug_active; /**< In a debugging session */190 bool debug_active; /**< in a debugging session */ 191 191 } udebug_thread_t; 192 192 -
kernel/generic/src/udebug/udebug.c
r18c485a r1378b2b 248 248 249 249 goto restart; 250 /* must try again - have to lose stoppability atomically*/250 /* Must try again - have to lose stoppability atomically. */ 251 251 } else { 252 252 ++TASK->udebug.not_stoppable_count; … … 322 322 mutex_lock(&THREAD->udebug.lock); 323 323 324 /* Must only generate events when in debugging session and have go*/324 /* Must only generate events when in debugging session and is go. */ 325 325 if (THREAD->udebug.debug_active != true || 326 326 THREAD->udebug.stop == true || … … 440 440 LOG("- check state\n"); 441 441 442 /* Must only generate events when in debugging session */442 /* Must only generate events when in debugging session. */ 443 443 if (THREAD->udebug.debug_active != true) { 444 444 /* printf("- debug_active: %s, udebug.stop: %s\n", … … 457 457 IPC_SET_ARG1(call->data, UDEBUG_EVENT_THREAD_E); 458 458 459 /* Prevent any further debug activity in thread */459 /* Prevent any further debug activity in thread. */ 460 460 THREAD->udebug.debug_active = false; 461 461 THREAD->udebug.cur_event = 0; /* none */ … … 467 467 mutex_unlock(&TASK->udebug.lock); 468 468 469 /* Leave int_lock enabled */470 /* This event does not sleep - debugging has finished in this thread */469 /* Leave int_lock enabled. */ 470 /* This event does not sleep - debugging has finished in this thread. */ 471 471 } 472 472 … … 513 513 interrupts_restore(ipl); 514 514 515 /* Only process userspace threads */515 /* Only process userspace threads. */ 516 516 if ((flags & THREAD_FLAG_USPACE) != 0) { 517 /* Prevent any further debug activity in thread */517 /* Prevent any further debug activity in thread. */ 518 518 t->udebug.debug_active = false; 519 519 t->udebug.cur_event = 0; /* none */ 520 520 521 /* Still hasgo? */521 /* Is the thread still go? */ 522 522 if (t->udebug.stop == false) { 523 523 /* -
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.