| | 3073 | | trc_process_trace_event( ID, name, entry_exit, index ) |
| | 3074 | | TRC_ID ID; |
| | 3075 | | char *name; |
| | 3076 | | int entry_exit; |
| | 3077 | | int index; |
| | 3078 | | { |
| | 3079 | | TRC_DATADESC DD; |
| | 3080 | | |
| | 3081 | | TRC_TEVDESC TD; |
| | 3082 | | |
| | 3083 | | TRC_TEVREC TR; |
| | | | ... |
| | 3094 | | short read_short; |
| | 3095 | | long read_long; |
| | 3096 | | int read_int; |
| | 3097 | | |
| | 3098 | | char c; |
| | 3099 | | |
| | 3100 | | int i, j; |
| | 3101 | | int flag; |
| | 3102 | | int num; |
| | 3103 | | |
| | 3104 | | if ( !(ID->handle_event) ) |
| | 3105 | | { |
| | 3106 | | trc_find_event_end( ID ); |
| | 3107 | | |
| | 3108 | | return( TRC_TRUE );
|
| | 3109 | | } |
| | 3110 | | |
| | 3111 | | TD = (TRC_TEVDESC) trc_lookup_trie( TRC_EVENT_TRIE, name ); |
| | 3112 | | |
| | 3113 | | while ( TD != NULL &&
|
| | 3114 | | ( TD->entry_exit != entry_exit || TD->index != index ) ) |
| | 3115 | | { |
| | 3116 | | TD = TD->next; |
| | 3117 | | } |
| | 3118 | | |
| | 3119 | | if ( TD == NULL )
|
| | 3120 | | { |
| | 3121 | | printf( "Error: Event \"%s\" Descriptor Not Found\n", name ); |
| | 3122 | | |
| | 3123 | | trc_find_event_end( ID ); |
| | 3124 | | |
| | 3125 | | return( TRC_FALSE );
|
| | 3126 | | } |
| | 3127 | | |
| | 3128 | | if ( !trc_find_event_str( ID, "{" ) ) |
| | 3129 | | return( TRC_FALSE );
|
| | 3130 | | |
| | 3131 | | |
| | 3132 | | |
| | 3133 | | DD = TD->ddesc; |
| | 3134 | | |
| | 3135 | | TR = (TRC_TEVREC) NULL;
|
| | 3136 | | |
| | 3137 | | while ( DD != NULL )
|
| | 3138 | | { |
| | 3139 | | if ( TR == NULL )
|
| | 3140 | | trptr = TR = trc_create_tevrec(); |
| | 3141 | | |
| | 3142 | | else |
| | 3143 | | trptr = trptr->next = trc_create_tevrec(); |
| | 3144 | | |
| | 3145 | | trptr->ddesc = DD; |
| | 3146 | | |
| | 3147 | | if ( DD->array == TEV_DATA_ARRAY )
|
| | 3148 | | { |
| | 3149 | | if ( !trc_find_event_str( ID, "[" ) ) |
| | 3150 | | return( TRC_FALSE );
|
| | 3151 | | |
| | 3152 | | flag = fscanf( ID->trace_in, "%d", &num ); |
| | 3153 | | |
| | 3154 | | if ( flag != 1 ) |
| | 3155 | | { |
| | 3156 | | printf( "Error Parsing Event Record\n" ); |
| | 3157 | | |
| | 3158 | | trc_find_event_end( ID ); |
| | 3159 | | |
| | 3160 | | return( TRC_FALSE );
|
| | 3161 | | } |
| | 3162 | | |
| | 3163 | | if ( !trc_find_event_str( ID, "{" ) ) |
| | 3164 | | return( TRC_FALSE );
|
| | 3165 | | |
| | 3166 | | |
| | 3167 | | } |
| | 3168 | | |
| | 3169 | | else |
| | 3170 | | num = 1; |
| | 3171 | | |
| | 3172 | | trptr->value = trc_make_value( DD->dt, ( num > 0 ) ? num : 1 ); |
| | 3173 | | |
| | 3174 | | if ( trptr->value == NULL )
|
| | 3175 | | { |
| | 3176 | | printf( "Error Allocating Value dt=%d num=%d\n", |
| | 3177 | | DD->dt, num ); |
| | 3178 | | |
| | 3179 | | return( TRC_FALSE );
|
| | 3180 | | } |
| | 3181 | | |
| | 3182 | | trptr->num = num; |
| | 3183 | | |
| | 3184 | | switch ( DD->dt ) |
| | 3185 | | { |
| | 3186 | | case TEV_DATA_NULL: break;
|
| | 3187 | | |
| | 3188 | | case TEV_DATA_BYTE:
|
| | 3189 | | { |
| | 3190 | | if ( DD->array == TEV_DATA_ARRAY )
|
| | 3191 | | { |
| | 3192 | | if ( !trc_find_event_str( ID, "\"" ) ) |
| | 3193 | | return( TRC_FALSE );
|
| | 3194 | | |
| | 3195 | | i = 0; |
| | 3196 | | |
| | 3197 | | while ( i < num |
| | 3198 | | && (c = getc( ID->trace_in )) != (char) EOF
|
| | 3199 | | && c != '"' ) |
| | 3200 | | { |
| | 3201 | | TRC_ARR_VALUE_OF( trptr->value, char, i++ ) = c;
|
| | 3202 | | } |
| | 3203 | | |
| | 3204 | | TRC_CKEOF( c, "EOF Parsing Event Record\n",
|
| | 3205 | | return( TRC_FALSE ) ); |
| | 3206 | | |
| | 3207 | | if ( i == num ) |
| | 3208 | | { |
| | 3209 | | printf( "Error: Character Overflow\n" ); |
| | 3210 | | |
| | 3211 | | return( TRC_FALSE );
|
| | 3212 | | } |
| | 3213 | | |
| | 3214 | | TRC_ARR_VALUE_OF( trptr->value, char, i ) = '\0';
|
| | 3215 | | } |
| | 3216 | | |
| | 3217 | | else |
| | 3218 | | { |
| | 3219 | | while ( (c = getc( ID->trace_in )) != (char) EOF
|
| | 3220 | | && ( c == ' ' || c == '\t' || c == '\n' ) ); |
| | 3221 | | |
| | 3222 | | TRC_CKEOF( c, "EOF Parsing Event Record\n",
|
| | 3223 | | return( TRC_FALSE ) ); |
| | 3224 | | |
| | 3225 | | TRC_VALUE_OF( trptr->value, char ) = c;
|
| | 3226 | | } |
| | 3227 | | |
| | 3228 | | break; |
| | 3229 | | } |
| | 3230 | | |
| | 3231 | | case TEV_DATA_CPLX:
|
| | 3232 | | case TEV_DATA_FLOAT:
|
| | 3233 | | { |
| | 3234 | | for ( i=0 ; i < num ; i++ ) |
| | 3235 | | { |
| | 3236 | | flag = fscanf( ID->trace_in, "%f", &read_float ); |
| | 3237 | | |
| | 3238 | | if ( flag != 1 ) |
| | 3239 | | { |
| | 3240 | | printf( "Error Parsing Event Record\n" ); |
| | 3241 | | |
| | 3242 | | trc_find_event_end( ID ); |
| | 3243 | | |
| | 3244 | | return( TRC_FALSE );
|
| | 3245 | | } |
| | 3246 | | |
| | 3247 | | TRC_ARR_VALUE_OF( trptr->value, float, i ) =
|
| | 3248 | | read_float; |
| | 3249 | | |
| | 3250 | | if ( i < num - 1 ) |
| | 3251 | | { |
| | 3252 | | if ( !trc_find_event_str( ID, "," ) ) |
| | 3253 | | return( TRC_FALSE );
|
| | 3254 | | } |
| | 3255 | | } |
| | 3256 | | |
| | 3257 | | break; |
| | 3258 | | } |
| | 3259 | | |
| | 3260 | | case TEV_DATA_DCPLX:
|
| | 3261 | | case TEV_DATA_DOUBLE:
|
| | 3262 | | { |
| | 3263 | | for ( i=0 ; i < num ; i++ ) |
| | 3264 | | { |
| | 3265 | | flag = fscanf( ID->trace_in, "%lf", &read_double ); |
| | 3266 | | |
| | 3267 | | if ( flag != 1 ) |
| | 3268 | | { |
| | 3269 | | printf( "Error Parsing Event Record\n" ); |
| | 3270 | | |
| | 3271 | | trc_find_event_end( ID ); |
| | 3272 | | |
| | 3273 | | return( TRC_FALSE );
|
| | 3274 | | } |
| | 3275 | | |
| | 3276 | | TRC_ARR_VALUE_OF( trptr->value, double, i ) =
|
| | 3277 | | read_double; |
| | 3278 | | |
| | 3279 | | if ( i < num - 1 ) |
| | 3280 | | { |
| | 3281 | | if ( !trc_find_event_str( ID, "," ) ) |
| | 3282 | | return( TRC_FALSE );
|
| | 3283 | | } |
| | 3284 | | } |
| | 3285 | | |
| | 3286 | | break; |
| | 3287 | | } |
| | 3288 | | |
| | 3289 | | case TEV_DATA_INT:
|
| | 3290 | | { |
| | 3291 | | for ( i=0 ; i < num ; i++ ) |
| | 3292 | | { |
| | 3293 | | flag = fscanf( ID->trace_in, "%d", &read_int ); |
| | 3294 | | |
| | 3295 | | if ( flag != 1 ) |
| | 3296 | | { |
| | 3297 | | printf( "Error Parsing Event Record\n" ); |
| | 3298 | | |
| | 3299 | | trc_find_event_end( ID ); |
| | 3300 | | |
| | 3301 | | return( TRC_FALSE );
|
| | 3302 | | } |
| | 3303 | | |
| | 3304 | | TRC_ARR_VALUE_OF( trptr->value, int, i ) = read_int;
|
| | 3305 | | |
| | 3306 | | if ( i < num - 1 ) |
| | 3307 | | { |
| | 3308 | | if ( !trc_find_event_str( ID, "," ) ) |
| | 3309 | | return( TRC_FALSE );
|
| | 3310 | | } |
| | 3311 | | } |
| | 3312 | | |
| | 3313 | | break; |
| | 3314 | | } |
| | 3315 | | |
| | 3316 | | case TEV_DATA_UINT:
|
| | 3317 | | { |
| | 3318 | | for ( i=0 ; i < num ; i++ ) |
| | 3319 | | { |
| | 3320 | | flag = fscanf( ID->trace_in, "%u", &read_uint ); |
| | 3321 | | |
| | 3322 | | if ( flag != 1 ) |
| | 3323 | | { |
| | 3324 | | printf( "Error Parsing Event Record\n" ); |
| | 3325 | | |
| | 3326 | | trc_find_event_end( ID ); |
| | 3327 | | |
| | 3328 | | return( TRC_FALSE );
|
| | 3329 | | } |
| | 3330 | | |
| | 3331 | | TRC_ARR_VALUE_OF( trptr->value, unsigned int, i ) =
|
| | 3332 | | read_uint; |
| | 3333 | | |
| | 3334 | | if ( i < num - 1 ) |
| | 3335 | | { |
| | 3336 | | if ( !trc_find_event_str( ID, "," ) ) |
| | 3337 | | return( TRC_FALSE );
|
| | 3338 | | } |
| | 3339 | | } |
| | 3340 | | |
| | 3341 | | break; |
| | 3342 | | } |
| | 3343 | | |
| | 3344 | | case TEV_DATA_LONG:
|
| | 3345 | | { |
| | 3346 | | for ( i=0 ; i < num ; i++ ) |
| | 3347 | | { |
| | 3348 | | flag = fscanf( ID->trace_in, "%ld", &read_long ); |
| | 3349 | | |
| | 3350 | | if ( flag != 1 ) |
| | 3351 | | { |
| | 3352 | | printf( "Error Parsing Event Record\n" ); |
| | 3353 | | |
| | 3354 | | trc_find_event_end( ID ); |
| | 3355 | | |
| | 3356 | | return( TRC_FALSE );
|
| | 3357 | | } |
| | 3358 | | |
| | 3359 | | TRC_ARR_VALUE_OF( trptr->value, long, i ) =
|
| | 3360 | | read_long; |
| | 3361 | | |
| | 3362 | | if ( i < num - 1 ) |
| | 3363 | | { |
| | 3364 | | if ( !trc_find_event_str( ID, "," ) ) |
| | 3365 | | return( TRC_FALSE );
|
| | 3366 | | } |
| | 3367 | | } |
| | 3368 | | |
| | 3369 | | break; |
| | 3370 | | } |
| | 3371 | | |
| | 3372 | | case TEV_DATA_ULONG:
|
| | 3373 | | { |
| | 3374 | | for ( i=0 ; i < num ; i++ ) |
| | 3375 | | { |
| | 3376 | | flag = fscanf( ID->trace_in, "%lu", &read_ulong ); |
| | 3377 | | |
| | 3378 | | if ( flag != 1 ) |
| | 3379 | | { |
| | 3380 | | printf( "Error Parsing Event Record\n" ); |
| | 3381 | | |
| | 3382 | | trc_find_event_end( ID ); |
| | 3383 | | |
| | 3384 | | return( TRC_FALSE );
|
| | 3385 | | } |
| | 3386 | | |
| | 3387 | | TRC_ARR_VALUE_OF( trptr->value, unsigned long, i ) =
|
| | 3388 | | read_ulong; |
| | 3389 | | |
| | 3390 | | if ( i < num - 1 ) |
| | 3391 | | { |
| | 3392 | | if ( !trc_find_event_str( ID, "," ) ) |
| | 3393 | | return( TRC_FALSE );
|
| | 3394 | | } |
| | 3395 | | } |
| | 3396 | | |
| | 3397 | | break; |
| | 3398 | | } |
| | 3399 | | |
| | 3400 | | case TEV_DATA_SHORT:
|
| | 3401 | | { |
| | 3402 | | for ( i=0 ; i < num ; i++ ) |
| | 3403 | | { |
| | 3404 | | flag = fscanf( ID->trace_in, "%hd", &read_short ); |
| | 3405 | | |
| | 3406 | | if ( flag != 1 ) |
| | 3407 | | { |
| | 3408 | | printf( "Error Parsing Event Record\n" ); |
| | 3409 | | |
| | 3410 | | trc_find_event_end( ID ); |
| | 3411 | | |
| | 3412 | | return( TRC_FALSE );
|
| | 3413 | | } |
| | 3414 | | |
| | 3415 | | TRC_ARR_VALUE_OF( trptr->value, short, i ) =
|
| | 3416 | | read_short; |
| | 3417 | | |
| | 3418 | | if ( i < num - 1 ) |
| | 3419 | | { |
| | 3420 | | if ( !trc_find_event_str( ID, "," ) ) |
| | 3421 | | return( TRC_FALSE );
|
| | 3422 | | } |
| | 3423 | | } |
| | 3424 | | |
| | 3425 | | break; |
| | 3426 | | } |
| | 3427 | | |
| | 3428 | | case TEV_DATA_USHORT:
|
| | 3429 | | { |
| | 3430 | | for ( i=0 ; i < num ; i++ ) |
| | 3431 | | { |
| | 3432 | | flag = fscanf( ID->trace_in, "%hu", &read_ushort ); |
| | 3433 | | |
| | 3434 | | if ( flag != 1 ) |
| | 3435 | | { |
| | 3436 | | printf( "Error Parsing Event Record\n" ); |
| | 3437 | | |
| | 3438 | | trc_find_event_end( ID ); |
| | 3439 | | |
| | 3440 | | return( TRC_FALSE );
|
| | 3441 | | } |
| | 3442 | | |
| | 3443 | | TRC_ARR_VALUE_OF( trptr->value, unsigned short, i )
|
| | 3444 | | = read_ushort; |
| | 3445 | | |
| | 3446 | | if ( i < num - 1 ) |
| | 3447 | | { |
| | 3448 | | if ( !trc_find_event_str( ID, "," ) ) |
| | 3449 | | return( TRC_FALSE );
|
| | 3450 | | } |
| | 3451 | | } |
| | 3452 | | |
| | 3453 | | break; |
| | 3454 | | } |
| | 3455 | | |
| | 3456 | | case TEV_DATA_STRING:
|
| | 3457 | | { |
| | 3458 | | if ( DD->array == TEV_DATA_SCALAR )
|
| | 3459 | | { |
| | 3460 | | if ( !trc_find_event_str( ID, "{" ) ) |
| | 3461 | | return( TRC_FALSE );
|
| | 3462 | | } |
| | 3463 | | |
| | 3464 | | for ( i=0 ; i < num ; i++ ) |
| | 3465 | | { |
| | 3466 | | if ( !trc_find_event_str( ID, "\"" ) ) |
| | 3467 | | return( TRC_FALSE );
|
| | 3468 | | |
| $input_622036 > 1023 | 3469 | | j = 0; |
| | 3470 | | |
| | 3471 | | while ( (c = getc( ID->trace_in )) != (char) EOF
|
| | 3472 | | && c != '"' ) |
| | 3473 | | { |
| | 3474 | | read_str[j++] = c; |
| | 3475 | | } |
| | 3476 | | |
| | 3477 | | TRC_CKEOF( c, "EOF Parsing Event Record\n",
|
| | 3478 | | return( TRC_FALSE ) ); |
| | 3479 | | |
| j > 1023 | 3480 | | read_str[j] = '\0'; |
| | 3481 | | |
| | 3482 | | TRC_ARR_VALUE_OF( trptr->value, char *, i ) =
|
| | 3483 | | trc_copy_str( read_str ); |
| | 3484 | | |
| | 3485 | | if ( i < num - 1 ) |
| | 3486 | | { |
| | 3487 | | if ( !trc_find_event_str( ID, "," ) ) |
| | 3488 | | return( TRC_FALSE );
|
| | 3489 | | } |
| | 3490 | | } |
| | 3491 | | |
| | 3492 | | if ( DD->array == TEV_DATA_SCALAR )
|
| | 3493 | | { |
| | 3494 | | if ( !trc_find_event_str( ID, "}" ) ) |
| | 3495 | | return( TRC_FALSE );
|
| | 3496 | | } |
| | 3497 | | |
| | 3498 | | break; |
| | 3499 | | } |
| | 3500 | | |
| | 3501 | | case TEV_DATA_STRUCT_START:
|
| | 3502 | | case TEV_DATA_STRUCT_END:
|
| | 3503 | | case TEV_DATA_DEFERRED:
|
| | 3504 | | { |
| | 3505 | | printf( "DT Not Impl\n" ); |
| | 3506 | | |
| | 3507 | | trc_find_event_end( ID ); |
| | 3508 | | |
| | | | ... |
| | 3512 | | default: |
| | 3513 | | { |
| | 3514 | | printf( "DT Unknown\n" ); |
| | 3515 | | |
| | 3516 | | trc_find_event_end( ID ); |
| | 3517 | | |
| | 3518 | | return( TRC_FALSE );
|
| | 3519 | | } |
| | 3520 | | } |
| | 3521 | | |
| | 3522 | | if ( DD->array == TEV_DATA_ARRAY )
|
| | 3523 | | { |
| | 3524 | | |
| | 3525 | | |
| | 3526 | | if ( !trc_find_event_str( ID, "}" ) ) |
| | 3527 | | return( TRC_FALSE );
|
| | 3528 | | } |
| | 3529 | | |
| | 3530 | | if ( DD->next != NULL )
|
| | 3531 | | { |
| | 3532 | | if ( !trc_find_event_str( ID, "," ) ) |
| | 3533 | | return( TRC_FALSE );
|
| | 3534 | | } |
| | 3535 | | |
| | 3536 | | DD = DD->next; |