1 /* Header file for GDB CLI command implementation library.
2 Copyright (C) 2000-2020 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 #ifndef CLI_CLI_SCRIPT_H
18 #define CLI_CLI_SCRIPT_H
20 #include "gdbsupport/function-view.h"
23 struct cmd_list_element
;
25 /* * Control types for commands. */
27 enum misc_command_type
35 enum command_control_type
46 while_stepping_control
,
53 extern void free_command_lines (struct command_line
**);
55 /* A deleter for command_line that calls free_command_lines. */
57 struct command_lines_deleter
59 void operator() (command_line
*cmd_lines
) const
61 free_command_lines (&cmd_lines
);
65 /* A reference-counted struct command_line. */
66 typedef std::shared_ptr
<command_line
> counted_command_line
;
68 /* * Structure for saved commands lines (for breakpoints, defined
73 explicit command_line (command_control_type type_
, char *line_
= nullptr)
77 memset (&control_u
, 0, sizeof (control_u
));
80 DISABLE_COPY_AND_ASSIGN (command_line
);
82 struct command_line
*next
= nullptr;
84 enum command_control_type control_type
;
89 enum compile_i_scope_types scope
;
95 /* * For composite commands, the nested lists of commands. For
96 example, for "if" command this will contain the then branch and
97 the else branch, if that is available. */
98 counted_command_line body_list_0
;
99 counted_command_line body_list_1
;
103 friend void free_command_lines (struct command_line
**);
111 extern counted_command_line read_command_lines
112 (const char *, int, int, gdb::function_view
<void (const char *)>);
113 extern counted_command_line read_command_lines_1
114 (gdb::function_view
<const char * ()>, int,
115 gdb::function_view
<void (const char *)>);
118 /* Exported to cli/cli-cmds.c */
120 extern void script_from_file (FILE *stream
, const char *file
);
122 extern void show_user_1 (struct cmd_list_element
*c
,
125 struct ui_file
*stream
);
127 /* Execute the commands in CMDLINES. */
129 extern void execute_control_commands (struct command_line
*cmdlines
,
132 /* Run execute_control_commands for COMMANDS. Capture its output into
133 the returned string, do not display it to the screen. BATCH_FLAG
134 will be temporarily set to true. */
136 extern std::string execute_control_commands_to_string
137 (struct command_line
*commands
, int from_tty
);
139 /* Exported to gdb/breakpoint.c */
141 extern enum command_control_type
142 execute_control_command (struct command_line
*cmd
,
145 extern enum command_control_type
146 execute_control_command_untraced (struct command_line
*cmd
);
148 extern counted_command_line
get_command_line (enum command_control_type
,
151 extern void print_command_lines (struct ui_out
*,
152 struct command_line
*, unsigned int);
154 /* Exported to gdb/infrun.c */
156 extern void execute_user_command (struct cmd_list_element
*c
, const char *args
);
158 /* If we're in a user-defined command, replace any $argc/$argN
159 reference found in LINE with the arguments that were passed to the
160 command. Otherwise, treat $argc/$argN as normal convenience
162 extern std::string
insert_user_defined_cmd_args (const char *line
);
164 /* Exported to top.c */
166 extern void print_command_trace (const char *cmd
, ...)
167 ATTRIBUTE_PRINTF (1, 2);
169 /* Exported to event-top.c */
171 extern void reset_command_nest_depth (void);
173 #endif /* CLI_CLI_SCRIPT_H */