41 int c = *(*string_ptr)++;
66 if (isdigit (c) && c !=
'8' && c !=
'9')
112 const char *chp = args;
114 char **argv =
xmalloc ((argc + 1) *
sizeof (
char *));
134 const char *start = chp + 1;
139 while (*chp !=
'\0' && *chp !=
'"')
162 if (chp[1] !=
'\0' && !isspace (chp[1]))
168 arg =
xmalloc ((len + 1) *
sizeof (
char));
171 while (*chp !=
'\0' && *chp !=
'"')
191 const char *start = chp;
193 while (*chp !=
'\0' && !isspace (*chp))
198 arg =
xmalloc ((len + 1) *
sizeof (
char));
199 strncpy (arg, start, len);
205 argv =
xrealloc (argv, (argc + 2) *
sizeof (
char *));
218 if (parse->
token != NULL)
220 if (parse->
args != NULL)
222 if (parse->
argv != NULL)
223 freeargv (parse->
argv);
242 memset (parse, 0,
sizeof (*parse));
255 for (chp = cmd; *chp >=
'0' && *chp <=
'9'; chp++)
257 *token =
xmalloc (chp - cmd + 1);
258 memcpy (*token, cmd, (chp - cmd));
259 (*token)[chp - cmd] =
'\0';
265 parse->
command = xstrdup (chp);
275 const char *tmp = chp + 1;
277 for (; *chp && !isspace (*chp); chp++)
280 memcpy (parse->
command, tmp, chp - tmp);
281 parse->
command[chp - tmp] =
'\0';
286 if (parse->
cmd == NULL)
288 _(
"Undefined MI command: %s"), parse->
command);
304 size_t as =
sizeof (
"--all ") - 1;
305 size_t tgs =
sizeof (
"--thread-group ") - 1;
306 size_t ts =
sizeof (
"--thread ") - 1;
307 size_t fs =
sizeof (
"--frame ") - 1;
308 size_t ls =
sizeof (
"--language ") - 1;
310 if (strncmp (chp,
"--all ", as) == 0)
316 if (strcmp (chp,
"--all") == 0)
321 if (strncmp (chp,
"--thread-group ", tgs) == 0)
325 option =
"--thread-group";
327 error (
_(
"Duplicate '--thread-group' option"));
330 error (
_(
"Invalid thread group id"));
335 else if (strncmp (chp,
"--thread ", ts) == 0)
341 error (
_(
"Duplicate '--thread' option"));
343 parse->
thread = strtol (chp, &endp, 10);
346 else if (strncmp (chp,
"--frame ", fs) == 0)
351 if (parse->
frame != -1)
352 error (
_(
"Duplicate '--frame' option"));
354 parse->
frame = strtol (chp, &endp, 10);
357 else if (strncmp (chp,
"--language ", ls) == 0)
360 struct cleanup *old_chain;
362 option =
"--language";
370 error (
_(
"Invalid --language argument: %s"), lang_name);
377 if (*chp !=
'\0' && !isspace (*chp))
378 error (
_(
"Invalid value for the '%s' option"), option);
387 if (parse->
argv == NULL)
388 error (
_(
"Problem parsing arguments: %s %s"), parse->
command, chp);
395 parse->
args = xstrdup (chp);
407 if (strcmp (name,
"0") == 0
410 else if (strcmp (name,
"1") == 0
413 else if (strcmp (name,
"2") == 0
417 error (
_(
"Unknown value for PRINT_VALUES: must be: \
418 0 or \"%s\", 1 or \"%s\", 2 or \"%s\""),
enum language language_enum(char *str)
static int parse(struct parser_state *ps)
const struct mi_cmd * cmd
static void mi_parse_argv(const char *args, struct mi_parse *parse)
static const char mi_simple_values[]
static void mi_parse_cleanup(void *arg)
struct mi_parse * mi_parse(const char *cmd, char **token)
const char * skip_spaces_const(const char *chp)
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
int host_hex_value(char c)
static int mi_parse_escape(const char **string_ptr)
struct mi_cmd * mi_lookup(const char *command)
PTR xrealloc(PTR ptr, size_t size)
void discard_cleanups(struct cleanup *old_chain)
void mi_parse_free(struct mi_parse *parse)
mi_cmd_argv_ftype * argv_func
char * extract_arg_const(const char **arg)
static const char mi_no_values[]
static const char mi_all_values[]
enum print_values mi_parse_print_values(const char *name)
void error(const char *fmt,...)
void throw_error(enum errors error, const char *fmt,...)
void do_cleanups(struct cleanup *old_chain)
const ULONGEST const LONGEST len