linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-trace-devel@vger.kernel.org
Cc: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
Subject: [PATCH 3/8] trace-cmd: Move tracecmd_write_cmdlines() out of tracecmd_append_cpu_data()
Date: Mon, 01 Mar 2021 09:37:27 -0500	[thread overview]
Message-ID: <20210301143857.098048355@goodmis.org> (raw)
In-Reply-To: 20210301143724.540985351@goodmis.org

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

When the saved_cmdlines was moved to after the recording, as it makes sense
because they are created during the recording, the saving was just tossed
into tracecmd_append_cpu_data() as that was called at the end of recording.

Unfortunately, the trace-cmd restore (as well as trace-cmd split) used the
tracecmd_append_cpu_data() but expecting it not store the saved_cmdlines.
This broke both of them.

Now that there's an API called tracecmd_write_cmdlines(), have those that
need it call it directly, and remove it out of tracecmd_append_cpu_data().

Note, although this can help the trace-cmd restore code, it appears that the
code for trace-cmd split may still be broken, and needs to be fixed.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 lib/trace-cmd/trace-output.c | 10 +++-------
 tracecmd/trace-record.c      |  3 +++
 tracecmd/trace-split.c       |  4 ++++
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/lib/trace-cmd/trace-output.c b/lib/trace-cmd/trace-output.c
index c8f8a106c295..917d20cfcfd6 100644
--- a/lib/trace-cmd/trace-output.c
+++ b/lib/trace-cmd/trace-output.c
@@ -1446,13 +1446,6 @@ int tracecmd_append_cpu_data(struct tracecmd_output *handle,
 {
 	int ret;
 
-	/*
-	 * Save the command lines;
-	 */
-	ret = tracecmd_write_cmdlines(handle);
-	if (ret)
-		return ret;
-
 	ret = tracecmd_write_cpus(handle, cpus);
 	if (ret)
 		return ret;
@@ -1554,6 +1547,9 @@ tracecmd_create_file_glob(const char *output_file,
 	if (!handle)
 		return NULL;
 
+	if (tracecmd_write_cmdlines(handle))
+		return NULL;
+
 	if (tracecmd_append_cpu_data(handle, cpus, cpu_data_files) < 0) {
 		tracecmd_output_close(handle);
 		return NULL;
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index 4337967e11e5..e7428788b1bb 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -4236,6 +4236,9 @@ static void record_data(struct common_record_context *ctx)
 				add_guest_info(handle, instance);
 		}
 
+		if (tracecmd_write_cmdlines(handle))
+			die("Writing cmdlines");
+
 		tracecmd_append_cpu_data(handle, local_cpu_count, temp_files);
 
 		for (i = 0; i < max_cpu_count; i++)
diff --git a/tracecmd/trace-split.c b/tracecmd/trace-split.c
index 8366d1286d9e..7c9863d481bc 100644
--- a/tracecmd/trace-split.c
+++ b/tracecmd/trace-split.c
@@ -384,6 +384,10 @@ static double parse_file(struct tracecmd_input *handle,
 	for (cpu = 0; cpu < cpus; cpu ++)
 		cpu_list[cpu] = cpu_data[cpu].file;
 
+	/* TODO: Fix me, this is suppose to come from handle */
+	if (tracecmd_write_cmdlines(ohandle))
+		die("Writing cmdlines");
+
 	tracecmd_append_cpu_data(ohandle, cpus, cpu_list);
 
 	current = end;
-- 
2.30.0



  parent reply	other threads:[~2021-03-01 14:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-01 14:37 [PATCH 0/8] trace-cmd: Fixes for trace-cmd restore Steven Rostedt
2021-03-01 14:37 ` [PATCH 1/8] trace-cmd restore: Fix to add saved cmdlines after calling tracecmd_create_init_file_override() Steven Rostedt
2021-03-01 14:37 ` [PATCH 2/8] trace-cmd: Create API tracecmd_read_pre_headers() Steven Rostedt
2021-03-02  4:49   ` Tzvetomir Stoyanov
2021-03-02 14:13     ` Steven Rostedt
2021-03-01 14:37 ` Steven Rostedt [this message]
2021-03-01 14:37 ` [PATCH 4/8] trace-cmd: Move the output state updates into the functions that change the state Steven Rostedt
2021-03-01 14:37 ` [PATCH 5/8] trace-cmd: Move the input " Steven Rostedt
2021-03-01 14:37 ` [PATCH 6/8] trace-cmd output: Set file_state of output handle after copy of headers Steven Rostedt
2021-03-02  8:10   ` Tzvetomir Stoyanov
2021-03-02 14:19     ` Steven Rostedt
2021-03-02 14:51       ` Tzvetomir Stoyanov
2021-03-02 15:48         ` Steven Rostedt
2021-03-02 17:35           ` Tzvetomir Stoyanov
2021-03-02 19:59             ` Steven Rostedt
2021-03-02 14:22     ` Steven Rostedt
2021-03-01 14:37 ` [PATCH 7/8] trace-cmd input: Validate the input handle when copying from it Steven Rostedt
2021-03-01 14:37 ` [PATCH 8/8] trace-cmd input: Add validation updates to the copy of a handle 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=20210301143857.098048355@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=tz.stoyanov@gmail.com \
    /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).