Change section_offsets to a std::vector
[deliverable/binutils-gdb.git] / gdb / cli / cli-script.h
1 /* Header file for GDB CLI command implementation library.
2 Copyright (C) 2000-2020 Free Software Foundation, Inc.
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
6 the Free Software Foundation; either version 3 of the License, or
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
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17 #ifndef CLI_CLI_SCRIPT_H
18 #define CLI_CLI_SCRIPT_H
19
20 #include "gdbsupport/function-view.h"
21
22 struct ui_file;
23 struct cmd_list_element;
24
25 /* * Control types for commands. */
26
27 enum misc_command_type
28 {
29 ok_command,
30 end_command,
31 else_command,
32 nop_command
33 };
34
35 enum 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,
47 define_control,
48 invalid_control
49 };
50
51 struct command_line;
52
53 extern void free_command_lines (struct command_line **);
54
55 /* A deleter for command_line that calls free_command_lines. */
56
57 struct command_lines_deleter
58 {
59 void operator() (command_line *cmd_lines) const
60 {
61 free_command_lines (&cmd_lines);
62 }
63 };
64
65 /* A reference-counted struct command_line. */
66 typedef std::shared_ptr<command_line> counted_command_line;
67
68 /* * Structure for saved commands lines (for breakpoints, defined
69 commands, etc). */
70
71 struct command_line
72 {
73 explicit command_line (command_control_type type_, char *line_ = nullptr)
74 : line (line_),
75 control_type (type_)
76 {
77 memset (&control_u, 0, sizeof (control_u));
78 }
79
80 DISABLE_COPY_AND_ASSIGN (command_line);
81
82 struct command_line *next = nullptr;
83 char *line;
84 enum command_control_type control_type;
85 union
86 {
87 struct
88 {
89 enum compile_i_scope_types scope;
90 void *scope_data;
91 }
92 compile;
93 }
94 control_u;
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;
100
101 private:
102
103 friend void free_command_lines (struct command_line **);
104
105 ~command_line ()
106 {
107 xfree (line);
108 }
109 };
110
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 *)>);
116
117
118 /* Exported to cli/cli-cmds.c */
119
120 extern void script_from_file (FILE *stream, const char *file);
121
122 extern void show_user_1 (struct cmd_list_element *c,
123 const char *prefix,
124 const char *name,
125 struct ui_file *stream);
126
127 /* Execute the commands in CMDLINES. */
128
129 extern void execute_control_commands (struct command_line *cmdlines,
130 int from_tty);
131
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. */
135
136 extern std::string execute_control_commands_to_string
137 (struct command_line *commands, int from_tty);
138
139 /* Exported to gdb/breakpoint.c */
140
141 extern enum command_control_type
142 execute_control_command (struct command_line *cmd,
143 int from_tty = 0);
144
145 extern enum command_control_type
146 execute_control_command_untraced (struct command_line *cmd);
147
148 extern counted_command_line get_command_line (enum command_control_type,
149 const char *);
150
151 extern void print_command_lines (struct ui_out *,
152 struct command_line *, unsigned int);
153
154 /* Exported to gdb/infrun.c */
155
156 extern void execute_user_command (struct cmd_list_element *c, const char *args);
157
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
161 variables. */
162 extern std::string insert_user_defined_cmd_args (const char *line);
163
164 /* Exported to top.c */
165
166 extern void print_command_trace (const char *cmd, ...)
167 ATTRIBUTE_PRINTF (1, 2);
168
169 /* Exported to event-top.c */
170
171 extern void reset_command_nest_depth (void);
172
173 #endif /* CLI_CLI_SCRIPT_H */
This page took 0.032641 seconds and 4 git commands to generate.