1 /* Header file for simulator argument handling.
2 Copyright (C) 1997, 1998 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 2, or (at your option)
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 along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
26 /* ARGV option support.
28 Options for the standalone simulator are parsed by sim_open since
29 sim_open handles the large majority of them and it also parses the
30 options when invoked by gdb [or any external program].
32 For OPTION_HANDLER: arg#2 is the processor to apply to option to
33 (all if NULL); arg#3 is the option index; arg#4 is the option's
34 argument, NULL if optional and missing; arg#5 is nonzero if a
35 command is being interpreted. */
37 typedef SIM_RC (OPTION_HANDLER) PARAMS ((SIM_DESC, sim_cpu *, int, char *, int));
39 /* Declare option handlers with a macro so it's usable on k&r systems. */
40 #define DECLARE_OPTION_HANDLER(fn) SIM_RC fn PARAMS ((SIM_DESC, sim_cpu *, int, char *, int))
44 /* The long option information. */
48 /* The short option with the same meaning ('\0' if none).
50 For short options, when OPT.VAL is non-zero, it, instead of
51 SHORTOPT is passed to HANDLER.
53 For example, for the below:
55 { {"dc", no_argument, NULL, OPTION_VALUE},
56 'd', NULL, "<<description>>", HANDLER},
57 { {NULL, no_argument, NULL, OPTION_VALUE},
58 'e', NULL, "<<description>>", HANDLER},
60 the options --dc, -d and -e all result in OPTION_VALUE being
61 passed into HANDLER. */
65 /* The name of the argument (NULL if none). */
69 /* The documentation string.
71 If DOC is NULL, this option name is listed as a synonym for the
74 If DOC and DOC_NAME are the empty string (i.e. ""), this option
75 is not listed in usage and help messages.
77 For example, given the aliased options --dc, --dp and -d, then:
79 { {"dc", no_argument, NULL, OPTION_DC},
80 'd', NULL, "<<description>>", HANDLER},
81 { {"dp", no_argument, NULL, OPTION_DP},
82 '\0', NULL, NULL, HANDLER},
84 will list ``-d, --dc, --dp <<description>>'' */
88 /* A function to process the option. */
90 OPTION_HANDLER *handler;
92 /* The documentation name. Used when generating usage and help
95 If DOC and DOC_NAME are the empty string (i.e. ""), this option
96 is not listed in usage and help messages.
98 If DOC_NAME is a non-empty string then it, insted of OPT.NAME, is
99 listed as the name of the option in usage and help messages.
101 For example, given the options --set-pc and --set-sp, then:
103 { {"set-pc", no_argument, NULL, OPTION_SET_PC},
104 '\0', NULL, "<<description>>", HANDLER, "--set-REGNAME" },
105 { {"set-sp", no_argument, NULL, OPTION_SET_SP},
106 '\0', NULL, "", HANDLER, "" },
108 will list ``--set-REGNAME <<description>>". */
110 const char *doc_name;
114 /* All options that don't have a short form equivalent begin with this for
115 `val'. 130 isn't special, just some non-ASCII value to begin at.
116 Modules needn't worry about collisions here, the code dynamically assigned
117 the actual numbers used and then passes the original value to the option
119 #define OPTION_START 130
121 /* Identify valid option in the table */
122 #define OPTION_VALID_P(O) ((O)->opt.name != NULL || (O)->shortopt != '\0')
124 /* List of options added by various modules. */
125 typedef struct option_list {
126 struct option_list *next;
127 const OPTION *options;
130 /* Add a set of options to the simulator.
131 CPU is the cpu the options apply to or NULL for all cpus.
132 TABLE is an array of OPTIONS terminated by a NULL `opt.name' entry. */
133 SIM_RC sim_add_option_table PARAMS ((SIM_DESC sd, sim_cpu *cpu, const OPTION *table));
135 /* Install handler for the standard options. */
136 MODULE_INSTALL_FN standard_install;
138 /* Called by sim_open to parse the arguments. */
139 SIM_RC sim_parse_args PARAMS ((SIM_DESC sd, char **argv));
141 /* Print help messages for the options. IS_COMMAND is non-zero when
142 this function is called from the command line interpreter. */
143 void sim_print_help PARAMS ((SIM_DESC sd, int is_command));
145 /* Try to parse the command as if it is an option, Only fail when
146 totally unsuccessful */
147 SIM_RC sim_args_command PARAMS ((SIM_DESC sd, char *cmd));
149 #endif /* SIM_OPTIONS_H */