1 |
578 |
markom |
/* Header file for simulator argument handling.
|
2 |
|
|
Copyright (C) 1997, 1998 Free Software Foundation, Inc.
|
3 |
|
|
Contributed by Cygnus Support.
|
4 |
|
|
|
5 |
|
|
This file is part of GDB, the GNU debugger.
|
6 |
|
|
|
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)
|
10 |
|
|
any later version.
|
11 |
|
|
|
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.
|
16 |
|
|
|
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. */
|
20 |
|
|
|
21 |
|
|
#ifndef SIM_OPTIONS_H
|
22 |
|
|
#define SIM_OPTIONS_H
|
23 |
|
|
|
24 |
|
|
#include "getopt.h"
|
25 |
|
|
|
26 |
|
|
/* ARGV option support.
|
27 |
|
|
|
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].
|
31 |
|
|
|
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. */
|
36 |
|
|
|
37 |
|
|
typedef SIM_RC (OPTION_HANDLER) PARAMS ((SIM_DESC, sim_cpu *, int, char *, int));
|
38 |
|
|
|
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))
|
41 |
|
|
|
42 |
|
|
typedef struct {
|
43 |
|
|
|
44 |
|
|
/* The long option information. */
|
45 |
|
|
|
46 |
|
|
struct option opt;
|
47 |
|
|
|
48 |
|
|
/* The short option with the same meaning ('\0' if none).
|
49 |
|
|
|
50 |
|
|
For short options, when OPT.VAL is non-zero, it, instead of
|
51 |
|
|
SHORTOPT is passed to HANDLER.
|
52 |
|
|
|
53 |
|
|
For example, for the below:
|
54 |
|
|
|
55 |
|
|
{ {"dc", no_argument, NULL, OPTION_VALUE},
|
56 |
|
|
'd', NULL, "<<description>>", HANDLER},
|
57 |
|
|
{ {NULL, no_argument, NULL, OPTION_VALUE},
|
58 |
|
|
'e', NULL, "<<description>>", HANDLER},
|
59 |
|
|
|
60 |
|
|
the options --dc, -d and -e all result in OPTION_VALUE being
|
61 |
|
|
passed into HANDLER. */
|
62 |
|
|
|
63 |
|
|
char shortopt;
|
64 |
|
|
|
65 |
|
|
/* The name of the argument (NULL if none). */
|
66 |
|
|
|
67 |
|
|
const char *arg;
|
68 |
|
|
|
69 |
|
|
/* The documentation string.
|
70 |
|
|
|
71 |
|
|
If DOC is NULL, this option name is listed as a synonym for the
|
72 |
|
|
previous option.
|
73 |
|
|
|
74 |
|
|
If DOC and DOC_NAME are the empty string (i.e. ""), this option
|
75 |
|
|
is not listed in usage and help messages.
|
76 |
|
|
|
77 |
|
|
For example, given the aliased options --dc, --dp and -d, then:
|
78 |
|
|
|
79 |
|
|
{ {"dc", no_argument, NULL, OPTION_DC},
|
80 |
|
|
'd', NULL, "<<description>>", HANDLER},
|
81 |
|
|
{ {"dp", no_argument, NULL, OPTION_DP},
|
82 |
|
|
'\0', NULL, NULL, HANDLER},
|
83 |
|
|
|
84 |
|
|
will list ``-d, --dc, --dp <<description>>'' */
|
85 |
|
|
|
86 |
|
|
const char *doc;
|
87 |
|
|
|
88 |
|
|
/* A function to process the option. */
|
89 |
|
|
|
90 |
|
|
OPTION_HANDLER *handler;
|
91 |
|
|
|
92 |
|
|
/* The documentation name. Used when generating usage and help
|
93 |
|
|
messages.
|
94 |
|
|
|
95 |
|
|
If DOC and DOC_NAME are the empty string (i.e. ""), this option
|
96 |
|
|
is not listed in usage and help messages.
|
97 |
|
|
|
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.
|
100 |
|
|
|
101 |
|
|
For example, given the options --set-pc and --set-sp, then:
|
102 |
|
|
|
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, "" },
|
107 |
|
|
|
108 |
|
|
will list ``--set-REGNAME <<description>>". */
|
109 |
|
|
|
110 |
|
|
const char *doc_name;
|
111 |
|
|
|
112 |
|
|
} OPTION;
|
113 |
|
|
|
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
|
118 |
|
|
handler. */
|
119 |
|
|
#define OPTION_START 130
|
120 |
|
|
|
121 |
|
|
/* Identify valid option in the table */
|
122 |
|
|
#define OPTION_VALID_P(O) ((O)->opt.name != NULL || (O)->shortopt != '\0')
|
123 |
|
|
|
124 |
|
|
/* List of options added by various modules. */
|
125 |
|
|
typedef struct option_list {
|
126 |
|
|
struct option_list *next;
|
127 |
|
|
const OPTION *options;
|
128 |
|
|
} OPTION_LIST;
|
129 |
|
|
|
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));
|
134 |
|
|
|
135 |
|
|
/* Install handler for the standard options. */
|
136 |
|
|
MODULE_INSTALL_FN standard_install;
|
137 |
|
|
|
138 |
|
|
/* Called by sim_open to parse the arguments. */
|
139 |
|
|
SIM_RC sim_parse_args PARAMS ((SIM_DESC sd, char **argv));
|
140 |
|
|
|
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));
|
144 |
|
|
|
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));
|
148 |
|
|
|
149 |
|
|
#endif /* SIM_OPTIONS_H */
|