]> Git Repo - binutils.git/blob - gdb/cli/cli-script.h
Use counted_command_line everywhere
[binutils.git] / gdb / cli / cli-script.h
1 /* Header file for GDB CLI command implementation library.
2    Copyright (C) 2000-2018 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 #if !defined (CLI_SCRIPT_H)
18 #define CLI_SCRIPT_H 1
19
20 struct ui_file;
21 struct cmd_list_element;
22
23 /* * Control types for commands.  */
24
25 enum misc_command_type
26 {
27   ok_command,
28   end_command,
29   else_command,
30   nop_command
31 };
32
33 enum command_control_type
34 {
35   simple_control,
36   break_control,
37   continue_control,
38   while_control,
39   if_control,
40   commands_control,
41   python_control,
42   compile_control,
43   guile_control,
44   while_stepping_control,
45   invalid_control
46 };
47
48 struct command_line;
49
50 extern void free_command_lines (struct command_line **);
51
52 /* A deleter for command_line that calls free_command_lines.  */
53
54 struct command_lines_deleter
55 {
56   void operator() (command_line *cmd_lines) const
57   {
58     free_command_lines (&cmd_lines);
59   }
60 };
61
62 /* A reference-counted struct command_line.  */
63 typedef std::shared_ptr<command_line> counted_command_line;
64
65 /* * Structure for saved commands lines (for breakpoints, defined
66    commands, etc).  */
67
68 struct command_line
69 {
70   explicit command_line (command_control_type type_, char *line_ = nullptr)
71     : line (line_),
72       control_type (type_)
73   {
74     memset (&control_u, 0, sizeof (control_u));
75   }
76
77   DISABLE_COPY_AND_ASSIGN (command_line);
78
79   struct command_line *next = nullptr;
80   char *line;
81   enum command_control_type control_type;
82   union
83     {
84       struct
85         {
86           enum compile_i_scope_types scope;
87           void *scope_data;
88         }
89       compile;
90     }
91   control_u;
92   /* * For composite commands, the nested lists of commands.  For
93      example, for "if" command this will contain the then branch and
94      the else branch, if that is available.  */
95   counted_command_line body_list_0;
96   counted_command_line body_list_1;
97
98 private:
99
100   friend void free_command_lines (struct command_line **);
101
102   ~command_line ()
103   {
104     xfree (line);
105   }
106 };
107
108 extern counted_command_line read_command_lines (char *, int, int,
109                                                 void (*)(char *, void *),
110                                                 void *);
111 extern counted_command_line read_command_lines_1 (char * (*) (void), int,
112                                                   void (*)(char *, void *),
113                                                   void *);
114
115
116 /* Exported to cli/cli-cmds.c */
117
118 extern void script_from_file (FILE *stream, const char *file);
119
120 extern void show_user_1 (struct cmd_list_element *c,
121                          const char *prefix,
122                          const char *name,
123                          struct ui_file *stream);
124
125 /* Exported to gdb/breakpoint.c */
126
127 extern enum command_control_type
128         execute_control_command (struct command_line *cmd);
129
130 extern enum command_control_type
131         execute_control_command_untraced (struct command_line *cmd);
132
133 extern counted_command_line get_command_line (enum command_control_type,
134                                               const char *);
135
136 extern void print_command_lines (struct ui_out *,
137                                  struct command_line *, unsigned int);
138
139 /* Exported to gdb/infrun.c */
140
141 extern void execute_user_command (struct cmd_list_element *c, const char *args);
142
143 /* If we're in a user-defined command, replace any $argc/$argN
144    reference found in LINE with the arguments that were passed to the
145    command.  Otherwise, treat $argc/$argN as normal convenience
146    variables.  */
147 extern std::string insert_user_defined_cmd_args (const char *line);
148
149 /* Exported to top.c */
150
151 extern void print_command_trace (const char *cmd);
152
153 /* Exported to event-top.c */
154
155 extern void reset_command_nest_depth (void);
156
157 #endif /* !defined (CLI_SCRIPT_H) */
This page took 0.034689 seconds and 4 git commands to generate.