diff options
author | Yao Qi <yao@codesourcery.com> | 2013-08-27 03:04:45 +0000 |
---|---|---|
committer | Yao Qi <yao@codesourcery.com> | 2013-08-27 03:04:45 +0000 |
commit | 242f1fd7ee29538968e32155c99a36c3d7604eb5 (patch) | |
tree | 63842883ad96777ca1f546e358c1456d6fea4618 /gdb/mi/mi-cmd-stack.c | |
parent | e5034e59e04c90d3a0b6c78af0cbfd3f73eb7809 (diff) | |
download | gdb-242f1fd7ee29538968e32155c99a36c3d7604eb5.zip gdb-242f1fd7ee29538968e32155c99a36c3d7604eb5.tar.gz gdb-242f1fd7ee29538968e32155c99a36c3d7604eb5.tar.bz2 |
Add mi_getopt_allow_unknown
This patch is to add a new function mi_getopt_allow_unknown, which
returns -1 silently (without throwing error) when unknown option is
met, and use this function to parse options for command
'-stack-list-arguments'.
gdb/
* mi/mi-cmd-stack.c (parse_no_frames_option): Remove.
(mi_cmd_stack_list_args): Use mi_getopt_silent to handle
options.
* mi/mi-getopt.c (mi_getopt): Remove.
(mi_getopt_1): Renamed from mi_getopt. Add one parameter
'error_on_unknown'.
(mi_getopt): Call mi_getopt_1.
(mi_getopt_silent): New.
* mi/mi-getopt.h (mi_getopt_silent): Declare.
Diffstat (limited to 'gdb/mi/mi-cmd-stack.c')
-rw-r--r-- | gdb/mi/mi-cmd-stack.c | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index e542fc1..2df97e2 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -54,17 +54,6 @@ mi_cmd_enable_frame_filters (char *command, char **argv, int argc) frame_filters = 1; } -/* Parse the --no-frame-filters option in commands where we cannot use - mi_getopt. */ -static int -parse_no_frames_option (const char *arg) -{ - if (arg && (strcmp (arg, "--no-frame-filters") == 0)) - return 1; - - return 0; -} - /* Print a list of the stack frames. Args can be none, in which case we want to print the whole backtrace, or a pair of numbers specifying the frame numbers at which to start and stop the @@ -284,19 +273,42 @@ mi_cmd_stack_list_args (char *command, char **argv, int argc) enum print_values print_values; struct ui_out *uiout = current_uiout; int raw_arg = 0; + int oind = 0; enum py_bt_status result = PY_BT_ERROR; + enum opt + { + NO_FRAME_FILTERS, + }; + static const struct mi_opt opts[] = + { + {"-no-frame-filters", NO_FRAME_FILTERS, 0}, + { 0, 0, 0 } + }; - if (argc > 0) - raw_arg = parse_no_frames_option (argv[0]); + while (1) + { + char *oarg; + int opt = mi_getopt_allow_unknown ("-stack-list-args", argc, argv, + opts, &oind, &oarg); + + if (opt < 0) + break; + switch ((enum opt) opt) + { + case NO_FRAME_FILTERS: + raw_arg = oind; + break; + } + } - if (argc < 1 || (argc > 3 && ! raw_arg) || (argc == 2 && ! raw_arg)) - error (_("-stack-list-arguments: Usage: " \ + if (argc - oind != 1 && argc - oind != 3) + error (_("-stack-list-arguments: Usage: " \ "[--no-frame-filters] PRINT_VALUES [FRAME_LOW FRAME_HIGH]")); - if (argc >= 3) + if (argc - oind == 3) { - frame_low = atoi (argv[1 + raw_arg]); - frame_high = atoi (argv[2 + raw_arg]); + frame_low = atoi (argv[1 + oind]); + frame_high = atoi (argv[2 + oind]); } else { @@ -306,7 +318,7 @@ mi_cmd_stack_list_args (char *command, char **argv, int argc) frame_high = -1; } - print_values = mi_parse_print_values (argv[raw_arg]); + print_values = mi_parse_print_values (argv[oind]); /* Let's position fi on the frame at which to start the display. Could be the innermost frame if the whole stack needs |