trace-cmd: Clear synthetic events on reset subcommand
PATCH v3 1/1 trace-cmd: Clear synthetic events on reset subcommand
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) <[email protected]>
---
v3: remove the warning in case there are no configured synthetic events
v2: remove the patch from "SQL-like syntax for ftrace histograms configuration" patch set
--- tracecmd/trace-record.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
tracecmd/trace-record.c +36 -0
@@ -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 ();
Signature · 1 line
2.24.1