/* pause the local and total timers for all functions in the stack */ void lprofM_pause_function(lprofP_STATE* S) { ASSERT(S->stack_top, "pause_function: stack_top null"); lprofM_pause_local_time(S); lprofM_pause_total_time(S); }
/* returns if there is another function in the stack */ int lprofP_callhookOUT(lprofP_STATE* S) { if (S == NULL ||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); /* 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; 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 = 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; }