From: Steven Rostedt <rostedt@goodmis.org>
To: Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Subject: [PATCH] trace-cmd library: Use clock local if no clock is found when creating buffer
Date: Mon, 4 Apr 2022 11:19:19 -0400 [thread overview]
Message-ID: <20220404111919.3883e905@gandalf.local.home> (raw)
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
Using restore to put together a trace.dat file from reading trace_pipe_raw
with a cat, and copying over the tracing/events and proc/kallsyms
directory from one machine to another and running trace-cmd on it.
Here's the scenario. On a machine with just a busybox environment.
# cd /sys/kernel/tracing/per_cpu
# for cpu in cpu*; do
# cat $cpu/trace_pipe_raw > /tmp/read_${cpu} &
# done
# mkdir /tmp/tracing
# cp -a /sys/kernel/tracing/events /tmp/tracing
# cp /proc/kallsyms /tmp
# cd tmp
# echo 0 > /sys/kernel/tracing/tracing_on
# tar cvzf trace-dat.tgz read_cpu* tracing kallsyms
Then on another machine:
$ scp target:/tmp/trace-dat.tgz /tmp
$ cd /tmp
$ tar xvzf /tmp/trace-dat.tgz
$ trace-cmd restore -c -o trace-head.dat -k /tmp/kallsyms -t /tmp/tracing
$ trace-cmd restore -o trace-target.dat -i trace-head.dat read_cpu*
The above ends with a segfault because get_clock() fails and then NULL
gets passed to strlen() and crashes.
Just set it to "local" and warn about it.
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
lib/trace-cmd/trace-output.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/trace-cmd/trace-output.c b/lib/trace-cmd/trace-output.c
index 73020ff1fda1..f3a203ec347f 100644
--- a/lib/trace-cmd/trace-output.c
+++ b/lib/trace-cmd/trace-output.c
@@ -2139,6 +2139,10 @@ out_add_buffer_option(struct tracecmd_output *handle, const char *name,
return NULL;
clock = get_clock(handle);
+ if (!clock) {
+ tracecmd_warning("Could not find clock, set to 'local'");
+ clock = "local";
+ }
/*
* Buffer flyrecord option:
--
2.35.1
reply other threads:[~2022-04-04 15:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220404111919.3883e905@gandalf.local.home \
--to=rostedt@goodmis.org \
--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 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).