43 void (*validator)(
char *,
void *),
150 if ((args == NULL || *args ==
'\0')
152 error (
_(
"if/while commands require arguments."));
161 cmd->
line = xstrdup (args);
179 warning (
_(
"Error reading in canned sequence of commands."));
198 uiout->
spaces (2 * depth);
244 uiout->
spaces (2 * depth);
264 uiout->
spaces (2 * depth);
271 uiout->
spaces (2 * depth);
289 uiout->
spaces (2 * depth);
303 uiout->
spaces (2 * depth);
316 uiout->
spaces (2 * depth);
329 uiout->
spaces (2 * depth);
403 error (
_(
"Max user call depth exceeded -- command aborted."));
419 warning (
_(
"Error executing canned sequence of commands."));
422 cmdlines = cmdlines->
next;
473 struct value *val_mark;
510 int len = strlen (cmd->
line) + 7;
511 char *
buffer = (
char *) alloca (len);
562 current = current->
next;
575 int len = strlen (cmd->
line) + 4;
576 char *
buffer = (
char *) alloca (len);
612 current = current->next;
642 warning (
_(
"Invalid control type in canned commands structure."));
721 const char *start_arg;
727 while (*p ==
' ' || *p ==
'\t')
736 if (((*p ==
' ' || *p ==
'\t')) && !squote && !dquote && !bsquote)
765 m_args.emplace_back (start_arg, p - start_arg);
775 while ((p = strchr (p,
'$')))
778 && (isdigit (p[4]) || p[4] ==
'c'))
796 return args->insert_args (line);
810 new_line.append (line, p - line);
814 new_line += std::to_string (
m_args.size ());
823 i = strtoul (p + 4, &tmp, 10);
824 if ((i == 0 && tmp == p + 4) || errno != 0)
826 else if (i >=
m_args.size ())
827 error (
_(
"Missing argument %ld in user function."), i);
836 new_line.append (line);
875 char *prompt_ptr, control_prompt[256];
880 error (
_(
"Control nesting too deep!"));
887 control_prompt[i] =
' ';
888 control_prompt[i] =
'>';
889 control_prompt[i + 1] =
'\0';
890 prompt_ptr = (
char *) &control_prompt[0];
929 void (*validator)(
char *,
void *),
void *closure)
940 p_end = p + strlen (p);
941 while (p_end > p && (p_end[-1] ==
' ' || p_end[-1] ==
'\t'))
946 while (p_start < p_end && (*p_start ==
' ' || *p_start ==
'\t'))
951 if (p_end - p_start == 3 &&
startswith (p_start,
"end"))
957 const char *cmd_name = p;
961 bool inline_cmd = *cmd_name !=
'\0';
971 if (p_end == p || p[0] ==
'#')
1025 else if (p_end - p == 10 &&
startswith (p,
"loop_break"))
1028 (*command)->next = NULL;
1029 (*command)->line = NULL;
1031 (*command)->body_count = 0;
1032 (*command)->body_list = NULL;
1034 else if (p_end - p == 13 &&
startswith (p,
"loop_continue"))
1037 (*command)->next = NULL;
1038 (*command)->line = NULL;
1040 (*command)->body_count = 0;
1041 (*command)->body_list = NULL;
1047 if (!parse_commands || not_handled)
1051 (*command)->next = NULL;
1052 (*command)->line =
savestring (p, p_end - p);
1054 (*command)->body_count = 0;
1055 (*command)->body_list = NULL;
1063 validator ((*command)->line, closure);
1084 void (*validator)(
char *,
void *),
1087 int current_body, i;
1097 error (
_(
"Recursed on a simple control type."));
1100 error (
_(
"Allocated body is smaller than this command type needs."));
1112 validator, closure);
1137 && current_body == 1)
1158 for (i = 1; i < current_body; i++)
1173 validator, closure);
1195 #define END_MESSAGE "End with a line saying just \"end\"." 1199 void (*validator)(
char *,
void *),
void *closure)
1206 (*deprecated_readline_begin_hook) (
"%s %s\n", prompt_arg,
1222 validator, closure);
1228 validator, closure);
1234 (*deprecated_readline_end_hook) ();
1244 void (*validator)(
char *,
void *),
void *closure)
1258 validator, closure);
1280 validator, closure);
1342 result->
line = xstrdup (cmds->
line);
1372 const char *p, *last_word;
1378 p = *comname + strlen (*comname);
1379 while (p > *comname && isspace (p[-1]))
1381 while (p > *comname && !isspace (p[-1]))
1386 if (last_word != *comname)
1392 const char *tem =
prefix.c_str ();
1396 error (
_(
"\"%s\" is not a prefix command."),
prefix.c_str ());
1399 *comname = last_word;
1405 if (!isalnum (*p) && *p !=
'-' && *p !=
'_')
1406 error (
_(
"Junk in argument list: \"%s\""), p);
1422 #define MAX_TMPBUF 128 1430 const char *tem, *comfull;
1433 int hook_name_size = 0;
1435 #define HOOK_STRING "hook-" 1437 #define HOOK_POST_STRING "hookpost-" 1438 #define HOOK_POST_LEN 9 1446 if (c && strcmp (comname, c->
name) != 0)
1454 q =
query (
_(
"Redefine command \"%s\"? "), c->
name);
1456 q =
query (
_(
"Really redefine built-in command \"%s\"? "), c->
name);
1458 error (
_(
"Command \"%s\" not redefined."), c->
name);
1479 tem = comname + hook_name_size;
1481 if (hookc && strcmp (comname + hook_name_size, hookc->
name) != 0)
1485 warning (
_(
"Your new `%s' command does not " 1486 "hook any existing command."),
1488 if (!
query (
_(
"Proceed? ")))
1489 error (
_(
"Not confirmed."));
1493 comname = xstrdup (comname);
1496 "Type commands for definition of \"%s\".", comfull);
1504 ? c->
doc : xstrdup (
"User-defined."), list);
1534 const char *comfull;
1544 error (
_(
"Command \"%s\" is built-in."), comfull);
1546 xsnprintf (tmpbuf,
sizeof (tmpbuf),
"Type documentation for \"%s\".",
1558 for (cl1 = doclines.get (); cl1; cl1 = cl1->
next)
1559 len += strlen (cl1->
line) + 1;
1561 doc = (
char *)
xmalloc (len + 1);
1564 for (cl1 = doclines.get (); cl1; cl1 = cl1->
next)
1566 strcat (doc, cl1->
line);
1581 internal_error (__FILE__, __LINE__,
_(
"called with NULL file pointer!"));
1599 _(
"%s:%d: Error in sourced command file:\n%s"),
1638 Document a user-defined command.\n\ 1639 Give command name as argument. Give documentation on following lines.\n\ 1640 End with a line of just \"end\"."));
1642 Define a new command name. Command name is argument.\n\ 1643 Definition appears on following lines, one command per line.\n\ 1644 End with a line of just \"end\".\n\ 1645 Use the \"document\" command to give documentation for the new command.\n\ 1646 Commands defined in this way may have up to ten arguments."));
1649 Execute nested commands WHILE the conditional expression is non zero.\n\ 1650 The conditional expression must follow the word `while' and must in turn be\n\ 1651 followed by a new line. The nested commands must be entered one per line,\n\ 1652 and should be terminated by the word `end'."));
1655 Execute nested commands once IF the conditional expression is non zero.\n\ 1656 The conditional expression must follow the word `if' and must in turn be\n\ 1657 followed by a new line. The nested commands must be entered one per line,\n\ 1658 and should be terminated by the word 'else' or `end'. If an else clause\n\ 1659 is used, the same rules apply to its nested commands as to the first ones."));
void error_no_arg(const char *why)
static void document_command(const char *comname, int from_tty)
struct value * value_mark(void)
struct cmd_list_element * next
static void while_command(const char *arg, int from_tty)
void eval_compile_command(struct command_line *cmd, const char *cmd_string, enum compile_i_scope_types scope, void *scope_data)
void execute_cmd_pre_hook(struct cmd_list_element *c)
enum command_control_type execute_control_command_untraced(struct command_line *cmd)
std::vector< string_view > m_args
static int suppress_next_print_command_trace
void field_string(const char *fldname, const char *string)
gdb::unique_xmalloc_ptr< expression > expression_up
std::string m_command_line
command_line_up read_command_lines_1(char *(*read_next_line_func)(void), int parse_commands, void(*validator)(char *, void *), void *closure)
char * command_line_input(const char *, int, const char *)
static void user_defined_command(const char *ignore, int from_tty)
void warning(const char *fmt,...)
int query(const char *ctlstr,...)
command_line_up get_command_line(enum command_control_type type, const char *arg)
struct cmd_list_element * hook_post
~scoped_user_args_level()
scoped_restore_hook_in & operator=(const scoped_restore_hook_in &)=delete
scoped_user_args_level(const char *line)
void internal_error(const char *file, int line, const char *fmt,...)
struct ui_out * interp_ui_out(struct interp *interp)
struct cmd_list_element * lookup_cmd(const char **line, struct cmd_list_element *list, const char *cmdtype, int allow_unknown, int ignore_help_classes)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
struct cmd_list_element * hookee_post
static struct command_line * build_command_line(enum command_control_type type, const char *args)
struct cmd_list_element * lookup_cmd_1(const char **text, struct cmd_list_element *clist, struct cmd_list_element **result_list, int ignore_help_classes)
struct cmd_list_element * cmdlist
char * skip_spaces(char *chp)
static struct cmd_list_element ** validate_comname(const char **comname)
static enum misc_command_type process_next_line(char *p, struct command_line **command, int parse_commands, void(*validator)(char *, void *), void *closure)
struct cmd_list_element * prefix
command_line_up read_command_lines(char *prompt_arg, int from_tty, int parse_commands, void(*validator)(char *, void *), void *closure)
void text(const char *string)
struct command_line::@21::@22 compile
void execute_user_command(struct cmd_list_element *c, const char *args)
void printf_filtered(const char *format,...)
struct command_line * user_commands
void execute_command(const char *, int)
scoped_restore_tmpl< T > make_scoped_restore(T *var)
struct value * evaluate_expression(struct expression *exp)
command_line_up copy_command_lines(struct command_line *cmds)
#define CATCH(EXCEPTION, MASK)
struct cmd_list_element * hook_pre
const char * source_file_name
static char * read_next_line(void)
void(* hook_type)(const char *)
int input_interactive_p(struct ui *)
void eval_ext_lang_from_control_command(struct command_line *cmd)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
void fputs_filtered(const char *linebuffer, struct ui_file *stream)
static const char * line_first_arg(const char *p)
static enum command_control_type execute_control_command_1(struct command_line *cmd)
std::string insert_args(const char *line) const
static int startswith(const char *string, const char *pattern)
#define CMD_LIST_AMBIGUOUS
struct cmd_list_element * m_cmd
static enum command_control_type recurse_read_control_structure(char *(*read_next_line_func)(void), struct command_line *current_cmd, void(*validator)(char *, void *), void *closure)
unsigned int max_user_call_depth
void printf_unfiltered(const char *format,...)
void print_command_lines(struct ui_out *uiout, struct command_line *cmd, unsigned int depth)
void script_from_file(FILE *stream, const char *file)
static const char * locate_arg(const char *p)
static bool command_name_equals(struct cmd_list_element *cmd, const char *name)
scoped_restore_hook_in(struct cmd_list_element *c)
void void spaces(int numspaces)
void(* deprecated_readline_begin_hook)(const char *,...) ATTRIBUTE_FPTR_PRINTF_1
user_args & operator=(const user_args &)=delete
std::string insert_user_defined_cmd_args(const char *line)
void throw_exception(struct gdb_exception exception)
struct command_line * next
enum command_control_type control_type
void(* deprecated_readline_end_hook)(void)
void execute_cmd_post_hook(struct cmd_list_element *c)
static int multi_line_command_p(enum command_control_type type)
int find_command_name_length(const char *text)
int xsnprintf(char *str, size_t size, const char *format,...)
~scoped_restore_hook_in()
static void if_command(const char *arg, int from_tty)
static void define_command(const char *comname, int from_tty)
string_view(const char *str_, size_t len_)
enum command_class theclass
user_args(const char *line)
void value_free_to_mark(const struct value *mark)
static int command_nest_depth
void reset_command_nest_depth(void)
static int ignore(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
expression_up parse_expression(const char *)
char * savestring(const char *ptr, size_t len)
struct cmd_list_element ** prefixlist
void show_user_1(struct cmd_list_element *c, const char *prefix, const char *name, struct ui_file *stream)
struct cmd_list_element * hookee_pre
std::unique_ptr< command_line, command_lines_deleter > command_line_up
static std::vector< std::unique_ptr< user_args > > user_args_stack
void _initialize_cli_script(void)
void print_command_trace(const char *cmd)
void gdb_flush(struct ui_file *file)
int value_true(struct value *val)
static void realloc_body_list(struct command_line *command, int new_length)
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc)
struct command_line ** body_list
int current_interp_named_p(const char *interp_name)
void error(const char *fmt,...)
union command_line::@21 control_u
void throw_error(enum errors error, const char *fmt,...)
void free_command_lines(struct command_line **lptr)
enum command_control_type execute_control_command(struct command_line *cmd)
enum command_control_type commands_from_control_command(const char *arg, struct command_line *cmd)
void field_fmt(const char *fldname, const char *format,...) ATTRIBUTE_PRINTF(3
void read_command_file(FILE *stream)
struct interp * interp_lookup(struct ui *ui, const char *name)
char *(* deprecated_readline_hook)(const char *)