trace-cmd reset: Clear all dynamic events
PATCH 1/1 trace-cmd reset: Clear all dynamic events
The "trace-cmd reset" command should set ftrace state to default, including all dynamically created events. Currently only synthetic events are deleted. The command is enhanced to delete all dynamic events, using the new tracefs library API for dynamic events.
--- tracecmd/trace-record.c | 43 ++++++++++------------------------------- 1 file changed, 10 insertions(+), 33 deletions(-)
tracecmd/trace-record.c +10 -33
@@ -5221,41 +5221,18 @@ static void clear_error_log(void)clear_instance_error_log (instance); } -static void clear_all_synth_events (void ) +static void clear_all_dynamic_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); - +/* Clear event probes first, as they may be attached to other dynamic event */ +tracefs_dynevent_destroy_all (TRACEFS_DYNEVENT_EPROBE , true); +tracefs_dynevent_destroy_all (TRACEFS_DYNEVENT_KPROBE | +TRACEFS_DYNEVENT_KRETPROBE | +TRACEFS_DYNEVENT_UPROBE | +TRACEFS_DYNEVENT_URETPROBE | +TRACEFS_DYNEVENT_SYNTH , + true); } - -static void clear_func_filters (void ) {struct buffer_instance *instance;
@@ -5951,7 +5928,7 @@ void trace_reset(int argc, char **argv)set_buffer_size ();clear_filters ();clear_triggers (); -clear_all_synth_events (); +clear_all_dynamic_events ();clear_error_log ();/* set clock to "local" */ reset_clock ();
Signature · 1 line
2.34.1
tracecmd/trace-record.c static void clear_error_log(void) · line 5234
Quoted 9 lines · On Fri, 14 Jan 2022 12:57:48 +0200 "Tzvetomir Stoyanov (VMware)"…
tracecmd/trace-record.c +8
-0+/* Clear event probes first, as they may be attached to other dynamic event */ +tracefs_dynevent_destroy_all (TRACEFS_DYNEVENT_EPROBE , true); +tracefs_dynevent_destroy_all (TRACEFS_DYNEVENT_KPROBE | +TRACEFS_DYNEVENT_KRETPROBE | +TRACEFS_DYNEVENT_UPROBE | +TRACEFS_DYNEVENT_URETPROBE | +TRACEFS_DYNEVENT_SYNTH , + true); }
I accepted this patch, but really, tracefs needs something to define:
TRACEFS_DYNEVENT_ALL
as callers should not have to call out each type of dynamic event. Especially when we are about to add new dynamic events, causing this to break again.
Want to add that?
Thanks Tzvetomir,
-- Steve
Quoted 16 lines · Steven Rostedt
tracecmd/trace-record.c static void clear_error_log(void) · line 5234
Quoted 9 lines · On Fri, 14 Jan 2022 12:57:48 +0200 "Tzvetomir Stoyanov (VMware)"…
tracecmd/trace-record.c +8
-0+/* Clear event probes first, as they may be attached to other dynamic event */ +tracefs_dynevent_destroy_all (TRACEFS_DYNEVENT_EPROBE , true); +tracefs_dynevent_destroy_all (TRACEFS_DYNEVENT_KPROBE | +TRACEFS_DYNEVENT_KRETPROBE | +TRACEFS_DYNEVENT_UPROBE | +TRACEFS_DYNEVENT_URETPROBE | +TRACEFS_DYNEVENT_SYNTH , + true); }I accepted this patch, but really, tracefs needs something to define:
Quoted 8 lines
TRACEFS_DYNEVENT_ALLas callers should not have to call out each type of dynamic event. Especially when we are about to add new dynamic events, causing this to break again.
Want to add that?
Sure, I'll send a patch with that.
Thanks!
Quoted 3 lines
Thanks Tzvetomir,
-- Steve
Signature · 2 lines
Tzvetomir (Ceco) Stoyanov VMware Open Source Technology Center