]> Git Repo - binutils.git/blob - gdb/cli/cli-script.h
gdb: multi-line support for "document" command
[binutils.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   document_control,
49   invalid_control
50 };
51
52 struct command_line;
53
54 extern void free_command_lines (struct command_line **);
55
56 /* A deleter for command_line that calls free_command_lines.  */
57
58 struct 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.  */
67 typedef std::shared_ptr<command_line> counted_command_line;
68
69 /* * Structure for saved commands lines (for breakpoints, defined
70    commands, etc).  */
71
72 struct command_line
73 {
74   explicit command_line (command_control_type type_, char *line_ = nullptr)
75     : line (line_),
76       control_type (type_)
77   {
78     memset (&control_u, 0, sizeof (control_u));
79   }
80
81   DISABLE_COPY_AND_ASSIGN (command_line);
82
83   struct command_line *next = nullptr;
84   char *line;
85   enum command_control_type control_type;
86   union
87     {
88       struct
89         {
90           enum compile_i_scope_types scope;
91           void *scope_data;
92         }
93       compile;
94     }
95   control_u;
96   /* * For composite commands, the nested lists of commands.  For
97      example, for "if" command this will contain the then branch and
98      the else branch, if that is available.  */
99   counted_command_line body_list_0;
100   counted_command_line body_list_1;
101
102 private:
103
104   friend void free_command_lines (struct command_line **);
105
106   ~command_line ()
107   {
108     xfree (line);
109   }
110 };
111
112 extern counted_command_line read_command_lines
113     (const char *, int, int, gdb::function_view<void (const char *)>);
114 extern counted_command_line read_command_lines_1
115     (gdb::function_view<const char * ()>, int,
116      gdb::function_view<void (const char *)>);
117
118
119 /* Exported to cli/cli-cmds.c */
120
121 extern void script_from_file (FILE *stream, const char *file);
122
123 extern void show_user_1 (struct cmd_list_element *c,
124                          const char *prefix,
125                          const char *name,
126                          struct ui_file *stream);
127
128 /* Execute the commands in CMDLINES.  */
129
130 extern void execute_control_commands (struct command_line *cmdlines,
131                                       int from_tty);
132
133 /* Run execute_control_commands for COMMANDS.  Capture its output into
134    the returned string, do not display it to the screen.  BATCH_FLAG
135    will be temporarily set to true.  */
136
137 extern std::string execute_control_commands_to_string
138     (struct command_line *commands, int from_tty);
139
140 /* Exported to gdb/breakpoint.c */
141
142 extern enum command_control_type
143         execute_control_command (struct command_line *cmd,
144                                  int from_tty = 0);
145
146 extern enum command_control_type
147         execute_control_command_untraced (struct command_line *cmd);
148
149 extern counted_command_line get_command_line (enum command_control_type,
150                                               const char *);
151
152 extern void print_command_lines (struct ui_out *,
153                                  struct command_line *, unsigned int);
154
155 /* Exported to gdb/infrun.c */
156
157 extern void execute_user_command (struct cmd_list_element *c, const char *args);
158
159 /* If we're in a user-defined command, replace any $argc/$argN
160    reference found in LINE with the arguments that were passed to the
161    command.  Otherwise, treat $argc/$argN as normal convenience
162    variables.  */
163 extern std::string insert_user_defined_cmd_args (const char *line);
164
165 /* Exported to top.c */
166
167 extern void print_command_trace (const char *cmd, ...)
168   ATTRIBUTE_PRINTF (1, 2);
169
170 /* Exported to event-top.c */
171
172 extern void reset_command_nest_depth (void);
173
174 #endif /* CLI_CLI_SCRIPT_H */
This page took 0.032197 seconds and 4 git commands to generate.