* [PATCH v2] trace-cmd: Clear synthetic events on reset subcommand
@ 2020-02-20 9:43 Tzvetomir Stoyanov (VMware)
0 siblings, 0 replies; only message in thread
From: Tzvetomir Stoyanov (VMware) @ 2020-02-20 9:43 UTC (permalink / raw)
To: rostedt; +Cc: linux-trace-devel
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-02-20 9:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-20 9:43 [PATCH v2] trace-cmd: Clear synthetic events on reset subcommand Tzvetomir Stoyanov (VMware)
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).