-
Notifications
You must be signed in to change notification settings - Fork 480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
utils: add more detailed help message #1813
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,6 +239,64 @@ __used static const char uftrace_help[] = | |
" Try `man uftrace [COMMAND]' for more information.\n" | ||
"\n"; | ||
|
||
__used static const char uftrace_record_usage[] = | ||
" COMMAND:\n" | ||
" record Run a program and saves the trace data\n" | ||
"\n"; | ||
|
||
__used static const char uftrace_replay_usage[] = | ||
" COMMAND:\n" | ||
" replay Show program execution in the trace data\n" | ||
"\n"; | ||
|
||
|
||
__used static const char uftrace_report_usage[] = | ||
" COMMAND:\n" | ||
" report Show performance statistics in the trace data\n" | ||
"\n"; | ||
|
||
|
||
__used static const char uftrace_live_usage[] = | ||
" COMMAND:\n" | ||
" live Do record and replay in a row (default)\n" | ||
"\n"; | ||
|
||
|
||
__used static const char uftrace_info_usage[] = | ||
" COMMAND:\n" | ||
" info Show system and program info in the trace data\n" | ||
"\n"; | ||
|
||
|
||
__used static const char uftrace_dump_usage[] = | ||
" COMMAND:\n" | ||
" dump Show low-level trace data\n" | ||
"\n"; | ||
|
||
|
||
__used static const char uftrace_recv_usage[] = | ||
" COMMAND:\n" | ||
" recv Save the trace data from network\n" | ||
"\n"; | ||
|
||
|
||
__used static const char uftrace_graph_usage[] = | ||
" COMMAND:\n" | ||
" graph Show function call graph in the trace data\n" | ||
"\n"; | ||
|
||
|
||
__used static const char uftrace_script_usage[] = | ||
" COMMAND:\n" | ||
" script Run a script for recorded trace data\n" | ||
"\n"; | ||
|
||
|
||
__used static const char uftrace_tui_usage[] = | ||
" COMMAND:\n" | ||
" tui Show text user interface for graph and report\n" | ||
"\n"; | ||
|
||
__used static const char uftrace_footer[] = | ||
" Try `uftrace --help' or `man uftrace [COMMAND]' for more information.\n" | ||
"\n"; | ||
|
@@ -1130,6 +1188,49 @@ static void update_subcmd(struct uftrace_opts *opts, char *cmd) | |
opts->mode = UFTRACE_MODE_INVALID; | ||
} | ||
|
||
static int print_subhelp(int beforekey) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be |
||
{ | ||
int retval = -1; | ||
switch (beforekey) { | ||
case UFTRACE_MODE_RECORD: | ||
pr_out(uftrace_record_usage); | ||
break; | ||
case UFTRACE_MODE_REPLAY: | ||
pr_out(uftrace_replay_usage); | ||
break; | ||
case UFTRACE_MODE_REPORT: | ||
pr_out(uftrace_report_usage); | ||
break; | ||
case UFTRACE_MODE_LIVE: | ||
pr_out(uftrace_live_usage); | ||
break; | ||
case UFTRACE_MODE_GRAPH: | ||
pr_out(uftrace_graph_usage); | ||
break; | ||
case UFTRACE_MODE_INFO: | ||
pr_out(uftrace_info_usage); | ||
break; | ||
case UFTRACE_MODE_DUMP: | ||
pr_out(uftrace_dump_usage); | ||
break; | ||
case UFTRACE_MODE_RECV: | ||
pr_out(uftrace_recv_usage); | ||
break; | ||
case UFTRACE_MODE_SCRIPT: | ||
pr_out(uftrace_script_usage); | ||
break; | ||
case UFTRACE_MODE_TUI: | ||
pr_out(uftrace_tui_usage); | ||
break; | ||
case UFTRACE_MODE_INVALID: | ||
default: | ||
retval = -3; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What the |
||
break; | ||
} | ||
|
||
return (retval); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't use parenthesis for return statement. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RndelQndel |
||
} | ||
|
||
static void parse_opt_file(int *argc, char ***argv, char *filename, struct uftrace_opts *opts) | ||
{ | ||
int file_argc; | ||
|
@@ -1324,6 +1425,7 @@ static void free_opts(struct uftrace_opts *opts) | |
static int parse_options(int argc, char **argv, struct uftrace_opts *opts) | ||
{ | ||
/* initial option parsing index */ | ||
int beforekey = 0; | ||
optind = 1; | ||
|
||
while (true) { | ||
|
@@ -1335,12 +1437,16 @@ static int parse_options(int argc, char **argv, struct uftrace_opts *opts) | |
update_subcmd(opts, argv[optind]); | ||
|
||
if (opts->mode != UFTRACE_MODE_INVALID) { | ||
beforekey = opts->mode; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not use |
||
optind++; | ||
continue; | ||
} | ||
} | ||
break; | ||
} | ||
else if ('h' == (char)key) { | ||
return (print_subhelp(beforekey)); | ||
} | ||
|
||
tmp = parse_option(opts, key, optarg); | ||
if (tmp < 0) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice to list available options (only for the subcommand) as well.