| 300 | */ |
| 301 | |
| 302 | void process (inf) |
| 303 | FILE *inf; |
| 304 | { |
| 305 | char buf[BUFSIZ]; |
| 306 | char fn_name[64]; /* Max length of fn_name */ |
| 307 | unsigned long fn_time; |
| 308 | unsigned long fn_sbot; |
| 309 | unsigned long fn_ssz; |
| 310 | unsigned long lastuse; |
| 311 | unsigned int pos; |
| 312 | unsigned long local_time; |
| 313 | unsigned int oldpos; |
| 314 | unsigned long oldtime; |
| 315 | unsigned long oldchild; |
| 316 | struct stack_t *t; |
| 317 | |
| 318 | DBUG_ENTER ("process"); |
| 319 | while (fgets (buf,BUFSIZ,inf) != NULL) { |
| 320 | switch (buf[0]) { |
| 321 | case 'E': |
| 322 | sscanf (buf+2, "%ld %64s", &fn_time, fn_name); |
| 323 | DBUG_PRINT ("erec", ("%ld %s", fn_time, fn_name)); |
| 324 | pos = add (fn_name); |
| 325 | push (pos, fn_time); |
| 326 | break; |
| 327 | case 'X': |
| 328 | sscanf (buf+2, "%ld %64s", &fn_time, fn_name); |
| 329 | DBUG_PRINT ("xrec", ("%ld %s", fn_time, fn_name)); |
| 330 | pos = add (fn_name); |
| 331 | /* |
| 332 | * An exited function implies that all stacked |
| 333 | * functions are also exited, until the matching |
| 334 | * function is found on the stack. |
| 335 | */ |
| 336 | while (pop (&oldpos, &oldtime, &oldchild)) { |
| 337 | DBUG_PRINT ("popped", ("%lu %lu", oldtime, oldchild)); |
| 338 | local_time = fn_time - oldtime; |
| 339 | t = top (); |
| 340 | t -> children += local_time; |
| 341 | DBUG_PRINT ("update", ("%s", modules[t -> pos].name)); |
| 342 | DBUG_PRINT ("update", ("%lu", t -> children)); |
| 343 | local_time -= oldchild; |
| 344 | modules[oldpos].m_time += local_time; |
| 345 | modules[oldpos].m_calls++; |
| 346 | tot_time += local_time; |
| 347 | tot_calls++; |
| 348 | if (pos == oldpos) { |
| 349 | goto next_line; /* Should be a break2 */ |
| 350 | } |
| 351 | } |
| 352 | /* |
| 353 | * Assume that item seen started at time 0. |
| 354 | * (True for function main). But initialize |
| 355 | * it so that it works the next time too. |
| 356 | */ |
| 357 | t = top (); |
| 358 | local_time = fn_time - t -> time - t -> children; |
| 359 | t -> time = fn_time; t -> children = 0; |