Changeset 47e0a05b in mainline
- Timestamp:
- 2008-09-18T09:05:31Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4e5aa02
- Parents:
- 2c57ee14
- Location:
- uspace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/trace/trace.c
r2c57ee14 r47e0a05b 42 42 #include <udebug.h> 43 43 #include <async.h> 44 #include <task.h> 44 45 45 46 // Temporary: service and method names … … 129 130 printf("Threads:"); 130 131 for (i = 0; i < n_threads; i++) { 131 printf(" [%d] (hash 0x% u)", 1+i, thread_hash_buf[i]);132 printf(" [%d] (hash 0x%x)", 1+i, thread_hash_buf[i]); 132 133 } 133 134 printf("\ntotal of %u threads\n", tb_needed/sizeof(unsigned)); … … 541 542 static void print_syntax() 542 543 { 543 printf("Syntax: trace [+<events>] <task_id>\n"); 544 printf("Syntax:\n"); 545 printf("\ttrace [+<events>] <executable> [<arg1> [...]]\n"); 546 printf("or\ttrace [+<events>] -t <task_id>\n"); 544 547 printf("Events: (default is +tp)\n"); 545 548 printf("\n"); … … 549 552 printf("\tp ... Protocol level\n"); 550 553 printf("\n"); 551 printf("Example: trace +tsip 12\n"); 554 printf("Examples:\n"); 555 printf("\ttrace +s /app/tetris\n"); 556 printf("\ttrace +tsip -t 12\n"); 552 557 } 553 558 … … 581 586 char *err_p; 582 587 588 task_id = 0; 589 583 590 --argc; ++argv; 584 591 585 while (argc > 1) {592 while (argc > 0) { 586 593 arg = *argv; 587 594 if (arg[0] == '+') { 588 595 display_mask = parse_display_mask(&arg[1]); 596 } else if (arg[0] == '-') { 597 if (arg[1] == 't') { 598 /* Trace an already running task */ 599 --argc; ++argv; 600 task_id = strtol(*argv, &err_p, 10); 601 if (*err_p) { 602 printf("Task ID syntax error\n"); 603 print_syntax(); 604 return -1; 605 } 606 } else { 607 printf("Uknown option '%s'\n", arg[0]); 608 print_syntax(); 609 return -1; 610 } 589 611 } else { 590 printf("Unexpected argument '%s'\n", arg); 591 print_syntax(); 592 return -1; 612 break; 593 613 } 594 614 … … 596 616 } 597 617 598 if (argc != 1) { 618 if (task_id != 0) { 619 if (argc == 0) return; 620 printf("Extra arguments\n"); 621 print_syntax(); 622 return -1; 623 } 624 625 if (argc < 1) { 599 626 printf("Missing argument\n"); 600 627 print_syntax(); 601 return 1;602 }603 604 task_id = strtol(*argv, &err_p, 10);605 606 if (*err_p) {607 printf("Task ID syntax error\n");608 print_syntax();609 628 return -1; 610 629 } 630 631 /* Execute the specified command and trace the new task. */ 632 printf("Spawning '%s' with arguments:\n", *argv); 633 { 634 char **cp = argv; 635 while (*cp) printf("'%s'\n", *cp++); 636 } 637 task_id = task_spawn(*argv, argv); 611 638 612 639 return 0; -
uspace/lib/libc/generic/task.c
r2c57ee14 r47e0a05b 134 134 char *pa; 135 135 size_t pa_len; 136 task_id_t task_id; 136 137 137 138 pa = absolutize(path, &pa_len); … … 152 153 return 0; 153 154 155 /* Get task ID. */ 156 req = async_send_0(phone_id, LOADER_GET_TASKID, &answer); 157 rc = ipc_data_read_start(phone_id, &task_id, sizeof(task_id)); 158 if (rc != EOK) { 159 async_wait_for(req, NULL); 160 goto error; 161 } 162 163 async_wait_for(req, &retval); 164 if (retval != EOK) 165 goto error; 166 154 167 /* Send program pathname */ 155 168 req = async_send_0(phone_id, LOADER_SET_PATHNAME, &answer); … … 176 189 /* Success */ 177 190 ipc_hangup(phone_id); 178 return 1;191 return task_id; 179 192 180 193 /* Error exit */ -
uspace/lib/libc/include/ipc/loader.h
r2c57ee14 r47e0a05b 40 40 typedef enum { 41 41 LOADER_HELLO = IPC_FIRST_USER_METHOD, 42 LOADER_GET_TASKID, 42 43 LOADER_SET_PATHNAME, 43 44 LOADER_SET_ARGS, -
uspace/srv/loader/main.c
r2c57ee14 r47e0a05b 78 78 static char *arg_buf = NULL; 79 79 80 static int loader_get_taskid(ipc_callid_t rid, ipc_call_t *request) 81 { 82 ipc_callid_t callid; 83 task_id_t task_id; 84 size_t len; 85 86 task_id = task_get_id(); 87 88 if (!ipc_data_read_receive(&callid, &len)) { 89 ipc_answer_0(callid, EINVAL); 90 ipc_answer_0(rid, EINVAL); 91 return; 92 } 93 94 if (len > sizeof(task_id)) len = sizeof(task_id); 95 96 ipc_data_write_finalize(callid, &task_id, len); 97 ipc_answer_0(rid, EOK); 98 } 99 100 80 101 /** Receive a call setting pathname of the program to execute. 81 102 * … … 275 296 // call.in_phone_hash, IPC_GET_METHOD(call)); 276 297 switch (IPC_GET_METHOD(call)) { 298 case LOADER_GET_TASKID: 299 loader_get_taskid(callid, &call); 300 continue; 277 301 case LOADER_SET_PATHNAME: 278 302 loader_set_pathname(callid, &call);
Note:
See TracChangeset
for help on using the changeset viewer.