From: Steven Rostedt <rostedt@goodmis.org>
To: <linux-trace-devel@vger.kernel.org>
Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
Subject: [PATCH 2/2] trace-cmd list: Add ftrace events to listing of events
Date: Fri, 16 Apr 2021 17:30:18 -0400 [thread overview]
Message-ID: <20210416213018.3890036-3-rostedt@goodmis.org> (raw)
In-Reply-To: <20210416213018.3890036-1-rostedt@goodmis.org>
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
If a search of events is done with trace-cmd list -e, check if any matches
the ftrace events. This is useful to get the fields and print fmt of the
events under the ftrace system.
Note, just "trace-cmd list -e" will still not list ftrace events by
default.
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
tracecmd/trace-list.c | 52 +++++++++++++++++++++++++++----------------
1 file changed, 33 insertions(+), 19 deletions(-)
diff --git a/tracecmd/trace-list.c b/tracecmd/trace-list.c
index 84ee573b..81f157ac 100644
--- a/tracecmd/trace-list.c
+++ b/tracecmd/trace-list.c
@@ -139,18 +139,34 @@ static void show_event_systems(process_file_func func, char **systems)
}
+static void match_system_events(process_file_func func, const char *system,
+ regex_t *reg)
+{
+ char **events;
+ int e;
+
+ events = tracefs_system_events(NULL, system);
+ if (!events) /* die? */
+ return;
+ for (e = 0; events[e]; e++) {
+ if (regexec(reg, events[e], 0, NULL, 0) == 0)
+ show_event(func, system, events[e]);
+ }
+ tracefs_list_free(events);
+}
+
static void process_events(process_file_func func, const char *re)
{
regex_t system_reg;
regex_t event_reg;
+ const char *ftrace = "ftrace";
char *str;
size_t l = strlen(re);
bool just_systems = true;
char **systems;
- char **events;
char *system;
char *event;
- int s, e;
+ int s;
systems = tracefs_event_systems(NULL);
if (!systems)
@@ -184,6 +200,19 @@ static void process_events(process_file_func func, const char *re)
}
free(str);
+ /*
+ * See if this matches the special ftrace system, as ftrace is not included
+ * in the systems list, but can get events from tracefs_system_events().
+ */
+ if (regexec(&system_reg, ftrace, 0, NULL, 0) == 0) {
+ if (!event)
+ show_system(func, ftrace);
+ else
+ match_system_events(func, ftrace, &event_reg);
+ } else if (!just_systems) {
+ match_system_events(func, ftrace, &system_reg);
+ }
+
for (s = 0; systems[s]; s++) {
if (regexec(&system_reg, systems[s], 0, NULL, 0) == 0) {
@@ -191,28 +220,13 @@ static void process_events(process_file_func func, const char *re)
show_system(func, systems[s]);
continue;
}
- events = tracefs_system_events(NULL, systems[s]);
- if (!events) /* die? */
- continue;
- for (e = 0; events[e]; e++) {
- if (regexec(&event_reg, events[e], 0, NULL, 0) == 0)
- show_event(func, systems[s], events[e]);
- }
- tracefs_list_free(events);
+ match_system_events(func, systems[s], &event_reg);
continue;
}
if (just_systems)
continue;
- events = tracefs_system_events(NULL, systems[s]);
- if (!events) /* die? */
- continue;
-
- for (e = 0; events[e]; e++) {
- if (regexec(&system_reg, events[e], 0, NULL, 0) == 0)
- show_event(func, systems[s], events[e]);
- }
- tracefs_list_free(events);
+ match_system_events(func, systems[s], &system_reg);
}
tracefs_list_free(systems);
--
2.29.2
prev parent reply other threads:[~2021-04-16 21:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-16 21:30 [PATCH 0/2] trace-cmd list: Include ftrace in event listings Steven Rostedt
2021-04-16 21:30 ` [PATCH 1/2] trace-cmd list: Use tracefs to help find events for -e Steven Rostedt
2021-04-19 5:10 ` Tzvetomir Stoyanov
2021-04-22 21:14 ` Steven Rostedt
2021-04-16 21:30 ` Steven Rostedt [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210416213018.3890036-3-rostedt@goodmis.org \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).