41 int c = *(*string_ptr)++;
66 if (isdigit (c) && c !=
'8' && c !=
'9')
112 const char *chp = args;
134 const char *start = chp + 1;
139 while (*chp !=
'\0' && *chp !=
'"')
162 if (chp[1] !=
'\0' && !isspace (chp[1]))
171 while (*chp !=
'\0' && *chp !=
'"')
191 const char *start = chp;
193 while (*chp !=
'\0' && !isspace (*chp))
199 strncpy (arg, start, len);
236 std::unique_ptr<struct mi_parse>
241 std::unique_ptr<struct mi_parse>
parse (
new struct mi_parse);
247 for (chp = cmd; *chp >=
'0' && *chp <=
'9'; chp++)
250 memcpy (*
token, cmd, (chp - cmd));
251 (*token)[chp - cmd] =
'\0';
257 parse->command = xstrdup (chp);
265 const char *tmp = chp + 1;
267 for (; *chp && !isspace (*chp); chp++)
270 memcpy (
parse->command, tmp, chp - tmp);
271 parse->command[chp - tmp] =
'\0';
276 if (
parse->cmd == NULL)
278 _(
"Undefined MI command: %s"),
parse->command);
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);
368 if (
parse->cmd->argv_func != NULL)
371 if (
parse->argv == NULL)
372 error (
_(
"Problem parsing arguments: %s %s"),
parse->command, chp);
378 if (
parse->cmd->cli.cmd != NULL)
379 parse->args = xstrdup (chp);
389 if (strcmp (
name,
"0") == 0
392 else if (strcmp (
name,
"1") == 0
395 else if (strcmp (
name,
"2") == 0
399 error (
_(
"Unknown value for PRINT_VALUES: must be: \ 400 0 or \"%s\", 1 or \"%s\", 2 or \"%s\""),
static int parse(struct parser_state *ps)
std::string extract_arg(const char **arg)
static void mi_parse_argv(const char *args, struct mi_parse *parse)
enum language language_enum(const char *str)
char * skip_spaces(char *chp)
static const char mi_simple_values[]
std::unique_ptr< struct mi_parse > mi_parse(const char *cmd, char **token)
int host_hex_value(char c)
static int mi_parse_escape(const char **string_ptr)
#define XRESIZEVEC(T, P, N)
struct mi_cmd * mi_lookup(const char *command)
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,...)