Commit | Line | Data |
---|---|---|
d318976c | 1 | /* Header file for GDB CLI command implementation library. |
e2882c85 | 2 | Copyright (C) 2000-2018 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 FN |
16 | |
17 | #if !defined (CLI_SCRIPT_H) | |
18 | #define CLI_SCRIPT_H 1 | |
19 | ||
da3331ec | 20 | struct ui_file; |
da3331ec AC |
21 | struct cmd_list_element; |
22 | ||
6b66338c SM |
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, | |
7a2c85f2 | 45 | define_control, |
6b66338c SM |
46 | invalid_control |
47 | }; | |
48 | ||
12973681 TT |
49 | struct command_line; |
50 | ||
51 | extern void free_command_lines (struct command_line **); | |
52 | ||
53 | /* A deleter for command_line that calls free_command_lines. */ | |
54 | ||
55 | struct command_lines_deleter | |
56 | { | |
57 | void operator() (command_line *cmd_lines) const | |
58 | { | |
59 | free_command_lines (&cmd_lines); | |
60 | } | |
61 | }; | |
62 | ||
63 | /* A reference-counted struct command_line. */ | |
64 | typedef std::shared_ptr<command_line> counted_command_line; | |
65 | ||
6b66338c SM |
66 | /* * Structure for saved commands lines (for breakpoints, defined |
67 | commands, etc). */ | |
68 | ||
69 | struct command_line | |
70 | { | |
12973681 TT |
71 | explicit command_line (command_control_type type_, char *line_ = nullptr) |
72 | : line (line_), | |
73 | control_type (type_) | |
74 | { | |
75 | memset (&control_u, 0, sizeof (control_u)); | |
76 | } | |
77 | ||
78 | DISABLE_COPY_AND_ASSIGN (command_line); | |
79 | ||
80 | struct command_line *next = nullptr; | |
6b66338c SM |
81 | char *line; |
82 | enum command_control_type control_type; | |
83 | union | |
84 | { | |
85 | struct | |
86 | { | |
87 | enum compile_i_scope_types scope; | |
88 | void *scope_data; | |
89 | } | |
90 | compile; | |
91 | } | |
92 | control_u; | |
6b66338c SM |
93 | /* * For composite commands, the nested lists of commands. For |
94 | example, for "if" command this will contain the then branch and | |
95 | the else branch, if that is available. */ | |
12973681 TT |
96 | counted_command_line body_list_0; |
97 | counted_command_line body_list_1; | |
6b66338c | 98 | |
12973681 | 99 | private: |
6b66338c | 100 | |
12973681 | 101 | friend void free_command_lines (struct command_line **); |
6b66338c | 102 | |
12973681 | 103 | ~command_line () |
6b66338c | 104 | { |
12973681 | 105 | xfree (line); |
6b66338c SM |
106 | } |
107 | }; | |
108 | ||
60b3cef2 TT |
109 | extern counted_command_line read_command_lines |
110 | (const char *, int, int, gdb::function_view<void (const char *)>); | |
111 | extern counted_command_line read_command_lines_1 | |
112 | (gdb::function_view<const char * ()>, int, | |
113 | gdb::function_view<void (const char *)>); | |
6b66338c SM |
114 | |
115 | ||
d318976c FN |
116 | /* Exported to cli/cli-cmds.c */ |
117 | ||
05159abe | 118 | extern void script_from_file (FILE *stream, const char *file); |
d318976c | 119 | |
6f937416 PA |
120 | extern void show_user_1 (struct cmd_list_element *c, |
121 | const char *prefix, | |
122 | const char *name, | |
123 | struct ui_file *stream); | |
d318976c FN |
124 | |
125 | /* Exported to gdb/breakpoint.c */ | |
126 | ||
127 | extern enum command_control_type | |
128 | execute_control_command (struct command_line *cmd); | |
129 | ||
d57a3c85 TJB |
130 | extern enum command_control_type |
131 | execute_control_command_untraced (struct command_line *cmd); | |
132 | ||
12973681 TT |
133 | extern counted_command_line get_command_line (enum command_control_type, |
134 | const char *); | |
d57a3c85 | 135 | |
d318976c FN |
136 | extern void print_command_lines (struct ui_out *, |
137 | struct command_line *, unsigned int); | |
d318976c FN |
138 | |
139 | /* Exported to gdb/infrun.c */ | |
140 | ||
95a6b0a1 | 141 | extern void execute_user_command (struct cmd_list_element *c, const char *args); |
d318976c | 142 | |
01770bbd PA |
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 | ||
16026cd7 AS |
149 | /* Exported to top.c */ |
150 | ||
1263a9d5 TT |
151 | extern void print_command_trace (const char *cmd, ...) |
152 | ATTRIBUTE_PRINTF (1, 2); | |
16026cd7 AS |
153 | |
154 | /* Exported to event-top.c */ | |
155 | ||
156 | extern void reset_command_nest_depth (void); | |
157 | ||
d318976c | 158 | #endif /* !defined (CLI_SCRIPT_H) */ |