diff mbox series

[3/4] libtracefs: Allow filter to be NULL if module is set in tracefs_function_filter()

Message ID 20210330183546.207110833@goodmis.org (mailing list archive)
State Accepted
Commit 9390fc2ee60adfadbedccf15d8bc4279dd9ae61f
Headers show
Series libtracefs: More updates to tracefs_function_filter() | expand

Commit Message

Steven Rostedt March 30, 2021, 6:33 p.m. UTC
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

If the module is set then a NULL filter will be the same as if "*" was
passed in as filter. This will select all the functions for a given
module.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 Documentation/libtracefs-function-filter.txt | 4 +++-
 src/tracefs-tools.c                          | 4 ++++
 2 files changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/Documentation/libtracefs-function-filter.txt b/Documentation/libtracefs-function-filter.txt
index a4218b75deea..fa0f0de6f567 100644
--- a/Documentation/libtracefs-function-filter.txt
+++ b/Documentation/libtracefs-function-filter.txt
@@ -37,7 +37,9 @@  not a period, but will match any one character. To force a regular
 expression, either prefix _filter_ with a '^' or append it with a '$' as
 the _filter_ does complete matches of the functions anyway.
 
-The _filter_ may be NULL if a previous call to *tracefs_function_filter()* with
+If _module_ is set and _filter_ is NULL, this will imply the same as _filter_ being
+equal to "pass:[*]". Which will enable all functions for a given _module_. Otherwise
+the _filter_ may be NULL if a previous call to *tracefs_function_filter()* with
 the same _instance_ had *TRACEFS_FL_CONTINUE* set and this call does not. This is
 useful to simply commit the previous filters. It may also be NULL
 if *TRACEFS_FL_RESET* is set and the previous call did not have the same _instance_
diff --git a/src/tracefs-tools.c b/src/tracefs-tools.c
index a9a51beb02b2..82809fae3e6d 100644
--- a/src/tracefs-tools.c
+++ b/src/tracefs-tools.c
@@ -786,6 +786,10 @@  int tracefs_function_filter(struct tracefs_instance *instance, const char *filte
 	 */
 	errno = EINVAL;
 
+	/* module set with NULL filter means to enable all functions in a module */
+	if (module && !filter)
+		filter = "*";
+
 	if (!filter) {
 		/* OK to call without filters if this is closing the opened file */
 		if (!cont && *fd >= 0) {