case 's':
trace_print_stats();
break;
+ case 'w':
+ if (trace_wipe())
+ return CMD_RET_FAILURE;
+ break;
default:
return CMD_RET_USAGE;
}
"stats - display tracing statistics\n"
"trace pause - pause tracing\n"
"trace resume - resume tracing\n"
+ "trace wipe - wipe traces\n"
"trace funclist [<addr> <size>] - dump function list into buffer\n"
"trace calls [<addr> <size>] "
"- dump function call trace into buffer"
return gd->mon_len / FUNC_SITE_SIZE;
}
-/**
- * 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)
+static int notrace trace_init_(void *buff, size_t buff_size, bool copy_early,
+ bool enable)
{
int func_count = get_func_count();
size_t needed;
return func_count;
trace_save_gd();
- if (!was_disabled) {
+ if (copy_early) {
#ifdef CONFIG_TRACE_EARLY
ulong used, count;
char *end;
}
puts("\n");
memcpy(buff, hdr, used);
-#else
- puts("trace: already enabled\n");
- return -EALREADY;
#endif
}
hdr = (struct trace_hdr *)buff;
hdr->ftrace_size = (buff_size - needed) / sizeof(*hdr->ftrace);
hdr->depth_limit = CONFIG_TRACE_CALL_DEPTH_LIMIT;
- puts("trace: enabled\n");
- trace_enabled = 1;
+ printf("trace: initialized, %senabled\n", enable ? "" : "not ");
+ trace_enabled = enable;
trace_inited = 1;
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
/**
* trace_early_init() - initialize the tracing system for early tracing