Skip to contentSkip to conversation

Enhancements of the "trace-cmd stat" command

PATCH New Tzvetomir Stoyanov (VMware) 1 participant 3 messages Apr 16, 2020 Documentation

lore
Share & tools
lore
#0 lore raw

cover Enhancements of the "trace-cmd stat" command

"error_log" dump is added to the trace-cmd stat command. Man page is updated.

Tzvetomir Stoyanov (VMware) (2):
trace-cmd: Update tarce-cmd stat man page with instances list
trace-cmd: Add error_log dump to trace-cmd stat command

 Documentation/trace-cmd-stat.1.txt |  4 ++++
 tracecmd/trace-stat.c              | 17 +++++++++++++++++
 2 files changed, 21 insertions(+)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 trace-cmd: Update tarce-cmd stat man page with instances list

Recently, the "tarce-cmd stat" command was enhanced to list all configured ftrace instances. However, the man page was not updated with this new output.

---
 Documentation/trace-cmd-stat.1.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/trace-cmd-stat.1.txt +2 -0
index 4a29b143..004fbaa5 100644
@@ -14,6 +14,8 @@ DESCRIPTION
 The trace-cmd(1) stat displays the various status of the tracing (ftrace)
 system. The status that it shows is:
 
+*Instances:* List all configured ftrace instances.
+
 *Tracer:* if one of the tracers (like function_graph) is active. Otherwise
   nothing is displayed.
 
Signature · 1 line
2.25.1
#2 lore raw

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

In reply to Tzvetomir Stoyanov (VMware)

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.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=207291

---
 Documentation/trace-cmd-stat.1.txt |  2 ++
 tracecmd/trace-stat.c              | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)
Documentation/trace-cmd-stat.1.txt +2 -0
index 004fbaa5..2f1a9c8b 100644
@@ -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),
tracecmd/trace-stat.c +17 -0
index 3f7b3493..c5057978 100644
@@ -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)
Signature · 1 line
2.25.1