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@xxxxxxxxx> --- tracecmd/trace-record.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index 4a49b64..b6a412e 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -4638,6 +4638,43 @@ 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) { + perror(file); + 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 +5381,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