linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH 2/4] trace-cmd: Add tsc2nsec clock to "list -C" command
Date: Mon, 29 Mar 2021 15:58:19 +0300	[thread overview]
Message-ID: <20210329125821.97496-3-tz.stoyanov@gmail.com> (raw)
In-Reply-To: <20210329125821.97496-1-tz.stoyanov@gmail.com>

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 --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);
 }
 
 
-- 
2.30.2


  parent reply	other threads:[~2021-03-29 12:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-29 12:58 [PATCH 0/4] Documented new trace-cmd options Tzvetomir Stoyanov (VMware)
2021-03-29 12:58 ` [PATCH 1/4] trace-cmd: Add internal API to check if tsc2nsec is supported Tzvetomir Stoyanov (VMware)
2021-03-30 21:37   ` Steven Rostedt
2021-03-29 12:58 ` Tzvetomir Stoyanov (VMware) [this message]
2021-03-29 12:58 ` [PATCH 3/4] trace-cmd: Document --tsc2nsec option Tzvetomir Stoyanov (VMware)
2021-03-29 12:58 ` [PATCH 4/4] trace-cmd: Document --raw-ts option Tzvetomir Stoyanov (VMware)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210329125821.97496-3-tz.stoyanov@gmail.com \
    --to=tz.stoyanov@gmail.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).