Make gdb_in_secondary_prompt_p() be per UI
[deliverable/binutils-gdb.git] / gdb / top.h
1 /* Top level stuff for GDB, the GNU debugger.
2
3 Copyright (C) 1986-2016 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #ifndef TOP_H
21 #define TOP_H
22
23 #include "buffer.h"
24 #include "event-loop.h"
25
26 struct tl_interp_info;
27
28 /* All about a user interface instance. Each user interface has its
29 own I/O files/streams, readline state, its own top level
30 interpreter (for the main UI, this is the interpreter specified
31 with -i on the command line) and secondary interpreters (for
32 interpreter-exec ...), etc. There's always one UI associated with
33 stdin/stdout/stderr, but the user can create secondary UIs, for
34 example, to create a separate MI channel on its own stdio
35 streams. */
36
37 struct ui
38 {
39 /* Pointer to next in singly-linked list. */
40 struct ui *next;
41
42 /* The UI's command line buffer. This is to used to accumulate
43 input until we have a whole command line. */
44 struct buffer line_buffer;
45
46 /* The callback used by the event loop whenever an event is detected
47 on the UI's input file descriptor. This function incrementally
48 builds a buffer where it accumulates the line read up to the
49 point of invocation. In the special case in which the character
50 read is newline, the function invokes the INPUT_HANDLER callback
51 (see below). */
52 void (*call_readline) (gdb_client_data);
53
54 /* The function to invoke when a complete line of input is ready for
55 processing. */
56 void (*input_handler) (char *);
57
58 /* True if this UI is using the readline library for command
59 editing; false if using GDB's own simple readline emulation, with
60 no editing support. */
61 int command_editing;
62
63 /* Each UI has its own independent set of interpreters. */
64 struct ui_interp_info *interp_info;
65
66 /* True if the UI is in async mode, false if in sync mode. If in
67 sync mode, a synchronous execution command (e.g, "next") does not
68 return until the command is finished. If in async mode, then
69 running a synchronous command returns right after resuming the
70 target. Waiting for the command's completion is later done on
71 the top event loop. For the main UI, this starts out disabled,
72 until all the explicit command line arguments (e.g., `gdb -ex
73 "start" -ex "next"') are processed. */
74 int async;
75
76 /* The number of nested readline secondary prompts that are
77 currently active. */
78 int secondary_prompt_depth;
79
80 /* stdio stream that command input is being read from. Set to stdin
81 normally. Set by source_command to the file we are sourcing.
82 Set to NULL if we are executing a user-defined command or
83 interacting via a GUI. */
84 FILE *instream;
85 /* Standard output stream. */
86 FILE *outstream;
87 /* Standard error stream. */
88 FILE *errstream;
89
90 /* The file descriptor for the input stream, so that we can register
91 it with the event loop. */
92 int input_fd;
93
94 /* The fields below that start with "m_" are "private". They're
95 meant to be accessed through wrapper macros that make them look
96 like globals. */
97
98 /* The ui_file streams. */
99 /* Normal results */
100 struct ui_file *m_gdb_stdout;
101 /* Input stream */
102 struct ui_file *m_gdb_stdin;
103 /* Serious error notifications */
104 struct ui_file *m_gdb_stderr;
105 /* Log/debug/trace messages that should bypass normal stdout/stderr
106 filtering. For moment, always call this stream using
107 *_unfiltered. In the very near future that restriction shall be
108 removed - either call shall be unfiltered. (cagney 1999-06-13). */
109 struct ui_file *m_gdb_stdlog;
110
111 /* The current ui_out. */
112 struct ui_out *m_current_uiout;
113 };
114
115 /* The main UI. This is the UI that is bound to stdin/stdout/stderr.
116 It always exists and is created automatically when GDB starts
117 up. */
118 extern struct ui *main_ui;
119
120 /* The current UI. */
121 extern struct ui *current_ui;
122
123 /* The list of all UIs. */
124 extern struct ui *ui_list;
125
126 /* State for SWITCH_THRU_ALL_UIS. Declared here because it is meant
127 to be created on the stack, but should be treated as opaque. */
128 struct switch_thru_all_uis
129 {
130 struct ui *iter;
131 struct cleanup *old_chain;
132 };
133
134 /* Functions to drive SWITCH_THRU_ALL_UIS. Though declared here by
135 necessity, these functions should not be used other than via the
136 SWITCH_THRU_ALL_UIS macro defined below. */
137 extern void switch_thru_all_uis_init (struct switch_thru_all_uis *state);
138 extern int switch_thru_all_uis_cond (struct switch_thru_all_uis *state);
139 extern void switch_thru_all_uis_next (struct switch_thru_all_uis *state);
140
141 /* Traverse through all UI, and switch the current UI to the one
142 being iterated. */
143 #define SWITCH_THRU_ALL_UIS(STATE) \
144 for (switch_thru_all_uis_init (&STATE); \
145 switch_thru_all_uis_cond (&STATE); \
146 switch_thru_all_uis_next (&STATE))
147
148 /* Cleanup that restores the current UI. */
149 extern void restore_ui_cleanup (void *data);
150
151 /* From top.c. */
152 extern char *saved_command_line;
153 extern int in_user_command;
154 extern int confirm;
155 extern char gdb_dirbuf[1024];
156 extern int inhibit_gdbinit;
157 extern const char gdbinit[];
158
159 extern void print_gdb_version (struct ui_file *);
160 extern void print_gdb_configuration (struct ui_file *);
161
162 extern void read_command_file (FILE *);
163 extern void init_history (void);
164 extern void command_loop (void);
165 extern int quit_confirm (void);
166 extern void quit_force (char *, int);
167 extern void quit_command (char *, int);
168 extern void quit_cover (void);
169 extern void execute_command (char *, int);
170
171 /* If the interpreter is in sync mode (we're running a user command's
172 list, running command hooks or similars), and we just ran a
173 synchronous command that started the target, wait for that command
174 to end. WAS_SYNC indicates whether sync_execution was set before
175 the command was run. */
176
177 extern void maybe_wait_sync_command_done (int was_sync);
178
179 /* Wait for a synchronous execution command to end. */
180 extern void wait_sync_command_done (void);
181
182 extern void check_frame_language_change (void);
183
184 /* Prepare for execution of a command.
185 Call this before every command, CLI or MI.
186 Returns a cleanup to be run after the command is completed. */
187 extern struct cleanup *prepare_execute_command (void);
188
189 /* This function returns a pointer to the string that is used
190 by gdb for its command prompt. */
191 extern char *get_prompt (void);
192
193 /* This function returns a pointer to the string that is used
194 by gdb for its command prompt. */
195 extern void set_prompt (const char *s);
196
197 /* Return 1 if UI's current input handler is a secondary prompt, 0
198 otherwise. */
199
200 extern int gdb_in_secondary_prompt_p (struct ui *ui);
201
202 /* From random places. */
203 extern int readnow_symbol_files;
204
205 /* Perform _initialize initialization. */
206 extern void gdb_init (char *);
207
208 /* For use by event-top.c. */
209 /* Variables from top.c. */
210 extern int source_line_number;
211 extern const char *source_file_name;
212 extern int history_expansion_p;
213 extern int server_command;
214 extern char *lim_at_start;
215
216 extern void gdb_add_history (const char *);
217
218 extern void show_commands (char *args, int from_tty);
219
220 extern void set_history (char *, int);
221
222 extern void show_history (char *, int);
223
224 extern void set_verbose (char *, int, struct cmd_list_element *);
225
226 extern void do_restore_instream_cleanup (void *stream);
227
228 extern char *handle_line_of_input (struct buffer *cmd_line_buffer,
229 char *rl, int repeat,
230 char *annotation_suffix);
231
232 #endif
This page took 0.036105 seconds and 4 git commands to generate.