mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-28 15:41:40 +00:00
trace: Track the minimum stack depth
The trace does not necessarily start at the top level, so we can see it go negative. Track this so that we can show an accurate value for the stack depth. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
c3d91812a2
commit
daca66d55f
1 changed files with 16 additions and 8 deletions
24
lib/trace.c
24
lib/trace.c
|
@ -35,9 +35,10 @@ struct trace_hdr {
|
||||||
ulong ftrace_count; /* Num. of ftrace records written */
|
ulong ftrace_count; /* Num. of ftrace records written */
|
||||||
ulong ftrace_too_deep_count; /* Functions that were too deep */
|
ulong ftrace_too_deep_count; /* Functions that were too deep */
|
||||||
|
|
||||||
int depth;
|
int depth; /* Depth of function calls */
|
||||||
int depth_limit;
|
int depth_limit; /* Depth limit to trace to */
|
||||||
int max_depth;
|
int max_depth; /* Maximum depth seen so far */
|
||||||
|
int min_depth; /* Minimum depth seen so far */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Pointer to start of trace buffer */
|
/* Pointer to start of trace buffer */
|
||||||
|
@ -142,7 +143,7 @@ void notrace __cyg_profile_func_enter(void *func_ptr, void *caller)
|
||||||
hdr->untracked_count++;
|
hdr->untracked_count++;
|
||||||
}
|
}
|
||||||
hdr->depth++;
|
hdr->depth++;
|
||||||
if (hdr->depth > hdr->depth_limit)
|
if (hdr->depth > hdr->max_depth)
|
||||||
hdr->max_depth = hdr->depth;
|
hdr->max_depth = hdr->depth;
|
||||||
trace_swap_gd();
|
trace_swap_gd();
|
||||||
}
|
}
|
||||||
|
@ -158,8 +159,10 @@ void notrace __cyg_profile_func_exit(void *func_ptr, void *caller)
|
||||||
{
|
{
|
||||||
if (trace_enabled) {
|
if (trace_enabled) {
|
||||||
trace_swap_gd();
|
trace_swap_gd();
|
||||||
add_ftrace(func_ptr, caller, FUNCF_EXIT);
|
|
||||||
hdr->depth--;
|
hdr->depth--;
|
||||||
|
add_ftrace(func_ptr, caller, FUNCF_EXIT);
|
||||||
|
if (hdr->depth < hdr->min_depth)
|
||||||
|
hdr->min_depth = hdr->depth;
|
||||||
trace_swap_gd();
|
trace_swap_gd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -309,8 +312,10 @@ void trace_print_stats(void)
|
||||||
printf(" (%lu dropped due to overflow)",
|
printf(" (%lu dropped due to overflow)",
|
||||||
hdr->ftrace_count - hdr->ftrace_size);
|
hdr->ftrace_count - hdr->ftrace_size);
|
||||||
}
|
}
|
||||||
puts("\n");
|
|
||||||
printf("%15d maximum observed call depth\n", hdr->max_depth);
|
/* Add in minimum depth since the trace did not start at top level */
|
||||||
|
printf("\n%15d maximum observed call depth\n",
|
||||||
|
hdr->max_depth - hdr->min_depth);
|
||||||
printf("%15d call depth limit\n", hdr->depth_limit);
|
printf("%15d call depth limit\n", hdr->depth_limit);
|
||||||
print_grouped_ull(hdr->ftrace_too_deep_count, 10);
|
print_grouped_ull(hdr->ftrace_too_deep_count, 10);
|
||||||
puts(" calls not traced due to depth\n");
|
puts(" calls not traced due to depth\n");
|
||||||
|
@ -381,8 +386,10 @@ int notrace trace_init(void *buff, size_t buff_size)
|
||||||
return -ENOSPC;
|
return -ENOSPC;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (was_disabled)
|
if (was_disabled) {
|
||||||
memset(hdr, '\0', needed);
|
memset(hdr, '\0', needed);
|
||||||
|
hdr->min_depth = INT_MAX;
|
||||||
|
}
|
||||||
hdr->func_count = func_count;
|
hdr->func_count = func_count;
|
||||||
hdr->call_accum = (uintptr_t *)(hdr + 1);
|
hdr->call_accum = (uintptr_t *)(hdr + 1);
|
||||||
|
|
||||||
|
@ -427,6 +434,7 @@ int notrace trace_early_init(void)
|
||||||
memset(hdr, '\0', needed);
|
memset(hdr, '\0', needed);
|
||||||
hdr->call_accum = (uintptr_t *)(hdr + 1);
|
hdr->call_accum = (uintptr_t *)(hdr + 1);
|
||||||
hdr->func_count = func_count;
|
hdr->func_count = func_count;
|
||||||
|
hdr->min_depth = INT_MAX;
|
||||||
|
|
||||||
/* Use any remaining space for the timed function trace */
|
/* Use any remaining space for the timed function trace */
|
||||||
hdr->ftrace = (struct trace_call *)((char *)hdr + needed);
|
hdr->ftrace = (struct trace_call *)((char *)hdr + needed);
|
||||||
|
|
Loading…
Reference in a new issue