diff mbox series

[2/2] trace-cmd: Add error_log dump to trace-cmd stat command

Message ID 20200416072244.50239-3-tz.stoyanov@gmail.com (mailing list archive)
State Accepted
Commit d1e5a16e304df56ffd75c997ecad0f8e29c8c5f5
Headers show
Series Enhancements of the "trace-cmd stat" command | expand

Commit Message

Tzvetomir Stoyanov (VMware) April 16, 2020, 7:22 a.m. UTC
In case of a ftrace configuration problem, the description
of the error is printed in the error_log file. It is useful
to dump all recorded errors in "trace-cmd stat" command.

Reported-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=207291
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 Documentation/trace-cmd-stat.1.txt |  2 ++
 tracecmd/trace-stat.c              | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)
diff mbox series

Patch

diff --git a/Documentation/trace-cmd-stat.1.txt b/Documentation/trace-cmd-stat.1.txt
index 004fbaa5..2f1a9c8b 100644
--- a/Documentation/trace-cmd-stat.1.txt
+++ b/Documentation/trace-cmd-stat.1.txt
@@ -43,6 +43,8 @@  system. The status that it shows is:
 
 *Uprobes:* Shows any uprobes that are defined for tracing.
 
+*Error log:* Dump the content of ftrace error_log file.
+
 SEE ALSO
 --------
 trace-cmd(1), trace-cmd-record(1), trace-cmd-report(1), trace-cmd-start(1),
diff --git a/tracecmd/trace-stat.c b/tracecmd/trace-stat.c
index 3f7b3493..c5057978 100644
--- a/tracecmd/trace-stat.c
+++ b/tracecmd/trace-stat.c
@@ -897,6 +897,22 @@  static void report_traceon(struct buffer_instance *instance)
 	free(str);
 }
 
+static void report_errorlog(struct buffer_instance *instance)
+{
+	char *str;
+
+	if (!tracefs_file_exists(instance->tracefs, "error_log"))
+		return;
+	str = get_instance_file_content(instance, "error_log");
+	if (!str)
+		return;
+
+	if (str[0])
+		printf("\nError log:\n%s\n", str);
+
+	free(str);
+}
+
 static void stat_instance(struct buffer_instance *instance)
 {
 	if (instance != &top_instance) {
@@ -920,6 +936,7 @@  static void stat_instance(struct buffer_instance *instance)
 	report_kprobes(instance);
 	report_uprobes(instance);
 	report_traceon(instance);
+	report_errorlog(instance);
 }
 
 void trace_stat (int argc, char **argv)