mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-28 08:35:38 +00:00
trace: Detect an infinite loop
If something is wrong with a board's timer function such that it calls functions not marked with notrace, U-Boot will hang. Detect this, print a message and disable the trace. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
80f91558a1
commit
852d4dbd70
1 changed files with 10 additions and 0 deletions
10
lib/trace.c
10
lib/trace.c
|
@ -39,6 +39,7 @@ struct trace_hdr {
|
||||||
int depth_limit; /* Depth limit to trace to */
|
int depth_limit; /* Depth limit to trace to */
|
||||||
int max_depth; /* Maximum depth seen so far */
|
int max_depth; /* Maximum depth seen so far */
|
||||||
int min_depth; /* Minimum depth seen so far */
|
int min_depth; /* Minimum depth seen so far */
|
||||||
|
bool trace_locked; /* Used to detect recursive tracing */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Pointer to start of trace buffer */
|
/* Pointer to start of trace buffer */
|
||||||
|
@ -133,6 +134,14 @@ void notrace __cyg_profile_func_enter(void *func_ptr, void *caller)
|
||||||
if (trace_enabled) {
|
if (trace_enabled) {
|
||||||
int func;
|
int func;
|
||||||
|
|
||||||
|
if (hdr->trace_locked) {
|
||||||
|
trace_enabled = 0;
|
||||||
|
puts("trace: recursion detected, disabling\n");
|
||||||
|
hdr->trace_locked = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hdr->trace_locked = true;
|
||||||
trace_swap_gd();
|
trace_swap_gd();
|
||||||
add_ftrace(func_ptr, caller, FUNCF_ENTRY);
|
add_ftrace(func_ptr, caller, FUNCF_ENTRY);
|
||||||
func = func_ptr_to_num(func_ptr);
|
func = func_ptr_to_num(func_ptr);
|
||||||
|
@ -146,6 +155,7 @@ void notrace __cyg_profile_func_enter(void *func_ptr, void *caller)
|
||||||
if (hdr->depth > hdr->max_depth)
|
if (hdr->depth > hdr->max_depth)
|
||||||
hdr->max_depth = hdr->depth;
|
hdr->max_depth = hdr->depth;
|
||||||
trace_swap_gd();
|
trace_swap_gd();
|
||||||
|
hdr->trace_locked = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue