Changeset 1643855 in mainline
- Timestamp:
- 2008-09-17T18:04:01Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e028660
- Parents:
- 8c125ad
- Location:
- uspace/app/trace
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/trace/ipcp.c
r8c125ad r1643855 39 39 #include "ipc_desc.h" 40 40 #include "proto.h" 41 #include "trace.h" 41 42 #include "ipcp.h" 42 43 … … 178 179 proto_t *proto; 179 180 unsigned long key[1]; 181 oper_t *oper; 180 182 181 183 if (have_conn[phone]) proto = connections[phone].proto; 182 184 else proto = NULL; 183 185 184 // printf("ipcp_call_out()\n"); 185 printf("call id: 0x%x, phone: %d, proto: %s, method: ", hash, phone, 186 (proto ? proto->name : "n/a")); 187 ipc_m_print(proto, IPC_GET_METHOD(*call)); 188 printf(" args: (%u, %u, %u, %u, %u)\n", 189 IPC_GET_ARG1(*call), 190 IPC_GET_ARG2(*call), 191 IPC_GET_ARG3(*call), 192 IPC_GET_ARG4(*call), 193 IPC_GET_ARG5(*call) 194 ); 186 if ((display_mask & DM_IPC) != 0) { 187 printf("Call ID: 0x%x, phone: %d, proto: %s, method: ", hash, 188 phone, (proto ? proto->name : "n/a")); 189 ipc_m_print(proto, IPC_GET_METHOD(*call)); 190 printf(" args: (%u, %u, %u, %u, %u)\n", 191 IPC_GET_ARG1(*call), 192 IPC_GET_ARG2(*call), 193 IPC_GET_ARG3(*call), 194 IPC_GET_ARG4(*call), 195 IPC_GET_ARG5(*call) 196 ); 197 } 198 199 200 if ((display_mask & DM_USER) != 0) { 201 202 if (proto != NULL) { 203 oper = proto_get_oper(proto, IPC_GET_METHOD(*call)); 204 } else { 205 oper = NULL; 206 } 207 208 if (oper != NULL) { 209 210 printf("%s(%d).%s", (proto ? proto->name : "n/a"), 211 phone, (oper ? oper->name : "unknown")); 212 213 printf("(%u, %u, %u, %u, %u)\n", 214 IPC_GET_ARG1(*call), 215 IPC_GET_ARG2(*call), 216 IPC_GET_ARG3(*call), 217 IPC_GET_ARG4(*call), 218 IPC_GET_ARG5(*call) 219 ); 220 } 221 } 195 222 196 223 /* Store call in hash table for response matching */ … … 206 233 } 207 234 208 static void parse_answer(pending_call_t *pcall, ipc_call_t *answer) 235 static void parse_answer(ipc_callid_t hash, pending_call_t *pcall, 236 ipc_call_t *answer) 209 237 { 210 238 int phone; … … 220 248 method = IPC_GET_METHOD(pcall->question); 221 249 retval = IPC_GET_RETVAL(*answer); 222 printf("phone=%d, method=%d, retval=%d\n", 223 phone, method, retval); 250 251 if ((display_mask & DM_IPC) != 0) { 252 printf("Response to 0x%x: retval=%d, args = (%u, %u, %u, %u, %u)\n", 253 hash, retval, IPC_GET_ARG1(*answer), 254 IPC_GET_ARG2(*answer), IPC_GET_ARG3(*answer), 255 IPC_GET_ARG4(*answer), IPC_GET_ARG5(*answer)); 256 } 257 258 if ((display_mask & DM_USER) != 0) { 259 printf("-> %d\n", retval); 260 } 224 261 225 262 if (phone == 0 && method == IPC_M_CONNECT_ME_TO && retval == 0) { … … 230 267 231 268 cphone = IPC_GET_ARG5(*answer); 232 printf("registering connection (phone %d, protocol: %s)\n", cphone, 233 proto->name); 269 if ((display_mask & DM_SYSTEM) != 0) { 270 printf("Registering connection (phone %d, protocol: %s)\n", cphone, 271 proto->name); 272 } 234 273 ipcp_connection_set(cphone, 0, proto); 235 274 } … … 255 294 if ((hash & IPC_CALLID_ANSWERED) == 0 && hash != IPCP_CALLID_SYNC) { 256 295 /* Not a response */ 257 printf("Not a response (hash %d)\n", hash); 296 if ((display_mask & DM_IPC) != 0) { 297 printf("Not a response (hash %d)\n", hash); 298 } 258 299 return; 259 300 } … … 264 305 item = hash_table_find(&pending_calls, key); 265 306 if (item == NULL) return; // No matching question found 307 308 /* 309 * Response matched to question. 310 */ 266 311 267 312 pcall = hash_table_get_instance(item, pending_call_t, link); 268 269 printf("response matched to question\n");270 313 hash_table_remove(&pending_calls, key, 1); 271 314 272 parse_answer( pcall, call);315 parse_answer(hash, pcall, call); 273 316 free(pcall); 274 317 } … … 282 325 void ipcp_hangup(int phone, int rc) 283 326 { 284 printf("hangup phone %d -> %d\n", phone, rc); 285 ipcp_connection_clear(phone); 327 if ((display_mask & DM_SYSTEM) != 0) { 328 printf("Hang phone %d up -> %d\n", phone, rc); 329 ipcp_connection_clear(phone); 330 } 286 331 } 287 332 -
uspace/app/trace/trace.c
r8c125ad r1643855 52 52 #include "ipcp.h" 53 53 #include "errors.h" 54 #include "trace.h" 54 55 55 56 #define THBUF_SIZE 64 … … 68 69 69 70 static proto_t *proto_console; 71 static task_id_t task_id; 72 73 /** Combination of events/data to print. */ 74 display_mask_t display_mask; 70 75 71 76 static int task_connect(task_id_t task_id) … … 287 292 } 288 293 289 /* Print syscall name, id and arguments */ 290 printf("%s", syscall_desc[sc_id].name); 291 print_sc_args(sc_args, syscall_desc[sc_id].n_args); 294 if ((display_mask & DM_SYSCALL) != 0) { 295 /* Print syscall name and arguments */ 296 printf("%s", syscall_desc[sc_id].name); 297 print_sc_args(sc_args, syscall_desc[sc_id].n_args); 298 } 292 299 293 300 async_serialize_end(); … … 313 320 } 314 321 315 rv_type = syscall_desc[sc_id].rv_type; 316 print_sc_retval(sc_rc, rv_type); 322 if ((display_mask & DM_SYSCALL) != 0) { 323 /* Print syscall return value */ 324 rv_type = syscall_desc[sc_id].rv_type; 325 print_sc_retval(sc_rc, rv_type); 326 } 317 327 318 328 switch (sc_id) { … … 429 439 int c; 430 440 431 printf("Syscall Tracer\n");432 433 441 rc = task_connect(task_id); 434 442 if (rc < 0) { … … 533 541 static void print_syntax() 534 542 { 535 printf("Syntax: trace <task_id>\n"); 536 } 537 538 int main(int argc, char *argv[]) 539 { 540 task_id_t task_id; 543 printf("Syntax: trace [+<events>] <task_id>\n"); 544 printf("Events: (default is +tp)\n"); 545 printf("\n"); 546 printf("\tt ... Thread creation and termination\n"); 547 printf("\ts ... System calls\n"); 548 printf("\ti ... Low-level IPC\n"); 549 printf("\tp ... Protocol level\n"); 550 printf("\n"); 551 printf("Example: trace +tsip 12\n"); 552 } 553 554 static display_mask_t parse_display_mask(char *text) 555 { 556 display_mask_t dm; 557 char *c; 558 559 c = text; 560 561 while (*c) { 562 switch (*c) { 563 case 't': dm = dm | DM_THREAD; break; 564 case 's': dm = dm | DM_SYSCALL; break; 565 case 'i': dm = dm | DM_IPC; break; 566 case 'p': dm = dm | DM_SYSTEM | DM_USER; break; 567 default: 568 printf("Unexpected event type '%c'\n", *c); 569 exit(1); 570 } 571 572 ++c; 573 } 574 575 return dm; 576 } 577 578 static int parse_args(int argc, char *argv[]) 579 { 580 char *arg; 541 581 char *err_p; 542 582 543 if (argc != 2) { 544 printf("Mising argument\n"); 583 --argc; ++argv; 584 585 while (argc > 1) { 586 arg = *argv; 587 if (arg[0] == '+') { 588 display_mask = parse_display_mask(&arg[1]); 589 } else { 590 printf("Unexpected argument '%s'\n", arg); 591 print_syntax(); 592 return -1; 593 } 594 595 --argc; ++argv; 596 } 597 598 if (argc != 1) { 599 printf("Missing argument\n"); 545 600 print_syntax(); 546 601 return 1; 547 602 } 548 603 549 task_id = strtol( argv[1], &err_p, 10);604 task_id = strtol(*argv, &err_p, 10); 550 605 551 606 if (*err_p) { 552 607 printf("Task ID syntax error\n"); 553 608 print_syntax(); 609 return -1; 610 } 611 612 return 0; 613 } 614 615 int main(int argc, char *argv[]) 616 { 617 printf("System Call / IPC Tracer\n"); 618 619 display_mask = DM_THREAD | DM_SYSTEM | DM_USER; 620 621 if (parse_args(argc, argv) < 0) 554 622 return 1; 555 }556 623 557 624 main_init(); 558 625 trace_active_task(task_id); 626 627 return 0; 559 628 } 560 629
Note:
See TracChangeset
for help on using the changeset viewer.