[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210813021655.939819-2-rostedt@goodmis.org>
Date: Thu, 12 Aug 2021 22:16:49 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: linux-trace-devel@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, Tom Zanussi <zanussi@...nel.org>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
Masami Hiramatsu <mhiramat@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
linux-rt-users <linux-rt-users@...r.kernel.org>,
Clark Williams <williams@...hat.com>,
"Steven Rostedt (VMware)" <rostedt@...dmis.org>
Subject: [PATCH 1/7] libtracefs: Move creating of onmatch handler and trace action into helper functions
From: "Steven Rostedt (VMware)" <rostedt@...dmis.org>
Have the creation of the onmatch handler and the trace action both be in
their own helper function. This will help when adding other handlers
like onmax and onchange as well as other actions like snapshot and save.
Signed-off-by: Steven Rostedt (VMware) <rostedt@...dmis.org>
---
src/tracefs-hist.c | 38 +++++++++++++++++++++++++-------------
1 file changed, 25 insertions(+), 13 deletions(-)
diff --git a/src/tracefs-hist.c b/src/tracefs-hist.c
index fefe251995ba..7fffa6cc653d 100644
--- a/src/tracefs-hist.c
+++ b/src/tracefs-hist.c
@@ -1378,28 +1378,40 @@ static char *create_hist(char **keys, char **vars)
return hist;
}
-static char *create_end_hist(struct tracefs_synth *synth)
+static char *create_onmatch(char *hist, struct tracefs_synth *synth)
{
- const char *name;
- char *end_hist;
+ hist = append_string(hist, NULL, ":onmatch(");
+ hist = append_string(hist, NULL, synth->start_event->system);
+ hist = append_string(hist, NULL, ".");
+ hist = append_string(hist, NULL, synth->start_event->name);
+ return append_string(hist, NULL, ")");
+}
+
+static char *create_trace(char *hist, struct tracefs_synth *synth)
+{
+ char *name;
int i;
- end_hist = create_hist(synth->end_keys, synth->end_vars);
- end_hist = append_string(end_hist, NULL, ":onmatch(");
- end_hist = append_string(end_hist, NULL, synth->start_event->system);
- end_hist = append_string(end_hist, NULL, ".");
- end_hist = append_string(end_hist, NULL, synth->start_event->name);
- end_hist = append_string(end_hist, NULL, ").trace(");
- end_hist = append_string(end_hist, NULL, synth->name);
+ hist = append_string(hist, NULL, ".trace(");
+ hist = append_string(hist, NULL, synth->name);
for (i = 0; synth->synthetic_args && synth->synthetic_args[i]; i++) {
name = synth->synthetic_args[i];
- end_hist = append_string(end_hist, NULL, ",");
- end_hist = append_string(end_hist, NULL, name);
+ hist = append_string(hist, NULL, ",");
+ hist = append_string(hist, NULL, name);
}
- return append_string(end_hist, NULL, ")");
+ return append_string(hist, NULL, ")");
+}
+
+static char *create_end_hist(struct tracefs_synth *synth)
+{
+ char *end_hist;
+
+ end_hist = create_hist(synth->end_keys, synth->end_vars);
+ end_hist = create_onmatch(end_hist, synth);
+ return create_trace(end_hist, synth);
}
static char *append_filter(char *hist, char *filter, unsigned int parens)
--
2.30.2
Powered by blists - more mailing lists