/* Top level stuff for GDB, the GNU debugger.
- Copyright (C) 1986-2019 Free Software Foundation, Inc.
+ Copyright (C) 1986-2020 Free Software Foundation, Inc.
This file is part of GDB.
#include "gdbsupport/scope-exit.h"
#include "gdbarch.h"
#include "gdbsupport/pathstuff.h"
+#include "cli/cli-style.h"
/* readline include files. */
#include "readline/readline.h"
struct cmd_list_element *c, const char *value)
{
fprintf_filtered (file, _("The filename in which to record "
- "the command history is \"%s\".\n"),
- value);
+ "the command history is \"%ps\".\n"),
+ styled_string (file_name_style.style (), value));
}
/* This is like readline(), but it has some gdb-specific behavior.
saved_errno = errno;
if (ret < 0 && saved_errno != ENOENT)
{
- warning (_("Could not rename %s to %s: %s"),
- history_filename, local_history_filename.c_str (),
+ warning (_("Could not rename %ps to %ps: %s"),
+ styled_string (file_name_style.style (), history_filename),
+ styled_string (file_name_style.style (),
+ local_history_filename.c_str ()),
safe_strerror (saved_errno));
}
else
/* Second line is a copyright notice. */
fprintf_filtered (stream,
- "Copyright (C) 2019 Free Software Foundation, Inc.\n");
+ "Copyright (C) 2020 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
}
\f
-struct qt_args
-{
- int from_tty;
-};
-
-/* Callback for iterate_over_inferiors. Kills or detaches the given
- inferior, depending on how we originally gained control of it. */
+/* Kills or detaches the given inferior, depending on how we originally
+ gained control of it. */
-static int
-kill_or_detach (struct inferior *inf, void *args)
+static void
+kill_or_detach (inferior *inf, int from_tty)
{
- struct qt_args *qt = (struct qt_args *) args;
-
if (inf->pid == 0)
- return 0;
+ return;
thread_info *thread = any_thread_of_inferior (inf);
if (thread != NULL)
if (target_has_execution)
{
if (inf->attach_flag)
- target_detach (inf, qt->from_tty);
+ target_detach (inf, from_tty);
else
target_kill ();
}
}
-
- return 0;
}
-/* Callback for iterate_over_inferiors. Prints info about what GDB
- will do to each inferior on a "quit". ARG points to a struct
- ui_out where output is to be collected. */
+/* Prints info about what GDB will do to inferior INF on a "quit". OUT is
+ where to collect the output. */
-static int
-print_inferior_quit_action (struct inferior *inf, void *arg)
+static void
+print_inferior_quit_action (inferior *inf, ui_file *out)
{
- struct ui_file *stb = (struct ui_file *) arg;
-
if (inf->pid == 0)
- return 0;
+ return;
if (inf->attach_flag)
- fprintf_filtered (stb,
+ fprintf_filtered (out,
_("\tInferior %d [%s] will be detached.\n"), inf->num,
target_pid_to_str (ptid_t (inf->pid)).c_str ());
else
- fprintf_filtered (stb,
+ fprintf_filtered (out,
_("\tInferior %d [%s] will be killed.\n"), inf->num,
target_pid_to_str (ptid_t (inf->pid)).c_str ());
-
- return 0;
}
/* If necessary, make the user confirm that we should quit. Return
string_file stb;
stb.puts (_("A debugging session is active.\n\n"));
- iterate_over_inferiors (print_inferior_quit_action, &stb);
+
+ for (inferior *inf : all_inferiors ())
+ print_inferior_quit_action (inf, &stb);
+
stb.puts (_("\nQuit anyway? "));
return query ("%s", stb.c_str ());
quit_force (int *exit_arg, int from_tty)
{
int exit_code = 0;
- struct qt_args qt;
undo_terminal_modifications_before_exit ();
else if (return_child_result)
exit_code = return_child_result_value;
- qt.from_tty = from_tty;
-
/* We want to handle any quit errors and exit regardless. */
/* Get out of tfind mode, and kill or detach all inferiors. */
try
{
disconnect_tracing ();
- iterate_over_inferiors (kill_or_detach, &qt);
+ for (inferior *inf : all_inferiors ())
+ kill_or_detach (inf, from_tty);
}
catch (const gdb_exception &ex)
{
/* Give all pushed targets a chance to do minimal cleanup, and pop
them all out. */
- try
- {
- pop_all_targets ();
- }
- catch (const gdb_exception &ex)
+ for (inferior *inf : all_inferiors ())
{
- exception_print (gdb_stderr, ex);
+ switch_to_inferior_no_thread (inf);
+ try
+ {
+ pop_all_targets ();
+ }
+ catch (const gdb_exception &ex)
+ {
+ exception_print (gdb_stderr, ex);
+ }
}
/* Save the history information if it is appropriate to do so. */
show_gdb_datadir (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- fprintf_filtered (file, _("GDB's data directory is \"%s\".\n"),
- gdb_datadir.c_str ());
+ fprintf_filtered (file, _("GDB's data directory is \"%ps\".\n"),
+ styled_string (file_name_style.style (),
+ gdb_datadir.c_str ()));
}
static void
#endif
init_cmd_lists (); /* This needs to be done first. */
- initialize_targets (); /* Setup target_terminal macros for utils.c. */
init_page_info ();