41 int c = *(*string_ptr)++;
66 if (isdigit (c) && c !=
'8' && c !=
'9')
117 const char *chp =
m_args.c_str ();
119 char **
argv = XNEWVEC (
char *,
argc + 1);
127 chp = skip_spaces (chp);
139 const char *start = chp + 1;
144 while (*chp !=
'\0' && *chp !=
'"')
167 if (chp[1] !=
'\0' && !isspace (chp[1]))
173 arg = XNEWVEC (
char, len + 1);
176 while (*chp !=
'\0' && *chp !=
'"')
196 const char *start = chp;
198 while (*chp !=
'\0' && !isspace (*chp))
203 arg = XNEWVEC (
char, len + 1);
204 strncpy (arg, start, len);
232 for (
int i = 0; i <
argc; ++i)
248 error (_(
"Duplicate '--thread-group' option"));
250 error (_(
"Invalid thread group id"));
261 error (_(
"Duplicate '--thread' option"));
262 thread = strtol (arg, endp, 10);
271 error (_(
"Duplicate '--frame' option"));
272 frame = strtol (arg, endp, 10);
284 error (_(
"Invalid --language argument: %s"), lang_name.c_str ());
300 for (chp =
cmd; *chp >=
'0' && *chp <=
'9'; chp++)
307 chp = skip_spaces (chp);
308 this->
command = make_unique_xstrdup (chp);
316 const char *tmp = chp + 1;
318 for (; *chp && !isspace (*chp); chp++)
320 this->
command = make_unique_xstrndup (tmp, chp - tmp);
325 if (this->cmd == NULL)
326 throw_error (UNDEFINED_COMMAND_ERROR,
327 _(
"Undefined MI command: %s"), this->
command.get ());
330 chp = skip_spaces (chp);
343 size_t as =
sizeof (
"--all ") - 1;
344 size_t tgs =
sizeof (
"--thread-group ") - 1;
345 size_t ts =
sizeof (
"--thread ") - 1;
346 size_t fs =
sizeof (
"--frame ") - 1;
347 size_t ls =
sizeof (
"--language ") - 1;
349 if (strncmp (chp,
"--all ", as) == 0)
355 if (strcmp (chp,
"--all") == 0)
360 if (strncmp (chp,
"--thread-group ", tgs) == 0)
364 option =
"--thread-group";
369 else if (strncmp (chp,
"--thread ", ts) == 0)
378 else if (strncmp (chp,
"--frame ", fs) == 0)
387 else if (strncmp (chp,
"--language ", ls) == 0)
389 option =
"--language";
396 if (*chp !=
'\0' && !isspace (*chp))
397 error (_(
"Invalid value for the '%s' option"), option);
398 chp = skip_spaces (chp);
411 std::vector<gdb::unique_xmalloc_ptr<char>> args)
413 this->command = std::move (
command);
416 if (this->command.get ()[0] !=
'-')
417 throw_error (UNDEFINED_COMMAND_ERROR,
418 _(
"MI command '%s' does not start with '-'"),
419 this->command.get ());
423 if (this->
cmd == NULL)
424 throw_error (UNDEFINED_COMMAND_ERROR,
425 _(
"Undefined MI command: %s"), this->command.get ());
428 this->
argv = XCNEWVEC (
char *,
args.size () + 1);
430 for (
size_t i = 0; i <
args.size (); ++i)
432 const char *chp =
args[i].get ();
435 if (strcmp (chp,
"--all") == 0)
439 else if (strcmp (chp,
"--thread-group") == 0)
442 if (i ==
args.size ())
443 error (
"No argument to '--thread-group'");
446 else if (strcmp (chp,
"--thread") == 0)
449 if (i ==
args.size ())
450 error (
"No argument to '--thread'");
453 else if (strcmp (chp,
"--frame") == 0)
456 if (i ==
args.size ())
457 error (
"No argument to '--frame'");
460 else if (strcmp (chp,
"--language") == 0)
463 if (i ==
args.size ())
464 error (
"No argument to '--language'");
478 if (strcmp (
name,
"0") == 0
481 else if (strcmp (
name,
"1") == 0
484 else if (strcmp (
name,
"2") == 0
488 error (_(
"Unknown value for PRINT_VALUES: must be: \
4890 or \"%s\", 1 or \"%s\", 2 or \"%s\""),
constexpr string_view get()
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)
enum print_values mi_parse_print_values(const char *name)
void set_thread_group(const char *arg, char **endp)
mi_parse(const char *cmd, std::string *token)
void set_thread(const char *arg, char **endp)
void set_frame(const char *arg, char **endp)
gdb::unique_xmalloc_ptr< char > command
void set_language(const char *arg, const char **endp)
const struct mi_command * cmd