linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] trace-cmd reset: Clear all dynamic events
@ 2022-01-14 10:57 Tzvetomir Stoyanov (VMware)
  2022-02-12  2:56 ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: Tzvetomir Stoyanov (VMware) @ 2022-01-14 10:57 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel

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.

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 tracecmd/trace-record.c | 43 ++++++++++-------------------------------
 1 file changed, 10 insertions(+), 33 deletions(-)

diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index b4200db1..aee3b01a 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -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();
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-14  4:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-14 10:57 [PATCH] trace-cmd reset: Clear all dynamic events Tzvetomir Stoyanov (VMware)
2022-02-12  2:56 ` Steven Rostedt
2022-02-14  4:15   ` Tzvetomir Stoyanov

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).