Rev 2866 | Rev 2885 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2866 | Rev 2870 | ||
|---|---|---|---|
| Line 187... | Line 187... | ||
| 187 | return EBUSY; |
187 | return EBUSY; |
| 188 | } |
188 | } |
| 189 | 189 | ||
| 190 | ta->dt_state = UDEBUG_TS_BEGINNING; |
190 | ta->dt_state = UDEBUG_TS_BEGINNING; |
| 191 | ta->debug_begin_call = call; |
191 | ta->debug_begin_call = call; |
| - | 192 | ta->debugger = call->sender; |
|
| 192 | 193 | ||
| 193 | if (ta->not_stoppable_count == 0) { |
194 | if (ta->not_stoppable_count == 0) { |
| 194 | ta->dt_state = UDEBUG_TS_ACTIVE; |
195 | ta->dt_state = UDEBUG_TS_ACTIVE; |
| 195 | ta->debug_begin_call = NULL; |
196 | ta->debug_begin_call = NULL; |
| 196 | rc = 1; /* actually we need backsend with 0 retval */ |
197 | rc = 1; /* actually we need backsend with 0 retval */ |
| Line 220... | Line 221... | ||
| 220 | 221 | ||
| 221 | static int udebug_rp_end(call_t *call, phone_t *phone) |
222 | static int udebug_rp_end(call_t *call, phone_t *phone) |
| 222 | { |
223 | { |
| 223 | task_t *ta; |
224 | task_t *ta; |
| 224 | ipl_t ipl; |
225 | ipl_t ipl; |
| 225 | - | ||
| 226 | thread_t *t; |
- | |
| 227 | link_t *cur; |
- | |
| 228 | int flags; |
226 | int rc; |
| 229 | 227 | ||
| 230 | klog_printf("udebug_rp_end()"); |
228 | klog_printf("udebug_rp_end()"); |
| 231 | 229 | ||
| 232 | ipl = interrupts_disable(); |
230 | ipl = interrupts_disable(); |
| 233 | ta = get_lock_callee_task(phone); |
231 | ta = get_lock_callee_task(phone); |
| 234 | klog_printf("task %llu", ta->taskid); |
- | |
| 235 | - | ||
| 236 | if (ta->dt_state == UDEBUG_TS_BEGINNING && |
- | |
| 237 | ta->dt_state != UDEBUG_TS_ACTIVE) { |
- | |
| 238 | spinlock_unlock(&ta->lock); |
- | |
| 239 | interrupts_restore(ipl); |
- | |
| 240 | klog_printf("udebug_rp_begin(): task not being debugged"); |
- | |
| 241 | return EINVAL; |
- | |
| 242 | } |
- | |
| 243 | - | ||
| 244 | /* Finish debugging of all userspace threads */ |
- | |
| 245 | for (cur = ta->th_head.next; cur != &ta->th_head; cur = cur->next) { |
- | |
| 246 | t = list_get_instance(cur, thread_t, th_link); |
- | |
| 247 | - | ||
| 248 | spinlock_lock(&t->debug_lock); |
- | |
| 249 | spinlock_lock(&t->lock); |
- | |
| 250 | - | ||
| 251 | flags = t->flags; |
- | |
| 252 | - | ||
| 253 | spinlock_unlock(&t->lock); |
- | |
| 254 | 232 | ||
| 255 | /* Only process userspace threads */ |
- | |
| 256 | if ((flags & THREAD_FLAG_USPACE) != 0) { |
- | |
| 257 | /* Prevent any further debug activity in thread */ |
- | |
| 258 | t->debug_active = false; |
233 | rc = udebug_task_cleanup(ta); |
| 259 | t->cur_event = 0; /* none */ |
- | |
| 260 | - | ||
| 261 | /* Still has go? */ |
- | |
| 262 | if (t->debug_stop == false) { |
- | |
| 263 | /* |
- | |
| 264 | * Yes, so clear go. As debug_active == false, |
- | |
| 265 | * this doesn't affect anything. |
- | |
| 266 | */ |
- | |
| 267 | t->debug_stop = true; |
- | |
| 268 | - | ||
| 269 | /* Answer GO call */ |
- | |
| 270 | klog_printf("answer GO call with EVENT_FINISHED"); |
- | |
| 271 | IPC_SET_RETVAL(t->debug_go_call->data, 0); |
- | |
| 272 | IPC_SET_ARG1(t->debug_go_call->data, UDEBUG_EVENT_FINISHED); |
- | |
| 273 | ipc_answer(&ta->answerbox, t->debug_go_call); |
- | |
| 274 | } else { |
- | |
| 275 | /* |
- | |
| 276 | * Debug_stop is already at initial value. |
- | |
| 277 | * Yet this means the thread needs waking up. |
- | |
| 278 | */ |
- | |
| 279 | - | ||
| 280 | /* |
- | |
| 281 | * t's lock must not be held when calling |
- | |
| 282 | * waitq_wakeup. |
- | |
| 283 | */ |
- | |
| 284 | waitq_wakeup(&t->go_wq, WAKEUP_FIRST); |
- | |
| 285 | } |
- | |
| 286 | } |
- | |
| 287 | spinlock_unlock(&t->debug_lock); |
- | |
| 288 | } |
- | |
| 289 | 234 | ||
| 290 | ta->dt_state = UDEBUG_TS_INACTIVE; |
235 | klog_printf("task %llu", ta->taskid); |
| 291 | 236 | ||
| 292 | spinlock_unlock(&ta->lock); |
237 | spinlock_unlock(&ta->lock); |
| 293 | interrupts_restore(ipl); |
238 | interrupts_restore(ipl); |
| 294 | 239 | ||
| - | 240 | if (rc < 0) { |
|
| - | 241 | return EINVAL; |
|
| - | 242 | } |
|
| - | 243 | ||
| 295 | IPC_SET_RETVAL(call->data, 0); |
244 | IPC_SET_RETVAL(call->data, 0); |
| 296 | 245 | ||
| 297 | klog_printf("udebug_rp_end() done\n"); |
246 | klog_printf("udebug_rp_end() done\n"); |
| 298 | 247 | ||
| 299 | return 1; |
248 | return 1; |