1 /* Header file for GDB CLI command implementation library.
2 Copyright (C) 2000-2018 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 #if !defined (CLI_SCRIPT_H)
18 #define CLI_SCRIPT_H 1
21 struct cmd_list_element;
23 /* * Control types for commands. */
25 enum misc_command_type
33 enum command_control_type
44 while_stepping_control,
51 extern void free_command_lines (struct command_line **);
53 /* A deleter for command_line that calls free_command_lines. */
55 struct command_lines_deleter
57 void operator() (command_line *cmd_lines) const
59 free_command_lines (&cmd_lines);
63 /* A reference-counted struct command_line. */
64 typedef std::shared_ptr<command_line> counted_command_line;
66 /* * Structure for saved commands lines (for breakpoints, defined
71 explicit command_line (command_control_type type_, char *line_ = nullptr)
75 memset (&control_u, 0, sizeof (control_u));
78 DISABLE_COPY_AND_ASSIGN (command_line);
80 struct command_line *next = nullptr;
82 enum command_control_type control_type;
87 enum compile_i_scope_types scope;
93 /* * For composite commands, the nested lists of commands. For
94 example, for "if" command this will contain the then branch and
95 the else branch, if that is available. */
96 counted_command_line body_list_0;
97 counted_command_line body_list_1;
101 friend void free_command_lines (struct command_line **);
109 extern counted_command_line read_command_lines
110 (const char *, int, int, gdb::function_view<void (const char *)>);
111 extern counted_command_line read_command_lines_1
112 (gdb::function_view<const char * ()>, int,
113 gdb::function_view<void (const char *)>);
116 /* Exported to cli/cli-cmds.c */
118 extern void script_from_file (FILE *stream, const char *file);
120 extern void show_user_1 (struct cmd_list_element *c,
123 struct ui_file *stream);
125 /* Execute the commands in CMDLINES. */
127 extern void execute_control_commands (struct command_line *cmdlines,
130 /* Run execute_control_commands for COMMANDS. Capture its output into
131 the returned string, do not display it to the screen. BATCH_FLAG
132 will be temporarily set to true. */
134 extern std::string execute_control_commands_to_string
135 (struct command_line *commands, int from_tty);
137 /* Exported to gdb/breakpoint.c */
139 extern enum command_control_type
140 execute_control_command (struct command_line *cmd,
143 extern enum command_control_type
144 execute_control_command_untraced (struct command_line *cmd);
146 extern counted_command_line get_command_line (enum command_control_type,
149 extern void print_command_lines (struct ui_out *,
150 struct command_line *, unsigned int);
152 /* Exported to gdb/infrun.c */
154 extern void execute_user_command (struct cmd_list_element *c, const char *args);
156 /* If we're in a user-defined command, replace any $argc/$argN
157 reference found in LINE with the arguments that were passed to the
158 command. Otherwise, treat $argc/$argN as normal convenience
160 extern std::string insert_user_defined_cmd_args (const char *line);
162 /* Exported to top.c */
164 extern void print_command_trace (const char *cmd, ...)
165 ATTRIBUTE_PRINTF (1, 2);
167 /* Exported to event-top.c */
169 extern void reset_command_nest_depth (void);
171 #endif /* !defined (CLI_SCRIPT_H) */