All of lore.kernel.org
 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 v3 4/8] trace-cmd library: New API to copy buffer description between trace files
Date: Fri,  8 Oct 2021 07:25:06 +0300	[thread overview]
Message-ID: <20211008042510.978362-5-tz.stoyanov@gmail.com> (raw)
In-Reply-To: <20211008042510.978362-1-tz.stoyanov@gmail.com>

A new library API is introduced, to copy buffers description between
trace files:
	tracecmd_copy_buffer_descr()

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 lib/trace-cmd/include/private/trace-cmd-private.h |  2 ++
 lib/trace-cmd/trace-input.c                       | 13 +++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/lib/trace-cmd/include/private/trace-cmd-private.h b/lib/trace-cmd/include/private/trace-cmd-private.h
index 8ff46d52..4930063e 100644
--- a/lib/trace-cmd/include/private/trace-cmd-private.h
+++ b/lib/trace-cmd/include/private/trace-cmd-private.h
@@ -189,6 +189,8 @@ int tracecmd_copy_headers(struct tracecmd_input *in_handle,
 			  struct tracecmd_output *out_handle,
 			  enum tracecmd_file_states start_state,
 			  enum tracecmd_file_states end_state);
+int tracecmd_copy_buffer_descr(struct tracecmd_input *in_handle,
+			       struct tracecmd_output *out_handle);
 void tracecmd_set_flag(struct tracecmd_input *handle, int flag);
 void tracecmd_clear_flag(struct tracecmd_input *handle, int flag);
 unsigned long tracecmd_get_flags(struct tracecmd_input *handle);
diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index cde613f3..63a4e7f2 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -4890,6 +4890,19 @@ int tracecmd_copy_headers(struct tracecmd_input *in_handle,
 	return ret < 0 ? -1 : 0;
 }
 
+int tracecmd_copy_buffer_descr(struct tracecmd_input *in_handle,
+			       struct tracecmd_output *out_handle)
+{
+	int i;
+
+	if (tracecmd_get_out_file_version(out_handle) >= FILE_VERSION_SECTIONS)
+		return 0;
+
+	for (i = 0; i < in_handle->nr_buffers; i++)
+		tracecmd_add_buffer_info(out_handle, in_handle->buffers[i].name, 0);
+	return tracecmd_write_buffer_info(out_handle);
+}
+
 /**
  * tracecmd_record_at_buffer_start - return true if record is first on subbuffer
  * @handle: input handle for the trace.dat file
-- 
2.31.1


  parent reply	other threads:[~2021-10-08  4:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-08  4:25 [PATCH v3 0/8] trace-cmd convert Tzvetomir Stoyanov (VMware)
2021-10-08  4:25 ` [PATCH v3 1/8] trace-cmd library: Use output handler when copying data from input file Tzvetomir Stoyanov (VMware)
2021-10-08  4:25 ` [PATCH v3 2/8] trace-cmd library: Handle version 7 files when copying headers between files Tzvetomir Stoyanov (VMware)
2021-10-08  4:25 ` [PATCH v3 3/8] trace-cmd library: Copy CPU count between trace files Tzvetomir Stoyanov (VMware)
2021-10-08  4:25 ` Tzvetomir Stoyanov (VMware) [this message]
2021-10-08  4:25 ` [PATCH v3 5/8] trace-cmd library: New API to copy options " Tzvetomir Stoyanov (VMware)
2021-10-08  4:25 ` [PATCH v3 6/8] trace-cmd library: New API to copy trace data " Tzvetomir Stoyanov (VMware)
2021-10-08  4:25 ` [PATCH v3 7/8] trace-cmd library: Extend tracecmd_copy() API Tzvetomir Stoyanov (VMware)
2021-10-08  4:25 ` [PATCH v3 8/8] trace-cmd: Add new subcommand "convert" 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=20211008042510.978362-5-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 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.