trace-cmd list: Show all functions that match string by default
PATCH 1/1 trace-cmd list: Show all functions that match string by default
From: "Steven Rostedt (Google)" <[email protected]>
Before tracefs_filter_functions() was used to find the list of functions, the trace-cmd list -f would list all functions that match the given string by default. After the switching over to tracefs_filter_functions(), by default it does a exact match.
This is quite annoying, as in most cases the user wants to see what available functions have the given string. If the user knows the function they are looking for, they do not need to use trace-cmd list -f !
Fixes 39acb4cc1 ("trace-cmd list: Use tracefs_filter_functions()")
Signed-off-by Steven Rostedt (Google) <[email protected]>
--- tracecmd/trace-list.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
tracecmd/trace-list.c +24 -0
@@ -466,6 +466,8 @@ static void show_clocks(void)static void show_functions (const char *funcre) { +bool found = false; +char *new_re =NULL ;char **list;int i;
@@ -474,11 +476,33 @@ static void show_functions(const char *funcre)return ; } +/* if the re doesn't have any regular expressions, then add them */ +for (i =0 ; !found && funcre[i]; i++) { +if (funcre[i] =='\\' ) +continue ; +switch (funcre[i]) { +case '*' : +case '[' : +case '(' : +case '.' : +case '?' : + found = true; + } + } + +if (!found) { +/* Add glob around expression */ +if (asprintf (&new_re,"*%s*" , funcre) <0 ) +die ("Failed to allocate memory" ); + funcre = new_re; + } +if (tracefs_filter_functions (funcre,NULL , &list) <0 )die ("Failed to read filte functions" );for (i =0 ; list && list[i]; i++)printf ("%s\n" , list[i]);tracefs_list_free (list); +free (new_re); }
Signature · 1 line
2.47.2