@@ -879,17 +879,7 @@ int cmd_ftrace(int argc, const char **argv)
879
879
.tracer = DEFAULT_TRACER ,
880
880
.target = { .uid = UINT_MAX , },
881
881
};
882
- const char * const ftrace_usage [] = {
883
- "perf ftrace [<options>] [<command>]" ,
884
- "perf ftrace [<options>] -- <command> [<options>]" ,
885
- NULL
886
- };
887
- const struct option ftrace_options [] = {
888
- OPT_STRING ('t' , "tracer" , & ftrace .tracer , "tracer" ,
889
- "Tracer to use: function_graph(default) or function" ),
890
- OPT_CALLBACK_DEFAULT ('F' , "funcs" , NULL , "[FILTER]" ,
891
- "Show available functions to filter" ,
892
- opt_list_avail_functions , "*" ),
882
+ const struct option common_options [] = {
893
883
OPT_STRING ('p' , "pid" , & ftrace .target .pid , "pid" ,
894
884
"Trace on existing process id" ),
895
885
/* TODO: Add short option -t after -t/--tracer can be removed. */
@@ -901,6 +891,14 @@ int cmd_ftrace(int argc, const char **argv)
901
891
"System-wide collection from all CPUs" ),
902
892
OPT_STRING ('C' , "cpu" , & ftrace .target .cpu_list , "cpu" ,
903
893
"List of cpus to monitor" ),
894
+ OPT_END ()
895
+ };
896
+ const struct option ftrace_options [] = {
897
+ OPT_STRING ('t' , "tracer" , & ftrace .tracer , "tracer" ,
898
+ "Tracer to use: function_graph(default) or function" ),
899
+ OPT_CALLBACK_DEFAULT ('F' , "funcs" , NULL , "[FILTER]" ,
900
+ "Show available functions to filter" ,
901
+ opt_list_avail_functions , "*" ),
904
902
OPT_CALLBACK ('T' , "trace-funcs" , & ftrace .filters , "func" ,
905
903
"Trace given functions using function tracer" ,
906
904
parse_filter_func ),
@@ -923,7 +921,15 @@ int cmd_ftrace(int argc, const char **argv)
923
921
"Trace children processes" ),
924
922
OPT_UINTEGER ('D' , "delay" , & ftrace .initial_delay ,
925
923
"Number of milliseconds to wait before starting tracing after program start" ),
926
- OPT_END ()
924
+ OPT_PARENT (common_options ),
925
+ };
926
+
927
+ const char * const ftrace_usage [] = {
928
+ "perf ftrace [<options>] [<command>]" ,
929
+ "perf ftrace [<options>] -- [<command>] [<options>]" ,
930
+ "perf ftrace trace [<options>] [<command>]" ,
931
+ "perf ftrace trace [<options>] -- [<command>] [<options>]" ,
932
+ NULL
927
933
};
928
934
929
935
INIT_LIST_HEAD (& ftrace .filters );
@@ -935,6 +941,11 @@ int cmd_ftrace(int argc, const char **argv)
935
941
if (ret < 0 )
936
942
return -1 ;
937
943
944
+ if (argc > 1 && !strcmp (argv [1 ], "trace" )) {
945
+ argc -- ;
946
+ argv ++ ;
947
+ }
948
+
938
949
argc = parse_options (argc , argv , ftrace_options , ftrace_usage ,
939
950
PARSE_OPT_STOP_AT_NON_OPTION );
940
951
if (!argc && target__none (& ftrace .target ))
0 commit comments