/* Top level stuff for GDB, the GNU debugger.
- Copyright (C) 1986-2021 Free Software Foundation, Inc.
+ Copyright (C) 1986-2022 Free Software Foundation, Inc.
This file is part of GDB.
void (*deprecated_attach_hook) (void);
void (*deprecated_detach_hook) (void);
-/* Called when going to wait for the target. Usually allows the GUI
- to run while waiting for target events. */
-
-ptid_t (*deprecated_target_wait_hook) (ptid_t ptid,
- struct target_waitstatus *status,
- int options);
-
/* Used by UI as a wrapper around command execution. May do various
things like enabling/disabling buttons, etc... */
ui.release ();
}
- printf_unfiltered ("New UI allocated\n");
+ printf_filtered ("New UI allocated\n");
}
/* Handler for SIGHUP. */
std::string prefixname = c->prefixname ();
std::string prefixname_no_space
= prefixname.substr (0, prefixname.length () - 1);
- printf_unfiltered
+ printf_filtered
("\"%s\" must be followed by the name of a subcommand.\n",
prefixname_no_space.c_str ());
help_list (*c->subcommands, prefixname.c_str (), all_commands,
/* See gdbcmd.h. */
-std::string
-execute_fn_to_string (std::function<void(void)> fn, bool term_out)
+void
+execute_fn_to_string (std::string &res, std::function<void(void)> fn,
+ bool term_out)
{
string_file str_file (term_out);
- execute_fn_to_ui_file (&str_file, fn);
- return std::move (str_file.string ());
+ try
+ {
+ execute_fn_to_ui_file (&str_file, fn);
+ }
+ catch (...)
+ {
+ /* Finally. */
+ res = std::move (str_file.string ());
+ throw;
+ }
+
+ /* And finally. */
+ res = std::move (str_file.string ());
}
/* See gdbcmd.h. */
/* See gdbcmd.h. */
-std::string
+void
+execute_command_to_string (std::string &res, const char *p, int from_tty,
+ bool term_out)
+{
+ execute_fn_to_string (res, [=]() { execute_command (p, from_tty); },
+ term_out);
+}
+
+/* See gdbcmd.h. */
+
+void
execute_command_to_string (const char *p, int from_tty,
bool term_out)
{
- return
- execute_fn_to_string ([=]() { execute_command (p, from_tty); }, term_out);
+ std::string dummy;
+ execute_fn_to_string (dummy, [=]() { execute_command (p, from_tty); },
+ term_out);
}
\f
/* When nonzero, cause dont_repeat to do nothing. This should only be
/* Don't use a _filtered function here. It causes the assumed
character position to be off, since the newline we read from
the user is not accounted for. */
- fputs_unfiltered (prompt, gdb_stdout);
+ printf_unfiltered ("%s", prompt);
gdb_flush (gdb_stdout);
}
/* Make sure that all output has been output. Some machines may
let you get away with leaving out some of the gdb_flush, but
not all. */
- wrap_here ("");
+ gdb_stdout->wrap_here (0);
gdb_flush (gdb_stdout);
gdb_flush (gdb_stderr);
++source_line_number;
if (from_tty && annotation_level > 1)
- {
- puts_unfiltered ("\n\032\032pre-");
- puts_unfiltered (annotation_suffix);
- puts_unfiltered ("\n");
- }
+ printf_unfiltered ("\n\032\032pre-%s\n", annotation_suffix);
/* Don't use fancy stuff if not talking to stdin. */
if (deprecated_readline_hook
/* Second line is a copyright notice. */
fprintf_filtered (stream,
- "Copyright (C) 2021 Free Software Foundation, Inc.\n");
+ "Copyright (C) 2022 Free Software Foundation, Inc.\n");
/* Following the copyright is a brief statement that the program is
free software, that users are free to copy and change it on