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);