Rev 3031 | Rev 3108 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3031 | Rev 3032 | ||
|---|---|---|---|
| Line 139... | Line 139... | ||
| 139 | 139 | ||
| 140 | mutex_lock(&TASK->udebug.lock); |
140 | mutex_lock(&TASK->udebug.lock); |
| 141 | 141 | ||
| 142 | nsc = --TASK->udebug.not_stoppable_count; |
142 | nsc = --TASK->udebug.not_stoppable_count; |
| 143 | 143 | ||
| 144 | if (TASK->udebug.dt_state == UDEBUG_TS_BEGINNING) { |
144 | /* Lock order OK, THREAD->udebug.lock is after TASK->udebug.lock */ |
| - | 145 | mutex_lock(&THREAD->udebug.lock); |
|
| 145 | klog_printf("udebug_stoppable_begin"); |
146 | ASSERT(THREAD->udebug.stoppable == false); |
| 146 | klog_printf(" - nsc := %d", nsc); |
147 | THREAD->udebug.stoppable = true; |
| 147 | } |
- | |
| 148 | 148 | ||
| 149 | if (TASK->udebug.dt_state == UDEBUG_TS_BEGINNING && nsc == 0) { |
149 | if (TASK->udebug.dt_state == UDEBUG_TS_BEGINNING && nsc == 0) { |
| 150 | /* |
150 | /* |
| 151 | * This was the last non-stoppable thread. Reply to |
151 | * This was the last non-stoppable thread. Reply to |
| 152 | * DEBUG_BEGIN call. |
152 | * DEBUG_BEGIN call. |
| 153 | */ |
153 | */ |
| 154 | 154 | ||
| 155 | db_call = TASK->udebug.begin_call; |
155 | db_call = TASK->udebug.begin_call; |
| 156 | ASSERT(db_call); |
156 | ASSERT(db_call); |
| 157 | 157 | ||
| 158 | /* Lock order OK, THREAD->udebug.lock is after TASK->udebug.lock */ |
- | |
| 159 | mutex_lock(&THREAD->udebug.lock); |
- | |
| 160 | ASSERT(THREAD->udebug.stoppable == false); |
- | |
| 161 | THREAD->udebug.stoppable = true; |
- | |
| 162 | mutex_unlock(&THREAD->udebug.lock); |
- | |
| 163 | - | ||
| 164 | TASK->udebug.dt_state = UDEBUG_TS_ACTIVE; |
158 | TASK->udebug.dt_state = UDEBUG_TS_ACTIVE; |
| 165 | TASK->udebug.begin_call = NULL; |
159 | TASK->udebug.begin_call = NULL; |
| 166 | mutex_unlock(&TASK->udebug.lock); |
- | |
| 167 | 160 | ||
| 168 | IPC_SET_RETVAL(db_call->data, 0); |
161 | IPC_SET_RETVAL(db_call->data, 0); |
| 169 | //klog_printf("udebug_stoppable_begin/ipc_answer"); |
- | |
| 170 | ipc_answer(&TASK->answerbox, db_call); |
162 | ipc_answer(&TASK->answerbox, db_call); |
| 171 | 163 | ||
| 172 | } else if (TASK->udebug.dt_state == UDEBUG_TS_ACTIVE) { |
164 | } else if (TASK->udebug.dt_state == UDEBUG_TS_ACTIVE) { |
| 173 | /* |
165 | /* |
| 174 | * Active debugging session |
166 | * Active debugging session |
| 175 | */ |
167 | */ |
| 176 | 168 | ||
| 177 | /* Lock order OK, THREAD->udebug.lock is after TASK->udebug.lock */ |
- | |
| 178 | mutex_lock(&THREAD->udebug.lock); |
- | |
| 179 | ASSERT(THREAD->udebug.stoppable == false); |
- | |
| 180 | THREAD->udebug.stoppable = true; |
- | |
| 181 | - | ||
| 182 | if (THREAD->udebug.debug_active && THREAD->udebug.stop) { |
169 | if (THREAD->udebug.debug_active && THREAD->udebug.stop) { |
| 183 | /* |
170 | /* |
| 184 | * Thread was requested to stop - answer go call |
171 | * Thread was requested to stop - answer go call |
| 185 | */ |
172 | */ |
| 186 | 173 | ||
| Line 191... | Line 178... | ||
| 191 | 178 | ||
| 192 | IPC_SET_RETVAL(go_call->data, 0); |
179 | IPC_SET_RETVAL(go_call->data, 0); |
| 193 | IPC_SET_ARG1(go_call->data, UDEBUG_EVENT_STOP); |
180 | IPC_SET_ARG1(go_call->data, UDEBUG_EVENT_STOP); |
| 194 | 181 | ||
| 195 | THREAD->udebug.cur_event = UDEBUG_EVENT_STOP; |
182 | THREAD->udebug.cur_event = UDEBUG_EVENT_STOP; |
| 196 | mutex_unlock(&THREAD->udebug.lock); |
- | |
| 197 | 183 | ||
| 198 | ipc_answer(&TASK->answerbox, go_call); |
184 | ipc_answer(&TASK->answerbox, go_call); |
| 199 | - | ||
| 200 | mutex_unlock(&TASK->udebug.lock); |
- | |
| 201 | } else { |
- | |
| 202 | /* |
- | |
| 203 | * No stop request - nothing happens. |
- | |
| 204 | */ |
- | |
| 205 | mutex_unlock(&THREAD->udebug.lock); |
- | |
| 206 | mutex_unlock(&TASK->udebug.lock); |
- | |
| 207 | } |
185 | } |
| 208 | } else { |
- | |
| 209 | /* |
- | |
| 210 | * All other cases - nothing special happens. |
- | |
| 211 | */ |
- | |
| 212 | - | ||
| 213 | /* Lock order OK, THREAD->udebug.lock is after TASK->udebug.lock */ |
- | |
| 214 | mutex_lock(&THREAD->udebug.lock); |
- | |
| 215 | ASSERT(THREAD->udebug.stoppable == false); |
- | |
| 216 | THREAD->udebug.stoppable = true; |
- | |
| 217 | mutex_unlock(&THREAD->udebug.lock); |
- | |
| 218 | - | ||
| 219 | mutex_unlock(&TASK->udebug.lock); |
- | |
| 220 | } |
186 | } |
| - | 187 | ||
| - | 188 | mutex_unlock(&THREAD->udebug.lock); |
|
| - | 189 | mutex_unlock(&TASK->udebug.lock); |
|
| 221 | } |
190 | } |
| 222 | 191 | ||
| 223 | void udebug_stoppable_end(void) |
192 | void udebug_stoppable_end(void) |
| 224 | { |
193 | { |
| 225 | /* Early check for undebugged tasks */ |
194 | /* Early check for undebugged tasks */ |
| Line 228... | Line 197... | ||
| 228 | return; |
197 | return; |
| 229 | } |
198 | } |
| 230 | 199 | ||
| 231 | restart: |
200 | restart: |
| 232 | mutex_lock(&TASK->udebug.lock); |
201 | mutex_lock(&TASK->udebug.lock); |
| 233 | - | ||
| 234 | /* Lock order OK, THREAD->udebug.lock is after TASK->udebug.lock */ |
- | |
| 235 | mutex_lock(&THREAD->udebug.lock); |
202 | mutex_lock(&THREAD->udebug.lock); |
| 236 | 203 | ||
| 237 | if (THREAD->udebug.debug_active && |
204 | if (THREAD->udebug.debug_active && |
| 238 | THREAD->udebug.stop == true) { |
205 | THREAD->udebug.stop == true) { |
| 239 | TASK->udebug.begin_call = NULL; |
206 | TASK->udebug.begin_call = NULL; |
| Line 341... | Line 308... | ||
| 341 | * Make sure udebug.stop is true when going to sleep |
308 | * Make sure udebug.stop is true when going to sleep |
| 342 | * in case we get woken up by DEBUG_END. (At which |
309 | * in case we get woken up by DEBUG_END. (At which |
| 343 | * point it must be back to the initial true value). |
310 | * point it must be back to the initial true value). |
| 344 | */ |
311 | */ |
| 345 | THREAD->udebug.stop = true; |
312 | THREAD->udebug.stop = true; |
| 346 | - | ||
| 347 | THREAD->udebug.cur_event = etype; |
313 | THREAD->udebug.cur_event = etype; |
| 348 | mutex_unlock(&THREAD->udebug.lock); |
- | |
| 349 | 314 | ||
| 350 | ipc_answer(&TASK->answerbox, call); |
315 | ipc_answer(&TASK->answerbox, call); |
| 351 | 316 | ||
| - | 317 | mutex_unlock(&THREAD->udebug.lock); |
|
| 352 | mutex_unlock(&TASK->udebug.lock); |
318 | mutex_unlock(&TASK->udebug.lock); |
| 353 | 319 | ||
| 354 | udebug_wait_for_go(&THREAD->udebug.go_wq); |
320 | udebug_wait_for_go(&THREAD->udebug.go_wq); |
| 355 | 321 | ||
| 356 | udebug_int_unlock(); |
322 | udebug_int_unlock(); |
| Line 390... | Line 356... | ||
| 390 | * Make sure udebug.stop is true when going to sleep |
356 | * Make sure udebug.stop is true when going to sleep |
| 391 | * in case we get woken up by DEBUG_END. (At which |
357 | * in case we get woken up by DEBUG_END. (At which |
| 392 | * point it must be back to the initial true value). |
358 | * point it must be back to the initial true value). |
| 393 | */ |
359 | */ |
| 394 | THREAD->udebug.stop = true; |
360 | THREAD->udebug.stop = true; |
| 395 | - | ||
| 396 | THREAD->udebug.cur_event = UDEBUG_EVENT_THREAD_B; |
361 | THREAD->udebug.cur_event = UDEBUG_EVENT_THREAD_B; |
| 397 | mutex_unlock(&THREAD->udebug.lock); |
- | |
| 398 | 362 | ||
| 399 | ipc_answer(&TASK->answerbox, call); |
363 | ipc_answer(&TASK->answerbox, call); |
| 400 | 364 | ||
| - | 365 | mutex_unlock(&THREAD->udebug.lock); |
|
| 401 | mutex_unlock(&TASK->udebug.lock); |
366 | mutex_unlock(&TASK->udebug.lock); |
| 402 | 367 | ||
| 403 | klog_printf("- sleep"); |
368 | klog_printf("- sleep"); |
| 404 | udebug_wait_for_go(&THREAD->udebug.go_wq); |
369 | udebug_wait_for_go(&THREAD->udebug.go_wq); |
| 405 | 370 | ||
| Line 438... | Line 403... | ||
| 438 | /* Prevent any further debug activity in thread */ |
403 | /* Prevent any further debug activity in thread */ |
| 439 | THREAD->udebug.debug_active = false; |
404 | THREAD->udebug.debug_active = false; |
| 440 | THREAD->udebug.cur_event = 0; /* none */ |
405 | THREAD->udebug.cur_event = 0; /* none */ |
| 441 | THREAD->udebug.stop = true; /* set to initial value */ |
406 | THREAD->udebug.stop = true; /* set to initial value */ |
| 442 | 407 | ||
| 443 | mutex_unlock(&THREAD->udebug.lock); |
- | |
| 444 | - | ||
| 445 | ipc_answer(&TASK->answerbox, call); |
408 | ipc_answer(&TASK->answerbox, call); |
| 446 | 409 | ||
| - | 410 | mutex_unlock(&THREAD->udebug.lock); |
|
| 447 | mutex_unlock(&TASK->udebug.lock); |
411 | mutex_unlock(&TASK->udebug.lock); |
| 448 | 412 | ||
| 449 | /* Leave int_lock enabled */ |
413 | /* Leave int_lock enabled */ |
| 450 | /* This event does not sleep - debugging has finished in this thread */ |
414 | /* This event does not sleep - debugging has finished in this thread */ |
| 451 | } |
415 | } |
| Line 488... | Line 452... | ||
| 488 | * Make sure udebug.stop is true when going to sleep |
452 | * Make sure udebug.stop is true when going to sleep |
| 489 | * in case we get woken up by DEBUG_END. (At which |
453 | * in case we get woken up by DEBUG_END. (At which |
| 490 | * point it must be back to the initial true value). |
454 | * point it must be back to the initial true value). |
| 491 | */ |
455 | */ |
| 492 | THREAD->udebug.stop = true; |
456 | THREAD->udebug.stop = true; |
| 493 | - | ||
| 494 | THREAD->udebug.cur_event = etype; |
457 | THREAD->udebug.cur_event = etype; |
| 495 | mutex_unlock(&THREAD->udebug.lock); |
- | |
| 496 | 458 | ||
| 497 | klog_printf("- send answer"); |
459 | klog_printf("- send answer"); |
| 498 | - | ||
| 499 | ipc_answer(&TASK->answerbox, call); |
460 | ipc_answer(&TASK->answerbox, call); |
| - | 461 | ||
| - | 462 | mutex_unlock(&THREAD->udebug.lock); |
|
| 500 | mutex_unlock(&TASK->udebug.lock); |
463 | mutex_unlock(&TASK->udebug.lock); |
| 501 | 464 | ||
| 502 | udebug_wait_for_go(&THREAD->udebug.go_wq); |
465 | udebug_wait_for_go(&THREAD->udebug.go_wq); |
| 503 | 466 | ||
| 504 | udebug_int_unlock(); |
467 | udebug_int_unlock(); |
| Line 530... | Line 493... | ||
| 530 | klog_printf("udebug_task_cleanup()"); |
493 | klog_printf("udebug_task_cleanup()"); |
| 531 | klog_printf("task %llu", ta->taskid); |
494 | klog_printf("task %llu", ta->taskid); |
| 532 | 495 | ||
| 533 | udebug_int_lock(); |
496 | udebug_int_lock(); |
| 534 | 497 | ||
| 535 | if (ta->udebug.dt_state == UDEBUG_TS_BEGINNING && |
498 | if (ta->udebug.dt_state != UDEBUG_TS_BEGINNING && |
| 536 | ta->udebug.dt_state != UDEBUG_TS_ACTIVE) { |
499 | ta->udebug.dt_state != UDEBUG_TS_ACTIVE) { |
| 537 | klog_printf("udebug_task_cleanup(): task not being debugged"); |
500 | klog_printf("udebug_task_cleanup(): task not being debugged"); |
| 538 | return EINVAL; |
501 | return EINVAL; |
| 539 | } |
502 | } |
| 540 | 503 | ||