Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / cli / cli-script.h
CommitLineData
d318976c 1/* Header file for GDB CLI command implementation library.
88b9d363 2 Copyright (C) 2000-2022 Free Software Foundation, Inc.
d318976c
FN
3
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
a9762ec7 6 the Free Software Foundation; either version 3 of the License, or
d318976c
FN
7 (at your option) any later version.
8
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.
13
14 You should have received a copy of the GNU General Public License
a9762ec7 15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
d318976c 16
1a5c2598
TT
17#ifndef CLI_CLI_SCRIPT_H
18#define CLI_CLI_SCRIPT_H
d318976c 19
0d12e84c
TT
20#include "gdbsupport/function-view.h"
21
da3331ec 22struct ui_file;
da3331ec
AC
23struct cmd_list_element;
24
6b66338c
SM
25/* * Control types for commands. */
26
27enum misc_command_type
28{
29 ok_command,
30 end_command,
31 else_command,
32 nop_command
33};
34
35enum command_control_type
36{
37 simple_control,
38 break_control,
39 continue_control,
40 while_control,
41 if_control,
42 commands_control,
43 python_control,
44 compile_control,
45 guile_control,
46 while_stepping_control,
7a2c85f2 47 define_control,
a33fc9ae 48 document_control,
6b66338c
SM
49 invalid_control
50};
51
12973681
TT
52struct command_line;
53
54extern void free_command_lines (struct command_line **);
55
56/* A deleter for command_line that calls free_command_lines. */
57
58struct command_lines_deleter
59{
60 void operator() (command_line *cmd_lines) const
61 {
62 free_command_lines (&cmd_lines);
63 }
64};
65
66/* A reference-counted struct command_line. */
67typedef std::shared_ptr<command_line> counted_command_line;
68
bb6203bf
AH
69/* A unique_ptr specialization for command_line. */
70typedef std::unique_ptr<command_line, command_lines_deleter> command_line_up;
71
6b66338c
SM
72/* * Structure for saved commands lines (for breakpoints, defined
73 commands, etc). */
74
75struct command_line
76{
12973681
TT
77 explicit command_line (command_control_type type_, char *line_ = nullptr)
78 : line (line_),
79 control_type (type_)
80 {
81 memset (&control_u, 0, sizeof (control_u));
82 }
83
84 DISABLE_COPY_AND_ASSIGN (command_line);
85
86 struct command_line *next = nullptr;
6b66338c
SM
87 char *line;
88 enum command_control_type control_type;
89 union
90 {
91 struct
92 {
93 enum compile_i_scope_types scope;
94 void *scope_data;
95 }
96 compile;
97 }
98 control_u;
6b66338c
SM
99 /* * For composite commands, the nested lists of commands. For
100 example, for "if" command this will contain the then branch and
101 the else branch, if that is available. */
12973681
TT
102 counted_command_line body_list_0;
103 counted_command_line body_list_1;
6b66338c 104
12973681 105private:
6b66338c 106
12973681 107 friend void free_command_lines (struct command_line **);
6b66338c 108
12973681 109 ~command_line ()
6b66338c 110 {
12973681 111 xfree (line);
6b66338c
SM
112 }
113};
114
60b3cef2
TT
115extern counted_command_line read_command_lines
116 (const char *, int, int, gdb::function_view<void (const char *)>);
117extern counted_command_line read_command_lines_1
118 (gdb::function_view<const char * ()>, int,
119 gdb::function_view<void (const char *)>);
6b66338c
SM
120
121
d318976c
FN
122/* Exported to cli/cli-cmds.c */
123
05159abe 124extern void script_from_file (FILE *stream, const char *file);
d318976c 125
6f937416
PA
126extern void show_user_1 (struct cmd_list_element *c,
127 const char *prefix,
128 const char *name,
129 struct ui_file *stream);
d318976c 130
56bcdbea
TT
131/* Execute the commands in CMDLINES. */
132
133extern void execute_control_commands (struct command_line *cmdlines,
134 int from_tty);
135
136/* Run execute_control_commands for COMMANDS. Capture its output into
137 the returned string, do not display it to the screen. BATCH_FLAG
138 will be temporarily set to true. */
139
140extern std::string execute_control_commands_to_string
141 (struct command_line *commands, int from_tty);
142
d318976c
FN
143/* Exported to gdb/breakpoint.c */
144
145extern enum command_control_type
56bcdbea
TT
146 execute_control_command (struct command_line *cmd,
147 int from_tty = 0);
d318976c 148
d57a3c85
TJB
149extern enum command_control_type
150 execute_control_command_untraced (struct command_line *cmd);
151
12973681
TT
152extern counted_command_line get_command_line (enum command_control_type,
153 const char *);
d57a3c85 154
d318976c
FN
155extern void print_command_lines (struct ui_out *,
156 struct command_line *, unsigned int);
d318976c
FN
157
158/* Exported to gdb/infrun.c */
159
95a6b0a1 160extern void execute_user_command (struct cmd_list_element *c, const char *args);
d318976c 161
01770bbd
PA
162/* If we're in a user-defined command, replace any $argc/$argN
163 reference found in LINE with the arguments that were passed to the
164 command. Otherwise, treat $argc/$argN as normal convenience
165 variables. */
166extern std::string insert_user_defined_cmd_args (const char *line);
167
16026cd7
AS
168/* Exported to top.c */
169
1263a9d5
TT
170extern void print_command_trace (const char *cmd, ...)
171 ATTRIBUTE_PRINTF (1, 2);
16026cd7
AS
172
173/* Exported to event-top.c */
174
175extern void reset_command_nest_depth (void);
176
1a5c2598 177#endif /* CLI_CLI_SCRIPT_H */
This page took 1.493895 seconds and 4 git commands to generate.