41 int c = *(*string_ptr)++;
66 if (isdigit (c) && c !=
'8' && c !=
'9')
112 const char *chp = args;
114 char **argv = XNEWVEC (
char *, argc + 1);
122 chp = skip_spaces (chp);
134 const char *start = chp + 1;
139 while (*chp !=
'\0' && *chp !=
'"')
162 if (chp[1] !=
'\0' && !isspace (chp[1]))
168 arg = XNEWVEC (
char, len + 1);
171 while (*chp !=
'\0' && *chp !=
'"')
191 const char *start = chp;
193 while (*chp !=
'\0' && !isspace (*chp))
198 arg = XNEWVEC (
char, len + 1);
199 strncpy (arg, start, len);
205 argv = XRESIZEVEC (
char *, argv, argc + 2);
236std::unique_ptr<struct mi_parse>
241 std::unique_ptr<struct mi_parse> parse (
new struct mi_parse);
244 cmd = skip_spaces (cmd);
247 for (chp = cmd; *chp >=
'0' && *chp <=
'9'; chp++)
250 memcpy (*
token, cmd, (chp - cmd));
251 (*token)[chp - cmd] =
'\0';
256 chp = skip_spaces (chp);
257 parse->command = xstrdup (chp);
265 const char *tmp = chp + 1;
267 for (; *chp && !isspace (*chp); chp++)
269 parse->command = (
char *)
xmalloc (chp - tmp + 1);
270 memcpy (parse->command, tmp, chp - tmp);
271 parse->command[chp - tmp] =
'\0';
276 if (parse->cmd == NULL)
277 throw_error (UNDEFINED_COMMAND_ERROR,
278 _(
"Undefined MI command: %s"), parse->command);
281 chp = skip_spaces (chp);
294 size_t as =
sizeof (
"--all ") - 1;
295 size_t tgs =
sizeof (
"--thread-group ") - 1;
296 size_t ts =
sizeof (
"--thread ") - 1;
297 size_t fs =
sizeof (
"--frame ") - 1;
298 size_t ls =
sizeof (
"--language ") - 1;
300 if (strncmp (chp,
"--all ", as) == 0)
306 if (strcmp (chp,
"--all") == 0)
311 if (strncmp (chp,
"--thread-group ", tgs) == 0)
315 option =
"--thread-group";
316 if (parse->thread_group != -1)
317 error (_(
"Duplicate '--thread-group' option"));
320 error (_(
"Invalid thread group id"));
322 parse->thread_group = strtol (chp, &endp, 10);
325 else if (strncmp (chp,
"--thread ", ts) == 0)
330 if (parse->thread != -1)
331 error (_(
"Duplicate '--thread' option"));
333 parse->thread = strtol (chp, &endp, 10);
336 else if (strncmp (chp,
"--frame ", fs) == 0)
341 if (parse->frame != -1)
342 error (_(
"Duplicate '--frame' option"));
344 parse->frame = strtol (chp, &endp, 10);
347 else if (strncmp (chp,
"--language ", ls) == 0)
349 option =
"--language";
356 error (_(
"Invalid --language argument: %s"), lang_name.c_str ());
361 if (*chp !=
'\0' && !isspace (*chp))
362 error (_(
"Invalid value for the '%s' option"), option);
363 chp = skip_spaces (chp);
367 parse->args = xstrdup (chp);
377 if (strcmp (
name,
"0") == 0
380 else if (strcmp (
name,
"1") == 0
383 else if (strcmp (
name,
"2") == 0
387 error (_(
"Unknown value for PRINT_VALUES: must be: \
3880 or \"%s\", 1 or \"%s\", 2 or \"%s\""),
std::string extract_arg(const char **arg)
enum language language_enum(const char *str)
mi_command * mi_cmd_lookup(const char *command)
static const char mi_no_values[]
static const char mi_simple_values[]
static const char mi_all_values[]
static int mi_parse_escape(const char **string_ptr)
void mi_parse_argv(const char *args, struct mi_parse *parse)
enum print_values mi_parse_print_values(const char *name)