| | 2421 | | trc_read_trace_event( ID, eof ) |
| | 2422 | | TRC_ID ID; |
| | 2423 | | int *eof; |
| | 2424 | | { |
| | 2425 | | TRC_TEVDESC TD; |
| | 2426 | | |
| | 2427 | | char tmp[4096]; |
| | 2428 | | char c; |
| | 2429 | | |
| | 2430 | | int entry_exit; |
| | 2431 | | int dummy; |
| | 2432 | | int index; |
| | 2433 | | int code; |
| | 2434 | | int flag; |
| | 2435 | | int eid; |
| | 2436 | | int ee; |
| | 2437 | | int i; |
| | 2438 | | |
| | 2439 | | *eof = TRC_FALSE;
|
| | 2440 | | |
| | 2441 | | if ( ID->trace_in == NULL )
|
| | 2442 | | return( TRC_FALSE );
|
| | 2443 | | |
| | 2444 | | while ( TRC_TRUE )
|
| | 2445 | | { |
| | 2446 | | c = getc( ID->trace_in ); |
| | 2447 | | |
| | 2448 | | if ( c != (char) EOF )
|
| | 2449 | | { |
| | 2450 | | switch ( c ) |
| | 2451 | | { |
| | 2452 | | |
| | 2453 | | |
| | 2454 | | case '#': |
| | 2455 | | { |
| | 2456 | | |
| | 2457 | | |
| | 2458 | | flag = fscanf( ID->trace_in, "%d", &code ); |
| | 2459 | | |
| | 2460 | | if ( flag != 1 ) |
| | 2461 | | { |
| | 2462 | | printf( "Error Reading Event ID\n" ); |
| | 2463 | | |
| | 2464 | | return( TRC_FALSE );
|
| | 2465 | | } |
| | 2466 | | |
| | 2467 | | |
| | 2468 | | |
| | 2469 | | if ( !trc_find_event_str( ID, "\"" ) ) |
| | 2470 | | return( TRC_FALSE );
|
| | 2471 | | |
| true | 2472 | | i = 0; |
| | 2473 | | |
| | 2474 | | while ( (c = getc( ID->trace_in )) != (char) EOF
|
| | 2475 | | && c != '"' && c != '(' ) |
| | 2476 | | { |
| | 2477 | | tmp[i++] = c; |
| | 2478 | | } |
| | 2479 | | |
| | 2480 | | TRC_CKEOF( c, "EOF Reading Event Descriptor Name\n",
|
| | 2481 | | return( TRC_FALSE ) ); |
| | 2482 | | |
| | 2483 | | tmp[i] = '\0'; |
| | 2484 | | |
| | 2485 | | |
| | 2486 | | |
| | 2487 | | if ( c == '(' ) |
| | 2488 | | { |
| | 2489 | | |
| | 2490 | | |
| | 2491 | | index = ( code / 1000 ) - 1; |
| | 2492 | | |
| | 2493 | | eid = ( code - ((index + 1) * 1000) ) / 2; |
| | 2494 | | |
| | 2495 | | ee = code - ((index + 1) * 1000) - (2 * eid); |
| | 2496 | | |
| | 2497 | | |
| | 2498 | | |
| | 2499 | | flag = fscanf( ID->trace_in, "%d", &dummy ); |
| | 2500 | | |
| | 2501 | | if ( flag != 1 ) |
| | 2502 | | { |
| | 2503 | | printf( "Error Reading Event Index\n" ); |
| | 2504 | | |
| | 2505 | | return( TRC_FALSE );
|
| | 2506 | | } |
| | 2507 | | |
| | 2508 | | |
| | 2509 | | |
| | 2510 | | c = getc( ID->trace_in ); |
| | 2511 | | |
| | 2512 | | TRC_CKEOF( c, "EOF Reading Event Descriptor\n",
|
| | 2513 | | return( TRC_FALSE ) ); |
| | 2514 | | |
| | 2515 | | if ( c == '.' ) |
| | 2516 | | { |
| | 2517 | | if ( ee != dummy ) |
| | 2518 | | { |
| | 2519 | | printf( "Warning: " ); |
| | 2520 | | printf( "Entry/Exit Mismatch " ); |
| | 2521 | | printf( "%d != %d\n", ee, dummy ); |
| | 2522 | | } |
| | 2523 | | |
| | 2524 | | entry_exit = TRC_IGNORE_TEV;
|
| | 2525 | | |
| | 2526 | | if ( dummy == 0 ) |
| | 2527 | | entry_exit = TRC_ENTRY_TEV;
|
| | 2528 | | |
| | 2529 | | else if ( dummy == 1 ) |
| | 2530 | | entry_exit = TRC_EXIT_TEV;
|
| | 2531 | | |
| | 2532 | | flag = fscanf( ID->trace_in, "%d", &dummy ); |
| | 2533 | | |
| | 2534 | | if ( flag != 1 ) |
| | 2535 | | { |
| | 2536 | | printf( "Error Reading Event Index\n" ); |
| | 2537 | | |
| | 2538 | | return( TRC_FALSE );
|
| | 2539 | | } |
| | 2540 | | |
| | 2541 | | if ( index != dummy ) |
| | 2542 | | { |
| | 2543 | | printf( "Warning: " ); |
| | 2544 | | printf( "Descriptor Index Mismatch " ); |
| | 2545 | | printf( "%d != %d\n", index, dummy ); |
| | 2546 | | |
| | 2547 | | index = dummy; |
| | 2548 | | } |
| | 2549 | | |
| | 2550 | | if ( !trc_find_event_str( ID, ")" ) ) |
| | 2551 | | return( TRC_FALSE );
|
| | 2552 | | } |
| | 2553 | | |
| | 2554 | | else |
| | 2555 | | { |
| | 2556 | | entry_exit = TRC_IGNORE_TEV;
|
| | 2557 | | |
| | 2558 | | if ( ee == 1 ) |
| | 2559 | | { |
| | 2560 | | printf( "Warning: " ); |
| | 2561 | | printf( "Entry/Exit Mismatch " ); |
| | 2562 | | printf( "%d != %d\n", ee, entry_exit ); |
| | 2563 | | } |
| | 2564 | | |
| | 2565 | | if ( index != dummy ) |
| | 2566 | | { |
| | 2567 | | printf( "Warning: " ); |
| | 2568 | | printf( "Descriptor Index Mismatch " ); |
| | 2569 | | printf( "%d != %d\n", index, dummy ); |
| | 2570 | | |
| | 2571 | | index = dummy; |
| | 2572 | | } |
| | 2573 | | } |
| | 2574 | | |
| | 2575 | | if ( !trc_find_event_str( ID, "\"" ) ) |
| | 2576 | | return( TRC_FALSE );
|
| | 2577 | | |
| | 2578 | | if ( !(TD = trc_read_descriptor( |
| | 2579 | | ID, eid, tmp, entry_exit, index )) ) |
| | 2580 | | { |
| | 2581 | | return( TRC_FALSE );
|
| | 2582 | | } |
| | 2583 | | |
| | 2584 | | if ( ID->handle_descriptor ) |
| | 2585 | | (ID->handle_descriptor)( ID, TD ); |
| | 2586 | | } |
| | 2587 | | |
| | 2588 | | |
| | 2589 | | |
| | 2590 | | else |
| | 2591 | | { |
| | 2592 | | eid = code; |
| | 2593 | | |
| i < 1 | 2594 | | if ( tmp[ i - 1 ] == '0' ) |
| | 2595 | | entry_exit = TRC_ENTRY_TEV;
|
| | 2596 | | |
| | 2597 | | else if ( tmp[ i - 1 ] == '1' ) |
| | 2598 | | entry_exit = TRC_EXIT_TEV;
|
| | 2599 | | |
| | 2600 | | else |
| | 2601 | | entry_exit = TRC_IGNORE_TEV;
|
| | 2602 | | |
| | 2603 | | if ( !(TD = trc_read_descriptor( |
| | 2604 | | ID, eid, tmp, entry_exit, -1 )) ) |
| | 2605 | | { |
| | 2606 | | return( TRC_FALSE );
|
| | 2607 | | } |
| | 2608 | | |
| | 2609 | | if ( ID->handle_old_descriptor ) |
| | 2610 | | (ID->handle_old_descriptor)( ID, TD ); |
| | 2611 | | } |
| | 2612 | | |
| | 2613 | | break; |
| | 2614 | | } |
| | 2615 | | |
| | 2616 | | |
| | 2617 | | |
| | 2618 | | case '"': |
| | 2619 | | { |
| | 2620 | | i = 0; |
| | 2621 | | |
| | 2622 | | while ( (c = getc( ID->trace_in )) != (char) EOF
|
| | 2623 | | && c != '"' && c != '(' ) |
| | | | ... |
| | 2695 | | { |
| | 2696 | | return( |
| | 2697 | | trc_process_old_trace_event( ID, tmp ) ); |
| | 2698 | | } |
| | 2699 | | |
| | 2700 | | |
| | 2701 | | } |
| | 2702 | | |
| | 2703 | | |
| | 2704 | | |
| | 2705 | | case '%': |
| | 2706 | | { |
| | 2707 | | tmp[0] = '%'; |
| | 2708 | | |
| | 2709 | | if ( !trc_find_event_end_ret( ID, tmp + 1, 4095 ) ) |
| | 2710 | | return( TRC_FALSE );
|
| | 2711 | | |
| | 2712 | | if ( ID->handle_command ) |
| | 2713 | | (ID->handle_command)( ID, tmp ); |
| | 2714 | | |
| | 2715 | | break; |
| | 2716 | | } |
| | 2717 | | |
| | 2718 | | |
| | 2719 | | |
| | 2720 | | case '/': |
| | 2721 | | { |
| | 2722 | | c = getc( ID->trace_in ); |
| | 2723 | | |
| | 2724 | | TRC_CKEOF( c, "EOF Reading Trace \n",
|
| | 2725 | | return( TRC_FALSE ) ); |
| | 2726 | | |
| | 2727 | | if ( c != '*' ) |
| | 2728 | | { |
| | 2729 | | printf( "\nError Reading Trace File\n" ); |
| | 2730 | | printf( "\t- '*' expected (/* */)\n\n" ); |
| | 2731 | | } |
| | 2732 | | |
| | 2733 | | strcpy( tmp, "/*" ); |
| | 2734 | | |
| | 2735 | | if ( !trc_find_event_end_ret( ID, tmp + 2, 4094 ) ) |
| | 2736 | | return( TRC_FALSE );
|
| | 2737 | | |
| | 2738 | | if ( ID->handle_comment ) |
| | 2739 | | (ID->handle_comment)( ID, tmp ); |
| | 2740 | | |
| | 2741 | | break; |
| | 2742 | | } |
| | 2743 | | |
| | 2744 | | |
| | 2745 | | |
| | 2746 | | case ' ': |
| | 2747 | | case '\t': |
| | 2748 | | case '\n': |
| | 2749 | | { |
| | 2750 | | break; |