Changeset 79ae36dd in mainline for uspace/app/trace
- Timestamp:
- 2011-06-08T19:01:55Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0eff68e
- Parents:
- 764d71e
- Location:
- uspace/app/trace
- Files:
-
- 4 edited
-
ipc_desc.c (modified) (2 diffs)
-
ipcp.c (modified) (7 diffs)
-
syscalls.c (modified) (1 diff)
-
trace.c (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/trace/ipc_desc.c
r764d71e r79ae36dd 33 33 */ 34 34 35 #include <ipc/common.h> 35 #include <kernel/ipc/ipc.h> 36 #include <kernel/ipc/ipc_methods.h> 36 37 #include <stdlib.h> 37 38 #include "ipc_desc.h" … … 39 40 ipc_m_desc_t ipc_methods[] = { 40 41 /* System methods */ 41 { IPC_M_CONNECT_TO_ME, "CONNECT_TO_ME" }, 42 { IPC_M_CONNECT_ME_TO, "CONNECT_ME_TO" }, 43 { IPC_M_PHONE_HUNGUP, "PHONE_HUNGUP" }, 44 { IPC_M_SHARE_OUT, "SHARE_OUT" }, 45 { IPC_M_SHARE_IN, "SHARE_IN" }, 46 { IPC_M_DATA_WRITE, "DATA_WRITE" }, 47 { IPC_M_DATA_READ, "DATA_READ" }, 48 { IPC_M_DEBUG_ALL, "DEBUG_ALL" }, 49 50 /* Well-known methods */ 51 { IPC_M_PING, "PING" }, 52 42 { IPC_M_PHONE_HUNGUP, "PHONE_HUNGUP" }, 43 { IPC_M_CONNECT_ME, "CONNECT_ME" }, 44 { IPC_M_CONNECT_ME_TO, "CONNECT_ME_TO" }, 45 { IPC_M_CONNECT_TO_ME, "CONNECT_TO_ME" }, 46 { IPC_M_SHARE_OUT, "SHARE_OUT" }, 47 { IPC_M_SHARE_IN, "SHARE_IN" }, 48 { IPC_M_DATA_WRITE, "DATA_WRITE" }, 49 { IPC_M_DATA_READ, "DATA_READ" }, 50 { IPC_M_DEBUG, "DEBUG" }, 51 53 52 /* Terminating entry */ 54 53 { 0, NULL } -
uspace/app/trace/ipcp.c
r764d71e r79ae36dd 37 37 #include <adt/hash_table.h> 38 38 #include <sys/typefmt.h> 39 39 #include <kernel/ipc/ipc_methods.h> 40 40 #include "ipc_desc.h" 41 41 #include "proto.h" … … 268 268 proto_t *proto; 269 269 int cphone; 270 270 271 271 sysarg_t *resp; 272 272 oper_t *oper; 273 273 int i; 274 275 // printf("parse_answer\n"); 276 274 277 275 phone = pcall->phone_hash; 278 276 method = IPC_GET_IMETHOD(pcall->question); 279 277 retval = IPC_GET_RETVAL(*answer); 280 278 281 279 resp = answer->args; 282 280 283 281 if ((display_mask & DM_IPC) != 0) { 284 282 printf("Response to %p: retval=%" PRIdn ", args = (%" PRIun ", " … … 288 286 IPC_GET_ARG4(*answer), IPC_GET_ARG5(*answer)); 289 287 } 290 288 291 289 if ((display_mask & DM_USER) != 0) { 292 290 oper = pcall->oper; 293 294 if (oper != NULL && (oper->rv_type != V_VOID || oper->respc > 0)) { 291 292 if ((oper != NULL) && 293 ((oper->rv_type != V_VOID) || (oper->respc > 0))) { 295 294 printf("->"); 296 295 297 296 if (oper->rv_type != V_VOID) { 298 297 putchar(' '); … … 304 303 putchar('('); 305 304 for (i = 1; i <= oper->respc; ++i) { 306 if (i > 1) printf(", "); 305 if (i > 1) 306 printf(", "); 307 307 val_print(resp[i], oper->resp_type[i - 1]); 308 308 } 309 309 putchar(')'); 310 310 } 311 311 312 312 putchar('\n'); 313 313 } 314 314 } 315 316 if (phone == 0 && method == IPC_M_CONNECT_ME_TO && retval == 0) { 315 316 if ((phone == PHONE_NS) && (method == IPC_M_CONNECT_ME_TO) && 317 (retval == 0)) { 317 318 /* Connected to a service (through NS) */ 318 319 service = IPC_GET_ARG1(pcall->question); 319 320 proto = proto_get_by_srv(service); 320 if (proto == NULL) proto = proto_unknown; 321 321 if (proto == NULL) 322 proto = proto_unknown; 323 322 324 cphone = IPC_GET_ARG5(*answer); 323 325 if ((display_mask & DM_SYSTEM) != 0) { 324 326 printf("Registering connection (phone %d, protocol: %s)\n", cphone, 325 proto->name); 326 } 327 proto->name); 328 } 329 327 330 ipcp_connection_set(cphone, 0, proto); 328 331 } … … 334 337 pending_call_t *pcall; 335 338 unsigned long key[1]; 336 337 // printf("ipcp_call_in()\n"); 338 339 339 340 if ((hash & IPC_CALLID_ANSWERED) == 0 && hash != IPCP_CALLID_SYNC) { 340 341 /* Not a response */ … … 344 345 return; 345 346 } 346 347 347 348 hash = hash & ~IPC_CALLID_ANSWERED; 348 349 key[0] = hash; 349 350 350 351 item = hash_table_find(&pending_calls, key); 351 if (item == NULL) return; // No matching question found 352 352 if (item == NULL) 353 return; /* No matching question found */ 354 353 355 /* 354 356 * Response matched to question. … … 357 359 pcall = hash_table_get_instance(item, pending_call_t, link); 358 360 hash_table_remove(&pending_calls, key, 1); 359 361 360 362 parse_answer(hash, pcall, call); 361 363 free(pcall); -
uspace/app/trace/syscalls.c
r764d71e r79ae36dd 40 40 [SYS_KLOG] ={ "klog", 3, V_INT_ERRNO }, 41 41 [SYS_TLS_SET] = { "tls_set", 1, V_ERRNO }, 42 42 43 [SYS_THREAD_CREATE] = { "thread_create", 3, V_ERRNO }, 43 44 [SYS_THREAD_EXIT] = { "thread_exit", 1, V_ERRNO }, -
uspace/app/trace/trace.c
r764d71e r79ae36dd 72 72 ipc_call_t thread_ipc_req[THBUF_SIZE]; 73 73 74 int phoneid;74 async_sess_t *sess; 75 75 bool abort_trace; 76 76 … … 81 81 82 82 static bool cev_valid; 83 static console_event_t cev;83 static kbd_event_t cev; 84 84 85 85 void thread_trace_start(uintptr_t thread_hash); … … 146 146 static int connect_task(task_id_t task_id) 147 147 { 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) { 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 161 159 printf("Error connecting\n"); 162 printf("ipc_connect_task(%" PRIu64 ") -> %d ", task_id, rc); 163 return rc; 164 } 165 166 phoneid = rc; 167 168 rc = udebug_begin(phoneid); 160 printf("ipc_connect_task(%" PRIu64 ") -> %d ", task_id, errno); 161 return errno; 162 } 163 164 int rc = udebug_begin(ksess); 169 165 if (rc < 0) { 170 166 printf("udebug_begin() -> %d\n", rc); 171 167 return rc; 172 168 } 173 174 rc = udebug_set_evmask( phoneid, UDEBUG_EM_ALL);169 170 rc = udebug_set_evmask(ksess, UDEBUG_EM_ALL); 175 171 if (rc < 0) { 176 172 printf("udebug_set_evmask(0x%x) -> %d\n ", UDEBUG_EM_ALL, rc); 177 173 return rc; 178 174 } 179 175 176 sess = ksess; 180 177 return 0; 181 178 } … … 188 185 int i; 189 186 190 rc = udebug_thread_read( phoneid, thread_hash_buf,187 rc = udebug_thread_read(sess, thread_hash_buf, 191 188 THBUF_SIZE*sizeof(unsigned), &tb_copied, &tb_needed); 192 189 if (rc < 0) { … … 314 311 315 312 memset(&call, 0, sizeof(call)); 316 rc = udebug_mem_read( phoneid, &call.args, sc_args[1], sizeof(call.args));313 rc = udebug_mem_read(sess, &call.args, sc_args[1], sizeof(call.args)); 317 314 318 315 if (rc >= 0) { … … 325 322 ipc_call_t question, reply; 326 323 int rc; 327 int phoneidx; 328 329 // printf("sc_ipc_call_sync_fast()\n"); 330 phoneidx = sc_args[0]; 324 int phoneid; 325 326 phoneid = sc_args[0]; 331 327 332 328 IPC_SET_IMETHOD(question, sc_args[1]); … … 337 333 IPC_SET_ARG5(question, 0); 338 334 339 // printf("memset\n");340 335 memset(&reply, 0, sizeof(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); 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); 349 341 } 350 342 … … 355 347 356 348 memset(&question, 0, sizeof(question)); 357 rc = udebug_mem_read( phoneid, &question.args, sc_args[1],349 rc = udebug_mem_read(sess, &question.args, sc_args[1], 358 350 sizeof(question.args)); 359 351 … … 372 364 373 365 memset(&reply, 0, sizeof(reply)); 374 rc = udebug_mem_read( phoneid, &reply.args, sc_args[2],366 rc = udebug_mem_read(sess, &reply.args, sc_args[2], 375 367 sizeof(reply.args)); 376 368 … … 391 383 392 384 memset(&call, 0, sizeof(call)); 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) { 385 rc = udebug_mem_read(sess, &call, sc_args[0], sizeof(call)); 386 387 if (rc >= 0) 398 388 ipcp_call_in(&call, sc_rc); 399 }400 389 } 401 390 … … 407 396 408 397 /* Read syscall arguments */ 409 rc = udebug_args_read(phoneid, thread_hash, sc_args); 410 411 async_serialize_start(); 412 413 // printf("[%d] ", thread_id); 398 rc = udebug_args_read(sess, thread_hash, sc_args); 414 399 415 400 if (rc < 0) { 416 401 printf("error\n"); 417 async_serialize_end();418 402 return; 419 403 } … … 432 416 break; 433 417 } 434 435 async_serialize_end();436 418 } 437 419 … … 444 426 445 427 /* Read syscall arguments */ 446 rc = udebug_args_read(phoneid, thread_hash, sc_args); 447 448 async_serialize_start(); 428 rc = udebug_args_read(sess, thread_hash, sc_args); 449 429 450 430 // printf("[%d] ", thread_id); … … 452 432 if (rc < 0) { 453 433 printf("error\n"); 454 async_serialize_end();455 434 return; 456 435 } … … 481 460 break; 482 461 } 483 484 async_serialize_end();485 462 } 486 463 487 464 static void event_thread_b(uintptr_t hash) 488 465 { 489 async_serialize_start();490 466 printf("New thread, hash %p\n", (void *) hash); 491 async_serialize_end();492 493 467 thread_trace_start(hash); 494 468 } … … 527 501 528 502 /* Run thread until an event occurs */ 529 rc = udebug_go( phoneid, thread_hash,503 rc = udebug_go(sess, thread_hash, 530 504 &ev_type, &val0, &val1); 531 505 … … 656 630 { 657 631 (void) arg; 658 632 633 console_ctrl_t *console = console_init(stdin, stdout); 634 659 635 while (true) { 660 636 fibril_mutex_lock(&state_lock); … … 662 638 fibril_condvar_wait(&state_cv, &state_lock); 663 639 fibril_mutex_unlock(&state_lock); 664 665 if (!console_get_ event(fphone(stdin), &cev))640 641 if (!console_get_kbd_event(console, &cev)) 666 642 return -1; 667 643 668 644 fibril_mutex_lock(&state_lock); 669 645 cev_valid = true; 670 646 fibril_condvar_broadcast(&state_cv); 671 fibril_mutex_unlock(&state_lock); 647 fibril_mutex_unlock(&state_lock); 672 648 } 673 649 } … … 675 651 static void trace_task(task_id_t task_id) 676 652 { 677 console_event_t ev;653 kbd_event_t ev; 678 654 bool done; 679 655 int i; … … 727 703 case KC_P: 728 704 printf("Pause...\n"); 729 rc = udebug_stop( phoneid, thash);705 rc = udebug_stop(sess, thash); 730 706 if (rc != EOK) 731 707 printf("Error: stop -> %d\n", rc); … … 743 719 printf("\nTerminate debugging session...\n"); 744 720 abort_trace = true; 745 udebug_end( phoneid);746 async_hangup( phoneid);721 udebug_end(sess); 722 async_hangup(sess); 747 723 748 724 ipcp_cleanup();
Note:
See TracChangeset
for help on using the changeset viewer.
