mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-19 03:15:00 +00:00
trace: add support for 'trace wipe'
Implement a 'trace wipe' command to delete the currently accumulated trace data. This comes handy when someone needs to trace a particular command. For example: => trace pause; trace wipe => trace resume; dhcp; trace pause => trace stats => trace calls 0x02100000 0x10000000 => tftpput $profbase $profoffset 192.168.0.16:trace.bin Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
This commit is contained in:
parent
c3c20a5e3c
commit
60a684e0a9
3 changed files with 40 additions and 14 deletions
|
@ -100,6 +100,10 @@ int do_trace(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||||
case 's':
|
case 's':
|
||||||
trace_print_stats();
|
trace_print_stats();
|
||||||
break;
|
break;
|
||||||
|
case 'w':
|
||||||
|
if (trace_wipe())
|
||||||
|
return CMD_RET_FAILURE;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
}
|
}
|
||||||
|
@ -113,6 +117,7 @@ U_BOOT_CMD(
|
||||||
"stats - display tracing statistics\n"
|
"stats - display tracing statistics\n"
|
||||||
"trace pause - pause tracing\n"
|
"trace pause - pause tracing\n"
|
||||||
"trace resume - resume tracing\n"
|
"trace resume - resume tracing\n"
|
||||||
|
"trace wipe - wipe traces\n"
|
||||||
"trace funclist [<addr> <size>] - dump function list into buffer\n"
|
"trace funclist [<addr> <size>] - dump function list into buffer\n"
|
||||||
"trace calls [<addr> <size>] "
|
"trace calls [<addr> <size>] "
|
||||||
"- dump function call trace into buffer"
|
"- dump function call trace into buffer"
|
||||||
|
|
|
@ -100,6 +100,8 @@ void trace_set_enabled(int enabled);
|
||||||
|
|
||||||
int trace_early_init(void);
|
int trace_early_init(void);
|
||||||
|
|
||||||
|
int trace_clear(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init the trace system
|
* Init the trace system
|
||||||
*
|
*
|
||||||
|
|
47
lib/trace.c
47
lib/trace.c
|
@ -351,14 +351,8 @@ static int get_func_count(void)
|
||||||
return gd->mon_len / FUNC_SITE_SIZE;
|
return gd->mon_len / FUNC_SITE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static int notrace trace_init_(void *buff, size_t buff_size, bool copy_early,
|
||||||
* trace_init() - initialize the tracing system and enable it
|
bool enable)
|
||||||
*
|
|
||||||
* @buff: Pointer to trace buffer
|
|
||||||
* @buff_size: Size of trace buffer
|
|
||||||
* Return: 0 if ok
|
|
||||||
*/
|
|
||||||
int notrace trace_init(void *buff, size_t buff_size)
|
|
||||||
{
|
{
|
||||||
int func_count = get_func_count();
|
int func_count = get_func_count();
|
||||||
size_t needed;
|
size_t needed;
|
||||||
|
@ -368,7 +362,7 @@ int notrace trace_init(void *buff, size_t buff_size)
|
||||||
return func_count;
|
return func_count;
|
||||||
trace_save_gd();
|
trace_save_gd();
|
||||||
|
|
||||||
if (!was_disabled) {
|
if (copy_early) {
|
||||||
#ifdef CONFIG_TRACE_EARLY
|
#ifdef CONFIG_TRACE_EARLY
|
||||||
ulong used, count;
|
ulong used, count;
|
||||||
char *end;
|
char *end;
|
||||||
|
@ -394,9 +388,6 @@ int notrace trace_init(void *buff, size_t buff_size)
|
||||||
}
|
}
|
||||||
puts("\n");
|
puts("\n");
|
||||||
memcpy(buff, hdr, used);
|
memcpy(buff, hdr, used);
|
||||||
#else
|
|
||||||
puts("trace: already enabled\n");
|
|
||||||
return -EALREADY;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
hdr = (struct trace_hdr *)buff;
|
hdr = (struct trace_hdr *)buff;
|
||||||
|
@ -419,13 +410,41 @@ int notrace trace_init(void *buff, size_t buff_size)
|
||||||
hdr->ftrace_size = (buff_size - needed) / sizeof(*hdr->ftrace);
|
hdr->ftrace_size = (buff_size - needed) / sizeof(*hdr->ftrace);
|
||||||
hdr->depth_limit = CONFIG_TRACE_CALL_DEPTH_LIMIT;
|
hdr->depth_limit = CONFIG_TRACE_CALL_DEPTH_LIMIT;
|
||||||
|
|
||||||
puts("trace: enabled\n");
|
printf("trace: initialized, %senabled\n", enable ? "" : "not ");
|
||||||
trace_enabled = 1;
|
trace_enabled = enable;
|
||||||
trace_inited = 1;
|
trace_inited = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* trace_init() - initialize the tracing system and enable it
|
||||||
|
*
|
||||||
|
* @buff: Pointer to trace buffer
|
||||||
|
* @buff_size: Size of trace buffer
|
||||||
|
* Return: 0 if ok
|
||||||
|
*/
|
||||||
|
int notrace trace_init(void *buff, size_t buff_size)
|
||||||
|
{
|
||||||
|
/* If traces are enabled already, we may have early traces to copy */
|
||||||
|
return trace_init_(buff, buff_size, trace_enabled, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* trace_clear() - clear accumulated traced data
|
||||||
|
*
|
||||||
|
* May be called with tracing enabled or disabled.
|
||||||
|
*/
|
||||||
|
int notrace trace_clear(void)
|
||||||
|
{
|
||||||
|
bool was_enabled = trace_enabled;
|
||||||
|
|
||||||
|
if (trace_enabled)
|
||||||
|
trace_enabled = 0;
|
||||||
|
return trace_init_(gd->trace_buff, CONFIG_TRACE_BUFFER_SIZE,
|
||||||
|
false, was_enabled);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_TRACE_EARLY
|
#ifdef CONFIG_TRACE_EARLY
|
||||||
/**
|
/**
|
||||||
* trace_early_init() - initialize the tracing system for early tracing
|
* trace_early_init() - initialize the tracing system for early tracing
|
||||||
|
|
Loading…
Add table
Reference in a new issue