All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Sartain <mikesart@fastmail.com>
To: linux-trace-devel@vger.kernel.org
Cc: Michael Sartain <mikesart@fastmail.com>
Subject: [PATCH] trace-cmd library: Add API to get information from trace file
Date: Tue, 30 Nov 2021 19:24:31 -0700	[thread overview]
Message-ID: <20211201022431.64763-1-mikesart@fastmail.com> (raw)

New APIs added to get trace cpustats, uname, version strings, and
cpu file sizes and offsets.

  const char *tracecmd_get_cpustats(struct tracecmd_input *handle);
  const char *tracecmd_get_uname(struct tracecmd_input *handle);
  const char *tracecmd_get_version(struct tracecmd_input *handle);
  unsigned long long tracecmd_get_cpu_file_offset(struct tracecmd_input *handle, int cpu);
  unsigned long long tracecmd_get_cpu_file_size(struct tracecmd_input *handle, int cpu);

Signed-off-by: Michael Sartain <mikesart@fastmail.com>
---
 .../include/private/trace-cmd-private.h       |  6 +++++
 lib/trace-cmd/trace-input.c                   | 25 +++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/lib/trace-cmd/include/private/trace-cmd-private.h b/lib/trace-cmd/include/private/trace-cmd-private.h
index c58b09e..cd78cc9 100644
--- a/lib/trace-cmd/include/private/trace-cmd-private.h
+++ b/lib/trace-cmd/include/private/trace-cmd-private.h
@@ -90,6 +90,12 @@ bool tracecmd_get_quiet(struct tracecmd_output *handle);
 void tracecmd_set_out_clock(struct tracecmd_output *handle, const char *clock);
 const char *tracecmd_get_trace_clock(struct tracecmd_input *handle);
 
+const char *tracecmd_get_cpustats(struct tracecmd_input *handle);
+const char *tracecmd_get_uname(struct tracecmd_input *handle);
+const char *tracecmd_get_version(struct tracecmd_input *handle);
+unsigned long long tracecmd_get_cpu_file_offset(struct tracecmd_input *handle, int cpu);
+unsigned long long tracecmd_get_cpu_file_size(struct tracecmd_input *handle, int cpu);
+
 static inline int tracecmd_host_bigendian(void)
 {
 	unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 };
diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index ac57bc4..99dbca2 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -4088,6 +4088,31 @@ const char *tracecmd_get_trace_clock(struct tracecmd_input *handle)
 	return handle->trace_clock;
 }
 
+const char *tracecmd_get_cpustats(struct tracecmd_input *handle)
+{
+	return handle->cpustats;
+}
+
+const char *tracecmd_get_uname(struct tracecmd_input *handle)
+{
+	return handle->uname;
+}
+
+const char *tracecmd_get_version(struct tracecmd_input *handle)
+{
+	return handle->version;
+}
+
+unsigned long long tracecmd_get_cpu_file_offset(struct tracecmd_input *handle, int cpu)
+{
+	return (cpu < handle->cpus) ? handle->cpu_data[cpu].file_offset : 0;
+}
+
+unsigned long long tracecmd_get_cpu_file_size(struct tracecmd_input *handle, int cpu)
+{
+	return (cpu < handle->cpus) ? handle->cpu_data[cpu].file_size : 0;
+}
+
 /**
  * tracecmd_get_show_data_func - return the show data func
  * @handle: input handle for the trace.dat file
-- 
2.33.0


             reply	other threads:[~2021-12-01  2:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-01  2:24 Michael Sartain [this message]
2021-12-01 15:33 ` [PATCH] trace-cmd library: Add API to get information from trace file Steven Rostedt
2021-12-02  2:36   ` Michael Sartain
2021-12-02  2:55     ` Steven Rostedt

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=20211201022431.64763-1-mikesart@fastmail.com \
    --to=mikesart@fastmail.com \
    --cc=linux-trace-devel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.