1 /* Header file for simulator argument handling.
2 Copyright (C) 1997-2018 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
5 This file is part of GDB, the GNU debugger.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
25 /* ARGV option support.
27 Options for the standalone simulator are parsed by sim_open since
28 sim_open handles the large majority of them and it also parses the
29 options when invoked by gdb [or any external program].
31 For OPTION_HANDLER: arg#2 is the processor to apply to option to
32 (all if NULL); arg#3 is the option index; arg#4 is the option's
33 argument, NULL if optional and missing; arg#5 is nonzero if a
34 command is being interpreted. */
36 typedef SIM_RC (OPTION_HANDLER) (SIM_DESC, sim_cpu *, int, char *, int);
38 /* Declare option handlers with a macro so it's usable on k&r systems. */
39 #define DECLARE_OPTION_HANDLER(fn) SIM_RC fn (SIM_DESC, sim_cpu *, int, char *, int)
43 /* The long option information. */
47 /* The short option with the same meaning ('\0' if none).
49 For short options, when OPT.VAL is non-zero, it, instead of
50 SHORTOPT is passed to HANDLER.
52 For example, for the below:
54 { {"dc", no_argument, NULL, OPTION_VALUE},
55 'd', NULL, "<<description>>", HANDLER},
56 { {NULL, no_argument, NULL, OPTION_VALUE},
57 'e', NULL, "<<description>>", HANDLER},
59 the options --dc, -d and -e all result in OPTION_VALUE being
60 passed into HANDLER. */
64 /* The name of the argument (NULL if none). */
68 /* The documentation string.
70 If DOC is NULL, this option name is listed as a synonym for the
73 If DOC and DOC_NAME are the empty string (i.e. ""), this option
74 is not listed in usage and help messages.
76 For example, given the aliased options --dc, --dp and -d, then:
78 { {"dc", no_argument, NULL, OPTION_DC},
79 'd', NULL, "<<description>>", HANDLER},
80 { {"dp", no_argument, NULL, OPTION_DP},
81 '\0', NULL, NULL, HANDLER},
83 will list ``-d, --dc, --dp <<description>>'' */
87 /* A function to process the option. */
89 OPTION_HANDLER *handler;
91 /* The documentation name. Used when generating usage and help
94 If DOC and DOC_NAME are the empty string (i.e. ""), this option
95 is not listed in usage and help messages.
97 If DOC_NAME is a non-empty string then it, insted of OPT.NAME, is
98 listed as the name of the option in usage and help messages.
100 For example, given the options --set-pc and --set-sp, then:
102 { {"set-pc", no_argument, NULL, OPTION_SET_PC},
103 '\0', NULL, "<<description>>", HANDLER, "--set-REGNAME" },
104 { {"set-sp", no_argument, NULL, OPTION_SET_SP},
105 '\0', NULL, "", HANDLER, "" },
107 will list ``--set-REGNAME <<description>>". */
109 const char *doc_name;
113 /* All options that don't have a short form equivalent begin with this for
114 `val'. 130 isn't special, just some non-ASCII value to begin at.
115 Modules needn't worry about collisions here, the code dynamically assigned
116 the actual numbers used and then passes the original value to the option
118 #define OPTION_START 130
120 /* Identify valid option in the table */
121 #define OPTION_VALID_P(O) ((O)->opt.name != NULL || (O)->shortopt != '\0')
123 /* List of options added by various modules. */
124 typedef struct option_list {
125 struct option_list *next;
126 const OPTION *options;
129 /* Add a set of options to the simulator.
130 CPU is the cpu the options apply to or NULL for all cpus.
131 TABLE is an array of OPTIONS terminated by a NULL `opt.name' entry. */
132 SIM_RC sim_add_option_table (SIM_DESC sd, sim_cpu *cpu, const OPTION *table);
134 /* Install handler for the standard options. */
135 MODULE_INSTALL_FN standard_install;
137 /* Called by sim_open to parse the arguments. */
138 SIM_RC sim_parse_args (SIM_DESC sd, char * const *argv);
140 /* Print help messages for the options. IS_COMMAND is non-zero when
141 this function is called from the command line interpreter. */
142 void sim_print_help (SIM_DESC sd, int is_command);
144 /* Try to parse the command as if it is an option, Only fail when
145 totally unsuccessful */
146 SIM_RC sim_args_command (SIM_DESC sd, const char *cmd);
148 #endif /* SIM_OPTIONS_H */