diff mbox series

[2/4] trace-cmd: Add tsc2nsec clock to "list -C" command

Message ID 20210329125821.97496-3-tz.stoyanov@gmail.com (mailing list archive)
State Accepted
Headers show
Series Documented new trace-cmd options | expand

Commit Message

Tzvetomir Stoyanov (VMware) March 29, 2021, 12:58 p.m. UTC
Extended the "trace-cmd list -C" command to show tsc2nsec clock, if
supported.

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 tracecmd/trace-list.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tracecmd/trace-list.c b/tracecmd/trace-list.c
index f017c938..63216b43 100644
--- a/tracecmd/trace-list.c
+++ b/tracecmd/trace-list.c
@@ -264,7 +264,21 @@  static void show_options(void)
 
 static void show_clocks(void)
 {
-	show_file("trace_clock");
+	char *clocks;
+	int size;
+
+	clocks = tracefs_instance_file_read(NULL, "trace_clock", &size);
+	if (!clocks)
+		die("getting clocks");
+	if (clocks[size - 1] == '\n')
+		clocks[size - 1] = 0;
+
+	if (trace_tsc2nsec_is_supported())
+		printf("%s %s\n", clocks, TSCNSEC_CLOCK);
+	else
+		printf("%s\n", clocks);
+
+	free(clocks);
 }