Rev 2810 | Rev 2813 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2810 | Rev 2812 | ||
|---|---|---|---|
| Line 360... | Line 360... | ||
| 360 | 360 | ||
| 361 | klog_printf("debug_go()"); |
361 | klog_printf("debug_go()"); |
| 362 | ta = get_lock_callee_task(phone); |
362 | ta = get_lock_callee_task(phone); |
| 363 | 363 | ||
| 364 | ta->debug_go_call = call; |
364 | ta->debug_go_call = call; |
| 365 | t = get_task_thread_by_id(ta, IPC_GET_ARG1(call->data)); |
365 | t = get_task_thread_by_id(ta, IPC_GET_ARG2(call->data)); |
| 366 | if (t == NULL) { |
366 | if (t == NULL) { |
| 367 | spinlock_unlock(&ta->lock); |
367 | spinlock_unlock(&ta->lock); |
| 368 | return ENOENT; |
368 | return ENOENT; |
| 369 | } |
369 | } |
| 370 | 370 | ||
| Line 387... | Line 387... | ||
| 387 | klog_printf("debug_args_read()"); |
387 | klog_printf("debug_args_read()"); |
| 388 | // FIXME: verify task/thread state |
388 | // FIXME: verify task/thread state |
| 389 | 389 | ||
| 390 | ta = get_lock_callee_task(phone); |
390 | ta = get_lock_callee_task(phone); |
| 391 | klog_printf("task %llu", ta->taskid); |
391 | klog_printf("task %llu", ta->taskid); |
| 392 | t = get_task_thread_by_id(ta, IPC_GET_ARG1(call->data)); |
392 | t = get_task_thread_by_id(ta, IPC_GET_ARG2(call->data)); |
| 393 | if (t == NULL) { |
393 | if (t == NULL) { |
| 394 | spinlock_unlock(&ta->lock); |
394 | spinlock_unlock(&ta->lock); |
| 395 | return ENOENT; |
395 | return ENOENT; |
| 396 | } |
396 | } |
| 397 | 397 | ||
| 398 | uspace_buffer = (void *)IPC_GET_ARG2(call->data); |
398 | uspace_buffer = (void *)IPC_GET_ARG3(call->data); |
| 399 | to_copy = IPC_GET_ARG3(call->data); |
399 | to_copy = IPC_GET_ARG4(call->data); |
| 400 | if (to_copy > 6 * sizeof(unative_t)) to_copy = 6 * sizeof(unative_t); |
400 | if (to_copy > 6 * sizeof(unative_t)) to_copy = 6 * sizeof(unative_t); |
| 401 | 401 | ||
| 402 | rc = copy_to_uspace(uspace_buffer, t->syscall_args, to_copy); |
402 | rc = copy_to_uspace(uspace_buffer, t->syscall_args, to_copy); |
| 403 | if (rc != 0) { |
403 | if (rc != 0) { |
| 404 | spinlock_unlock(&ta->lock); |
404 | spinlock_unlock(&ta->lock); |
| Line 430... | Line 430... | ||
| 430 | // FIXME: verify task/thread state |
430 | // FIXME: verify task/thread state |
| 431 | 431 | ||
| 432 | ta = get_lock_callee_task(phone); |
432 | ta = get_lock_callee_task(phone); |
| 433 | klog_printf("task %llu", ta->taskid); |
433 | klog_printf("task %llu", ta->taskid); |
| 434 | 434 | ||
| 435 | uspace_buffer = (void *)IPC_GET_ARG1(call->data); |
435 | uspace_buffer = (void *)IPC_GET_ARG2(call->data); |
| 436 | buf_size = IPC_GET_ARG2(call->data); |
436 | buf_size = IPC_GET_ARG3(call->data); |
| 437 | 437 | ||
| 438 | copied = total = 0; |
438 | copied = total = 0; |
| 439 | for (cur = ta->th_head.next; cur != &ta->th_head; cur = cur->next) { |
439 | for (cur = ta->th_head.next; cur != &ta->th_head; cur = cur->next) { |
| 440 | t = list_get_instance(cur, thread_t, th_link); |
440 | t = list_get_instance(cur, thread_t, th_link); |
| 441 | 441 | ||
| Line 471... | Line 471... | ||
| 471 | 471 | ||
| 472 | klog_printf("debug_thread_read() done"); |
472 | klog_printf("debug_thread_read() done"); |
| 473 | return 1; /* actually need becksend with retval 0 */ |
473 | return 1; /* actually need becksend with retval 0 */ |
| 474 | } |
474 | } |
| 475 | 475 | ||
| - | 476 | #include <udebug.h> |
|
| - | 477 | ||
| - | 478 | static int debug_request_preprocess(call_t *call, phone_t *phone) |
|
| - | 479 | { |
|
| - | 480 | int rc; |
|
| - | 481 | ||
| - | 482 | switch (IPC_GET_ARG1(call->data)) { |
|
| - | 483 | case UDEBUG_M_BEGIN: |
|
| - | 484 | rc = debug_begin(call, phone); |
|
| - | 485 | return rc; |
|
| - | 486 | case UDEBUG_M_GO: |
|
| - | 487 | rc = debug_go(call, phone); |
|
| - | 488 | return rc; |
|
| - | 489 | case UDEBUG_M_ARGS_READ: |
|
| - | 490 | rc = debug_args_read(call, phone); |
|
| - | 491 | return rc; |
|
| - | 492 | case UDEBUG_M_THREAD_READ: |
|
| - | 493 | rc = debug_thread_read(call, phone); |
|
| - | 494 | return rc; |
|
| - | 495 | default: |
|
| - | 496 | break; |
|
| - | 497 | } |
|
| - | 498 | ||
| - | 499 | return 0; |
|
| - | 500 | } |
|
| 476 | 501 | ||
| 477 | /** Called before the request is sent. |
502 | /** Called before the request is sent. |
| 478 | * |
503 | * |
| 479 | * @param call Call structure with the request. |
504 | * @param call Call structure with the request. |
| 480 | * @param phone Phone that the call will be sent through. |
505 | * @param phone Phone that the call will be sent through. |
| Line 521... | Line 546... | ||
| 521 | if (rc != 0) { |
546 | if (rc != 0) { |
| 522 | free(call->buffer); |
547 | free(call->buffer); |
| 523 | return rc; |
548 | return rc; |
| 524 | } |
549 | } |
| 525 | break; |
550 | break; |
| 526 | case IPC_M_DEBUG_BEGIN: |
551 | case IPC_M_DEBUG_ALL: |
| 527 | /* actually need possibility of backsend with 0 result code */ |
552 | /* actually need possibility of backsend with 0 result code */ |
| 528 | rc = debug_begin(call, phone); |
- | |
| 529 | return rc; |
- | |
| 530 | case IPC_M_DEBUG_GO: |
- | |
| 531 | rc = debug_go(call, phone); |
- | |
| 532 | return rc; |
- | |
| 533 | case IPC_M_DEBUG_ARGS_READ: |
- | |
| 534 | rc = debug_args_read(call, phone); |
- | |
| 535 | return rc; |
- | |
| 536 | case IPC_M_DEBUG_THREAD_READ: |
- | |
| 537 | rc = debug_thread_read(call, phone); |
553 | rc = debug_request_preprocess(call, phone); |
| 538 | return rc; |
554 | return rc; |
| 539 | default: |
555 | default: |
| 540 | break; |
556 | break; |
| 541 | } |
557 | } |
| 542 | return 0; |
558 | return 0; |
| Line 563... | Line 579... | ||
| 563 | IPC_SET_ARG5(call->data, call->priv); |
579 | IPC_SET_ARG5(call->data, call->priv); |
| 564 | } |
580 | } |
| 565 | 581 | ||
| 566 | if (call->buffer) { |
582 | if (call->buffer) { |
| 567 | /* This must be an affirmative answer to IPC_M_DATA_READ. */ |
583 | /* This must be an affirmative answer to IPC_M_DATA_READ. */ |
| 568 | /* or IPC_M_DEBUG_MEM_READ... */ |
584 | /* or IPC_M_DEBUG_ALL/UDEBUG_M_MEM_READ... */ |
| 569 | uintptr_t dst = IPC_GET_ARG1(call->data); |
585 | uintptr_t dst = IPC_GET_ARG1(call->data); |
| 570 | size_t size = IPC_GET_ARG2(call->data); |
586 | size_t size = IPC_GET_ARG2(call->data); |
| 571 | int rc = copy_to_uspace((void *) dst, call->buffer, size); |
587 | int rc = copy_to_uspace((void *) dst, call->buffer, size); |
| 572 | if (rc) |
588 | if (rc) |
| 573 | IPC_SET_RETVAL(call->data, rc); |
589 | IPC_SET_RETVAL(call->data, rc); |
| Line 596... | Line 612... | ||
| 596 | return -1; |
612 | return -1; |
| 597 | } |
613 | } |
| 598 | IPC_SET_ARG5(call->data, phoneid); |
614 | IPC_SET_ARG5(call->data, phoneid); |
| 599 | } |
615 | } |
| 600 | switch (IPC_GET_METHOD(call->data)) { |
616 | switch (IPC_GET_METHOD(call->data)) { |
| 601 | case IPC_M_DEBUG_BEGIN: |
- | |
| 602 | case IPC_M_DEBUG_END: |
617 | case IPC_M_DEBUG_ALL: |
| 603 | case IPC_M_DEBUG_GO: |
- | |
| 604 | case IPC_M_DEBUG_STOP: |
- | |
| 605 | case IPC_M_DEBUG_GUARD: |
- | |
| 606 | return -1; |
618 | return -1; |
| 607 | default: |
619 | default: |
| 608 | break; |
620 | break; |
| 609 | } |
621 | } |
| 610 | return 0; |
622 | return 0; |