1 /* Top level stuff for GDB, the GNU debugger.
3 Copyright (C) 1986-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
23 #include "gdbsupport/event-loop.h"
24 #include "gdbsupport/next-iterator.h"
29 extern int inhibit_gdbinit
;
30 extern auto_boolean interactive_mode
;
32 /* Print the GDB version banner to STREAM. If INTERACTIVE is false,
33 then information referring to commands (e.g., "show configuration")
34 is omitted; this mode is used for the --version command line
35 option. If INTERACTIVE is true, then interactive commands are
37 extern void print_gdb_version (struct ui_file
*stream
, bool interactive
);
39 extern void print_gdb_configuration (struct ui_file
*);
41 extern void read_command_file (FILE *);
42 extern void init_history (void);
43 extern void command_loop (void);
44 extern int quit_confirm (void);
45 extern void quit_force (int *, int) ATTRIBUTE_NORETURN
;
46 extern void quit_command (const char *, int);
47 extern void quit_cover (void);
48 extern void execute_command (const char *, int);
50 /* Run FN. Capture its output into the returned string, do not display it
51 to the screen. The global BATCH_FLAG will temporarily be set to true.
52 When TERM_OUT is true the output is collected with terminal behaviour
53 (e.g. with styling). When TERM_OUT is false raw output will be collected
56 extern void execute_fn_to_string (std::string
&res
,
57 std::function
<void(void)> fn
, bool term_out
);
59 /* As execute_fn_to_ui_file, but run execute_command for P and FROM_TTY. */
61 extern void execute_command_to_ui_file (struct ui_file
*file
,
62 const char *p
, int from_tty
);
64 /* As execute_fn_to_string, but run execute_command for P and FROM_TTY. */
66 extern void execute_command_to_string (std::string
&res
, const char *p
,
67 int from_tty
, bool term_out
);
69 /* Same as the above, but ignore resulting string. */
71 extern void execute_command_to_string (const char *p
,
72 int from_tty
, bool term_out
);
74 /* If the interpreter is in sync mode (we're running a user command's
75 list, running command hooks or similars), and we just ran a
76 synchronous command that started the target, wait for that command
77 to end. WAS_SYNC indicates whether sync_execution was set before
78 the command was run. */
80 extern void maybe_wait_sync_command_done (int was_sync
);
82 /* Wait for a synchronous execution command to end. */
83 extern void wait_sync_command_done (void);
85 extern void check_frame_language_change (void);
87 /* Prepare for execution of a command.
88 Call this before every command, CLI or MI.
89 Returns a cleanup to be run after the command is completed. */
90 extern scoped_value_mark
prepare_execute_command (void);
92 /* This function returns a pointer to the string that is used
93 by gdb for its command prompt. */
94 extern const std::string
&get_prompt ();
96 /* This function returns a pointer to the string that is used
97 by gdb for its command prompt. */
98 extern void set_prompt (const char *s
);
100 /* Return 1 if UI's current input handler is a secondary prompt, 0
103 extern int gdb_in_secondary_prompt_p (struct ui
*ui
);
105 /* Perform _initialize initialization. */
106 extern void gdb_init ();
108 /* For use by event-top.c. */
109 /* Variables from top.c. */
110 extern int source_line_number
;
111 extern std::string source_file_name
;
112 extern bool history_expansion_p
;
113 extern bool server_command
;
114 extern char *lim_at_start
;
116 extern void gdb_add_history (const char *);
118 extern void show_commands (const char *args
, int from_tty
);
120 extern void set_verbose (const char *, int, struct cmd_list_element
*);
122 extern const char *handle_line_of_input (std::string
&cmd_line_buffer
,
123 const char *rl
, int repeat
,
124 const char *annotation_suffix
);
126 /* Call at startup to see if the user has requested that gdb start up
129 extern bool check_quiet_mode ();
131 /* Unbuffer STREAM. This is a wrapper around setbuf(STREAM, nullptr)
132 which applies some special rules for MS-Windows hosts. */
134 extern void unbuffer_stream (FILE *stream
);