Changes in uspace/app/trace/trace.c [7c014d1:28a3e74] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/trace/trace.c
r7c014d1 r28a3e74 50 50 #include <sys/types.h> 51 51 #include <sys/typefmt.h> 52 #include <vfs/vfs.h>53 52 54 53 #include <libc.h> … … 73 72 ipc_call_t thread_ipc_req[THBUF_SIZE]; 74 73 75 async_sess_t *sess;74 int phoneid; 76 75 bool abort_trace; 77 76 … … 82 81 83 82 static bool cev_valid; 84 static kbd_event_t cev;83 static console_event_t cev; 85 84 86 85 void thread_trace_start(uintptr_t thread_hash); 87 86 87 static proto_t *proto_console; 88 88 static task_id_t task_id; 89 89 static loader_t *task_ldr; … … 146 146 static int connect_task(task_id_t task_id) 147 147 { 148 async_sess_t *ksess = async_connect_kbox(task_id); 149 150 if (!ksess) { 151 if (errno == ENOTSUP) { 152 printf("You do not have userspace debugging support " 153 "compiled in the kernel.\n"); 154 printf("Compile kernel with 'Support for userspace debuggers' " 155 "(CONFIG_UDEBUG) enabled.\n"); 156 return errno; 157 } 158 148 int rc; 149 150 rc = async_connect_kbox(task_id); 151 152 if (rc == ENOTSUP) { 153 printf("You do not have userspace debugging support " 154 "compiled in the kernel.\n"); 155 printf("Compile kernel with 'Support for userspace debuggers' " 156 "(CONFIG_UDEBUG) enabled.\n"); 157 return rc; 158 } 159 160 if (rc < 0) { 159 161 printf("Error connecting\n"); 160 printf("ipc_connect_task(%" PRIu64 ") -> %d ", task_id, errno); 161 return errno; 162 } 163 164 int rc = udebug_begin(ksess); 162 printf("ipc_connect_task(%" PRIu64 ") -> %d ", task_id, rc); 163 return rc; 164 } 165 166 phoneid = rc; 167 168 rc = udebug_begin(phoneid); 165 169 if (rc < 0) { 166 170 printf("udebug_begin() -> %d\n", rc); 167 171 return rc; 168 172 } 169 170 rc = udebug_set_evmask( ksess, UDEBUG_EM_ALL);173 174 rc = udebug_set_evmask(phoneid, UDEBUG_EM_ALL); 171 175 if (rc < 0) { 172 176 printf("udebug_set_evmask(0x%x) -> %d\n ", UDEBUG_EM_ALL, rc); 173 177 return rc; 174 178 } 175 176 sess = ksess; 179 177 180 return 0; 178 181 } … … 185 188 int i; 186 189 187 rc = udebug_thread_read( sess, thread_hash_buf,190 rc = udebug_thread_read(phoneid, thread_hash_buf, 188 191 THBUF_SIZE*sizeof(unsigned), &tb_copied, &tb_needed); 189 192 if (rc < 0) { … … 311 314 312 315 memset(&call, 0, sizeof(call)); 313 rc = udebug_mem_read( sess, &call.args, sc_args[1], sizeof(call.args));316 rc = udebug_mem_read(phoneid, &call.args, sc_args[1], sizeof(call.args)); 314 317 315 318 if (rc >= 0) { … … 322 325 ipc_call_t question, reply; 323 326 int rc; 324 int phoneid; 325 326 phoneid = sc_args[0]; 327 int phoneidx; 328 329 // printf("sc_ipc_call_sync_fast()\n"); 330 phoneidx = sc_args[0]; 327 331 328 332 IPC_SET_IMETHOD(question, sc_args[1]); … … 333 337 IPC_SET_ARG5(question, 0); 334 338 339 // printf("memset\n"); 335 340 memset(&reply, 0, sizeof(reply)); 336 rc = udebug_mem_read(sess, &reply.args, sc_args[5], sizeof(reply.args)); 337 if (rc < 0) 338 return; 339 340 ipcp_call_sync(phoneid, &question, &reply); 341 // printf("udebug_mem_read(phone=%d, buffer_ptr=%u, src_addr=%d, n=%d\n", 342 // phoneid, &reply.args, sc_args[5], sizeof(reply.args)); 343 rc = udebug_mem_read(phoneid, &reply.args, sc_args[5], sizeof(reply.args)); 344 // printf("dmr->%d\n", rc); 345 if (rc < 0) return; 346 347 // printf("call ipc_call_sync\n"); 348 ipcp_call_sync(phoneidx, &question, &reply); 341 349 } 342 350 … … 347 355 348 356 memset(&question, 0, sizeof(question)); 349 rc = udebug_mem_read( sess, &question.args, sc_args[1],357 rc = udebug_mem_read(phoneid, &question.args, sc_args[1], 350 358 sizeof(question.args)); 351 359 … … 364 372 365 373 memset(&reply, 0, sizeof(reply)); 366 rc = udebug_mem_read( sess, &reply.args, sc_args[2],374 rc = udebug_mem_read(phoneid, &reply.args, sc_args[2], 367 375 sizeof(reply.args)); 368 376 … … 383 391 384 392 memset(&call, 0, sizeof(call)); 385 rc = udebug_mem_read(sess, &call, sc_args[0], sizeof(call)); 386 387 if (rc >= 0) 393 rc = udebug_mem_read(phoneid, &call, sc_args[0], sizeof(call)); 394 // printf("udebug_mem_read(phone %d, dest %d, app-mem src %d, size %d -> %d\n", 395 // phoneid, (int)&call, sc_args[0], sizeof(call), rc); 396 397 if (rc >= 0) { 388 398 ipcp_call_in(&call, sc_rc); 399 } 389 400 } 390 401 … … 396 407 397 408 /* Read syscall arguments */ 398 rc = udebug_args_read(sess, thread_hash, sc_args); 409 rc = udebug_args_read(phoneid, thread_hash, sc_args); 410 411 async_serialize_start(); 412 413 // printf("[%d] ", thread_id); 399 414 400 415 if (rc < 0) { 401 416 printf("error\n"); 417 async_serialize_end(); 402 418 return; 403 419 } … … 416 432 break; 417 433 } 434 435 async_serialize_end(); 418 436 } 419 437 … … 426 444 427 445 /* Read syscall arguments */ 428 rc = udebug_args_read(sess, thread_hash, sc_args); 446 rc = udebug_args_read(phoneid, thread_hash, sc_args); 447 448 async_serialize_start(); 429 449 430 450 // printf("[%d] ", thread_id); … … 432 452 if (rc < 0) { 433 453 printf("error\n"); 454 async_serialize_end(); 434 455 return; 435 456 } … … 460 481 break; 461 482 } 483 484 async_serialize_end(); 462 485 } 463 486 464 487 static void event_thread_b(uintptr_t hash) 465 488 { 489 async_serialize_start(); 466 490 printf("New thread, hash %p\n", (void *) hash); 491 async_serialize_end(); 492 467 493 thread_trace_start(hash); 468 494 } … … 501 527 502 528 /* Run thread until an event occurs */ 503 rc = udebug_go( sess, thread_hash,529 rc = udebug_go(phoneid, thread_hash, 504 530 &ev_type, &val0, &val1); 505 531 … … 586 612 587 613 /* Send default files */ 588 int *files[4];589 int fd_stdin;590 int fd_stdout;591 int fd_stderr;614 fdi_node_t *files[4]; 615 fdi_node_t stdin_node; 616 fdi_node_t stdout_node; 617 fdi_node_t stderr_node; 592 618 593 if ((stdin != NULL) && (f handle(stdin, &fd_stdin) == EOK))594 files[0] = & fd_stdin;619 if ((stdin != NULL) && (fnode(stdin, &stdin_node) == EOK)) 620 files[0] = &stdin_node; 595 621 else 596 622 files[0] = NULL; 597 623 598 if ((stdout != NULL) && (f handle(stdout, &fd_stdout) == EOK))599 files[1] = & fd_stdout;624 if ((stdout != NULL) && (fnode(stdout, &stdout_node) == EOK)) 625 files[1] = &stdout_node; 600 626 else 601 627 files[1] = NULL; 602 628 603 if ((stderr != NULL) && (f handle(stderr, &fd_stderr) == EOK))604 files[2] = & fd_stderr;629 if ((stderr != NULL) && (fnode(stderr, &stderr_node) == EOK)) 630 files[2] = &stderr_node; 605 631 else 606 632 files[2] = NULL; … … 630 656 { 631 657 (void) arg; 632 633 console_ctrl_t *console = console_init(stdin, stdout); 634 658 635 659 while (true) { 636 660 fibril_mutex_lock(&state_lock); … … 638 662 fibril_condvar_wait(&state_cv, &state_lock); 639 663 fibril_mutex_unlock(&state_lock); 640 641 if (!console_get_ kbd_event(console, &cev))664 665 if (!console_get_event(fphone(stdin), &cev)) 642 666 return -1; 643 667 644 668 fibril_mutex_lock(&state_lock); 645 669 cev_valid = true; 646 670 fibril_condvar_broadcast(&state_cv); 647 fibril_mutex_unlock(&state_lock); 671 fibril_mutex_unlock(&state_lock); 648 672 } 649 673 } … … 651 675 static void trace_task(task_id_t task_id) 652 676 { 653 kbd_event_t ev;677 console_event_t ev; 654 678 bool done; 655 679 int i; … … 657 681 658 682 ipcp_init(); 683 684 /* 685 * User apps now typically have console on phone 3. 686 * (Phones 1 and 2 are used by the loader). 687 */ 688 ipcp_connection_set(3, 0, proto_console); 659 689 660 690 rc = get_thread_list(); … … 697 727 case KC_P: 698 728 printf("Pause...\n"); 699 rc = udebug_stop( sess, thash);729 rc = udebug_stop(phoneid, thash); 700 730 if (rc != EOK) 701 731 printf("Error: stop -> %d\n", rc); … … 708 738 printf("Resume...\n"); 709 739 break; 710 default:711 break;712 740 } 713 741 } … … 715 743 printf("\nTerminate debugging session...\n"); 716 744 abort_trace = true; 717 udebug_end( sess);718 async_hangup( sess);745 udebug_end(phoneid); 746 async_hangup(phoneid); 719 747 720 748 ipcp_cleanup(); … … 757 785 o = oper_new("open", 2, arg_def, V_INT_ERRNO, 0, resp_def); 758 786 proto_add_oper(p, VFS_IN_OPEN, o); 787 o = oper_new("open_node", 4, arg_def, V_INT_ERRNO, 0, resp_def); 788 proto_add_oper(p, VFS_IN_OPEN_NODE, o); 759 789 o = oper_new("read", 1, arg_def, V_ERRNO, 1, resp_def); 760 790 proto_add_oper(p, VFS_IN_READ, o); … … 785 815 786 816 proto_register(SERVICE_VFS, p); 817 818 p = proto_new("console"); 819 820 o = oper_new("write", 1, arg_def, V_ERRNO, 1, resp_def); 821 proto_add_oper(p, VFS_IN_WRITE, o); 822 823 resp_def[0] = V_INTEGER; resp_def[1] = V_INTEGER; 824 resp_def[2] = V_INTEGER; resp_def[3] = V_CHAR; 825 o = oper_new("getkey", 0, arg_def, V_ERRNO, 4, resp_def); 826 827 arg_def[0] = V_CHAR; 828 o = oper_new("clear", 0, arg_def, V_VOID, 0, resp_def); 829 proto_add_oper(p, CONSOLE_CLEAR, o); 830 831 arg_def[0] = V_INTEGER; arg_def[1] = V_INTEGER; 832 o = oper_new("goto", 2, arg_def, V_VOID, 0, resp_def); 833 proto_add_oper(p, CONSOLE_GOTO, o); 834 835 resp_def[0] = V_INTEGER; resp_def[1] = V_INTEGER; 836 o = oper_new("getsize", 0, arg_def, V_INTEGER, 2, resp_def); 837 proto_add_oper(p, CONSOLE_GET_SIZE, o); 838 839 arg_def[0] = V_INTEGER; 840 o = oper_new("set_style", 1, arg_def, V_VOID, 0, resp_def); 841 proto_add_oper(p, CONSOLE_SET_STYLE, o); 842 arg_def[0] = V_INTEGER; arg_def[1] = V_INTEGER; arg_def[2] = V_INTEGER; 843 o = oper_new("set_color", 3, arg_def, V_VOID, 0, resp_def); 844 proto_add_oper(p, CONSOLE_SET_COLOR, o); 845 arg_def[0] = V_INTEGER; arg_def[1] = V_INTEGER; 846 o = oper_new("set_rgb_color", 2, arg_def, V_VOID, 0, resp_def); 847 proto_add_oper(p, CONSOLE_SET_RGB_COLOR, o); 848 o = oper_new("cursor_visibility", 1, arg_def, V_VOID, 0, resp_def); 849 proto_add_oper(p, CONSOLE_CURSOR_VISIBILITY, o); 850 851 proto_console = p; 852 proto_register(SERVICE_CONSOLE, p); 787 853 } 788 854
Note:
See TracChangeset
for help on using the changeset viewer.