From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH v2] trace-cmd: Clear synthetic events on reset subcommand
Date: Thu, 20 Feb 2020 11:43:15 +0200 [thread overview]
Message-ID: <20200220094315.467649-1-tz.stoyanov@gmail.com> (raw)
The "trace-cmd reset" command is supposed to set the ftrace state to default.
However, the synthetic events are not reseted.
A logic is added to delete all entries from "synthetic_events" files.
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
v2: remove the warning in case there are no configured synthetic events
---
tracecmd/trace-record.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index 4a49b640..881efe44 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -4638,6 +4638,41 @@ static void clear_triggers(void)
clear_instance_triggers(instance);
}
+static void clear_all_synth_events(void)
+{
+ char sevent[BUFSIZ];
+ char *save = NULL;
+ char *line;
+ char *file;
+ char *buf;
+ int len;
+
+ file = tracefs_instance_get_file(NULL, "synthetic_events");
+ if (!file)
+ return;
+
+ buf = read_file(file);
+ if (!buf)
+ goto out;
+
+ sevent[0] = '!';
+
+ for (line = strtok_r(buf, "\n", &save); line; line = strtok_r(NULL, "\n", &save)) {
+ len = strlen(line);
+ if (len > BUFSIZ - 2)
+ len = BUFSIZ - 2;
+ strncpy(sevent + 1, line, len);
+ sevent[len + 1] = '\0';
+ write_file(file, sevent);
+ }
+out:
+ free(buf);
+ tracefs_put_tracing_file(file);
+
+}
+
+
+
static void clear_func_filters(void)
{
struct buffer_instance *instance;
@@ -5344,6 +5379,7 @@ void trace_reset(int argc, char **argv)
set_buffer_size();
clear_filters();
clear_triggers();
+ clear_all_synth_events();
/* set clock to "local" */
reset_clock();
reset_event_pid();
--
2.24.1
reply other threads:[~2020-02-20 9:43 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=20200220094315.467649-1-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.