GDB (xrefs)
Loading...
Searching...
No Matches
cli-script.h
Go to the documentation of this file.
1/* Header file for GDB CLI command implementation library.
2 Copyright (C) 2000-2023 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
22struct ui_file;
23struct cmd_list_element;
24
25/* * Control types for commands. */
26
34
51
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
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
69/* A unique_ptr specialization for command_line. */
70typedef std::unique_ptr<command_line, command_lines_deleter> command_line_up;
71
72/* * Structure for saved commands lines (for breakpoints, defined
73 commands, etc). */
74
76{
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
85
86 struct command_line *next = nullptr;
87 char *line;
89 union
90 {
91 struct
92 {
95 }
97 }
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. */
104
105private:
106
107 friend void free_command_lines (struct command_line **);
108
110 {
111 xfree (line);
112 }
113};
114
115/* Prototype for a function to call to get one more input line.
116
117 If the function needs to return a dynamically allocated string, it can place
118 in the passed-in buffer, and return a pointer to it. Otherwise, it can
119 simply ignore it. */
120
121using read_next_line_ftype = gdb::function_view<const char * (std::string &)>;
122
124 (const char *, int, int, gdb::function_view<void (const char *)>);
126 (read_next_line_ftype, int, gdb::function_view<void (const char *)>);
127
128
129/* Exported to cli/cli-cmds.c */
130
131extern void script_from_file (FILE *stream, const char *file);
132
133extern void show_user_1 (struct cmd_list_element *c,
134 const char *prefix,
135 const char *name,
136 struct ui_file *stream);
137
138/* Execute the commands in CMDLINES. */
139
140extern void execute_control_commands (struct command_line *cmdlines,
141 int from_tty);
142
143/* Run execute_control_commands for COMMANDS. Capture its output into
144 the returned string, do not display it to the screen. BATCH_FLAG
145 will be temporarily set to true. */
146
147extern std::string execute_control_commands_to_string
148 (struct command_line *commands, int from_tty);
149
150/* Exported to gdb/breakpoint.c */
151
152extern enum command_control_type
154 int from_tty = 0);
155
156extern enum command_control_type
158
160 const char *);
161
162extern void print_command_lines (struct ui_out *,
163 struct command_line *, unsigned int);
164
165/* Exported to gdb/infrun.c */
166
167extern void execute_user_command (struct cmd_list_element *c, const char *args);
168
169/* If we're in a user-defined command, replace any $argc/$argN
170 reference found in LINE with the arguments that were passed to the
171 command. Otherwise, treat $argc/$argN as normal convenience
172 variables. */
173extern std::string insert_user_defined_cmd_args (const char *line);
174
175/* Exported to top.c */
176
177extern void print_command_trace (const char *cmd, ...)
178 ATTRIBUTE_PRINTF (1, 2);
179
180/* Exported to event-top.c */
181
182extern void reset_command_nest_depth (void);
183
184#endif /* CLI_CLI_SCRIPT_H */
const char *const name
void xfree(void *)
void show_user_1(struct cmd_list_element *c, const char *prefix, const char *name, struct ui_file *stream)
void execute_control_commands(struct command_line *cmdlines, int from_tty)
Definition cli-script.c:403
std::unique_ptr< command_line, command_lines_deleter > command_line_up
Definition cli-script.h:70
void print_command_lines(struct ui_out *, struct command_line *, unsigned int)
Definition cli-script.c:202
counted_command_line get_command_line(enum command_control_type, const char *)
Definition cli-script.c:182
std::string insert_user_defined_cmd_args(const char *line)
Definition cli-script.c:839
void script_from_file(FILE *stream, const char *file)
counted_command_line read_command_lines_1(read_next_line_ftype, int, gdb::function_view< void(const char *)>)
void free_command_lines(struct command_line **)
gdb::function_view< const char *(std::string &)> read_next_line_ftype
Definition cli-script.h:121
counted_command_line read_command_lines(const char *, int, int, gdb::function_view< void(const char *)>)
enum command_control_type execute_control_command(struct command_line *cmd, int from_tty=0)
Definition cli-script.c:698
void void reset_command_nest_depth(void)
Definition cli-script.c:468
command_control_type
Definition cli-script.h:36
@ commands_control
Definition cli-script.h:42
@ invalid_control
Definition cli-script.h:49
@ python_control
Definition cli-script.h:43
@ document_control
Definition cli-script.h:48
@ while_stepping_control
Definition cli-script.h:46
@ break_control
Definition cli-script.h:38
@ if_control
Definition cli-script.h:41
@ define_control
Definition cli-script.h:47
@ compile_control
Definition cli-script.h:44
@ guile_control
Definition cli-script.h:45
@ continue_control
Definition cli-script.h:39
@ simple_control
Definition cli-script.h:37
@ while_control
Definition cli-script.h:40
void print_command_trace(const char *cmd,...) ATTRIBUTE_PRINTF(1
enum command_control_type execute_control_command_untraced(struct command_line *cmd)
Definition cli-script.c:716
std::shared_ptr< command_line > counted_command_line
Definition cli-script.h:67
misc_command_type
Definition cli-script.h:28
@ nop_command
Definition cli-script.h:32
@ ok_command
Definition cli-script.h:29
@ end_command
Definition cli-script.h:30
@ else_command
Definition cli-script.h:31
std::string execute_control_commands_to_string(struct command_line *commands, int from_tty)
Definition cli-script.c:425
void execute_user_command(struct cmd_list_element *c, const char *args)
Definition cli-script.c:439
compile_i_scope_types
Definition defs.h:70
static void ATTRIBUTE_PRINTF(1, 0)
Definition gdb_bfd.c:1154
#define prefix(a, b, R, do)
Definition ppc64-tdep.c:52
counted_command_line body_list_0
Definition cli-script.h:102
struct command_line::@29::@30 compile
friend void free_command_lines(struct command_line **)
counted_command_line body_list_1
Definition cli-script.h:103
enum compile_i_scope_types scope
Definition cli-script.h:93
enum command_control_type control_type
Definition cli-script.h:88
char * line
Definition cli-script.h:87
union command_line::@29 control_u
command_line(command_control_type type_, char *line_=nullptr)
Definition cli-script.h:77
DISABLE_COPY_AND_ASSIGN(command_line)
void * scope_data
Definition cli-script.h:94
void operator()(command_line *cmd_lines) const
Definition cli-script.h:60