/* resume the local and total timers for all functions in the stack */ void lprofM_resume_function(lprofP_STATE* S) { ASSERT(S->stack_top, "resume_function: stack_top null"); lprofM_resume_local_time(S); lprofM_resume_total_time(S); }
/* because the funcinfo will be overwritten */ lprofS_STACK_RECORD *lprofM_leave_function(lprofP_STATE* S, int isto_resume) { ASSERT(S->stack_top, "leave_function: stack_top null"); leave_ret = lprofS_pop(&(S->stack_top)); compute_local_time(&leave_ret); compute_total_time(&leave_ret); /* resume the timer for the parent function ? */ if (isto_resume) lprofM_resume_local_time(S); return &leave_ret; }
/* returns if there is another function in the stack */ int lprofP_callhookOUT(lprofP_STATE* S, lprofP_STATE* R) { if (S->stack_level == 0) { return 0; } S->stack_level--; /* 0: do not resume the parent function's timer yet... */ info = lprofM_leave_function(S, 0); //info->local_time += function_call_time; //info->total_time += function_call_time; // for call stack level //if (info->local_time > 0.0000001 || info->total_time > 0.0000001) //{ R->stack_level++; //info->stack_level = S->stack_level; lprofS_push(&(R->stack_top), *info); R->stack_top->stack_level = S->stack_level; //} if (S->stack_level != 0) { lprofM_resume_local_time(S); } /* // writing a log may take too long to be computed with the function's time ... lprofM_pause_total_time(S); info->local_time += function_call_time; info->total_time += function_call_time; if (info->local_time > 0.0000001 || info->total_time > 0.0000001) { char* source = info->file_defined; //if (source[0] != '@') { // source = "(string)"; //} //else { // formats(source); //} char* name = info->function_name; if (strlen(name) > MAX_FUNCTION_NAME_LENGTH) { name = (char*)malloc(MAX_FUNCTION_NAME_LENGTH + 10); name[0] = '\"'; strncpy(name + 1, info->function_name, MAX_FUNCTION_NAME_LENGTH); name[MAX_FUNCTION_NAME_LENGTH] = '"'; name[MAX_FUNCTION_NAME_LENGTH + 1] = '\0'; } formats(name); output("%d\t%s\t%s\t%d\t%d\t%f\t%f\n", S->stack_level, source, name, info->line_defined, info->current_line, info->local_time, info->total_time); } // ... now it's ok to resume the timer if (S->stack_level != 0) { lprofM_resume_function(S); } */ return 1; }