/* GDB CLI commands.
- Copyright (C) 2000-2021 Free Software Foundation, Inc.
+ Copyright (C) 2000-2022 Free Software Foundation, Inc.
This file is part of GDB.
#include "target.h" /* For baud_rate, remote_debug and remote_timeout. */
#include "gdbsupport/gdb_wait.h" /* For shell escape implementation. */
#include "gdbcmd.h"
-#include "gdb_regex.h" /* Used by apropos_command. */
+#include "gdbsupport/gdb_regex.h" /* Used by apropos_command. */
#include "gdb_vfork.h"
#include "linespec.h"
#include "expression.h"
static const char *script_ext_mode = script_ext_soft;
\f
+
+/* User-controllable flag to suppress event notification on CLI. */
+
+static bool user_wants_cli_suppress_notification = false;
+
/* Utility used everywhere when at least one argument is needed and
none is supplied. */
safe_strerror (errno));
if (strcmp (cwd.get (), current_directory) != 0)
- printf_unfiltered (_("Working directory %ps\n (canonically %ps).\n"),
- styled_string (file_name_style.style (),
- current_directory),
- styled_string (file_name_style.style (), cwd.get ()));
+ printf_filtered (_("Working directory %ps\n (canonically %ps).\n"),
+ styled_string (file_name_style.style (),
+ current_directory),
+ styled_string (file_name_style.style (), cwd.get ()));
else
- printf_unfiltered (_("Working directory %ps.\n"),
- styled_string (file_name_style.style (),
- current_directory));
+ printf_filtered (_("Working directory %ps.\n"),
+ styled_string (file_name_style.style (),
+ current_directory));
}
void
printf_filtered ("%c", c);
}
- reset_terminal_style (gdb_stdout);
+ gdb_stdout->reset_style ();
/* Force this output to appear now. */
- wrap_here ("");
+ gdb_stdout->wrap_here (0);
gdb_flush (gdb_stdout);
}
struct symtab_and_line sal;
struct symbol *sym;
const char *editor;
- char *p;
const char *fn;
/* Pull in the current default source line if necessary. */
arg1 = arg;
event_location_up location = string_to_event_location (&arg1,
current_language);
+
+ if (*arg1)
+ error (_("Junk at end of line specification."));
+
std::vector<symtab_and_line> sals = decode_line_1 (location.get (),
DECODE_LINE_LIST_MODE,
NULL, NULL, 0);
sal = sals[0];
- if (*arg1)
- error (_("Junk at end of line specification."));
-
/* If line was specified by address, first print exactly which
line, and which file. In this case, sal.symtab == 0 means
address is outside of all known source files, not that user
error (_("No source file for address %s."),
paddress (get_current_arch (), sal.pc));
- gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch ();
+ gdbarch = sal.symtab->objfile ()->arch ();
sym = find_pc_function (sal.pc);
if (sym)
printf_filtered ("%s is in %s (%s:%d).\n",
/* Quote the file name, in case it has whitespace or other special
characters. */
- p = xstrprintf ("%s +%d \"%s\"", editor, sal.line, fn);
- shell_escape (p, from_tty);
- xfree (p);
+ gdb::unique_xmalloc_ptr<char> p
+ = xstrprintf ("%s +%d \"%s\"", editor, sal.line, fn);
+ shell_escape (p.get (), from_tty);
}
/* The options for the "pipe" command. */
{
event_location_up location = string_to_event_location (&arg1,
current_language);
+
+ /* We know that the ARG string is not empty, yet the attempt to parse
+ a location from the string consumed no characters. This most
+ likely means that the first thing in ARG looks like a location
+ condition, and so the string_to_event_location call stopped
+ parsing. */
+ if (arg1 == arg)
+ error (_("Junk at end of line specification."));
+
sals = decode_line_1 (location.get (), DECODE_LINE_LIST_MODE,
NULL, NULL, 0);
filter_sals (sals);
event_location_up location
= string_to_event_location (&arg1, current_language);
+ if (*arg1)
+ error (_("Junk at end of line specification."));
+
std::vector<symtab_and_line> sals_end
= (dummy_beg
? decode_line_1 (location.get (), DECODE_LINE_LIST_MODE,
error (_("No source file for address %s."),
paddress (get_current_arch (), sal.pc));
- gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch ();
+ gdbarch = sal.symtab->objfile ()->arch ();
sym = find_pc_function (sal.pc);
if (sym)
printf_filtered ("%s is in %s (%s:%d).\n",
static int
cmp_symtabs (const symtab_and_line &sala, const symtab_and_line &salb)
{
- const char *dira = SYMTAB_DIRNAME (sala.symtab);
- const char *dirb = SYMTAB_DIRNAME (salb.symtab);
+ const char *dira = sala.symtab->dirname ();
+ const char *dirb = salb.symtab->dirname ();
int r;
if (dira == NULL)
value);
}
+/* Implement 'show suppress-cli-notifications'. */
+
+static void
+show_suppress_cli_notifications (ui_file *file, int from_tty,
+ cmd_list_element *c, const char *value)
+{
+ fprintf_filtered (file, _("Suppression of printing CLI notifications "
+ "is %s.\n"), value);
+}
+
+/* Implement 'set suppress-cli-notifications'. */
+
+static void
+set_suppress_cli_notifications (const char *args, int from_tty,
+ cmd_list_element *c)
+{
+ cli_suppress_notification.user_selected_context
+ = user_wants_cli_suppress_notification;
+ cli_suppress_notification.normal_stop
+ = user_wants_cli_suppress_notification;
+}
+
/* Returns the cmd_list_element in SHOWLIST corresponding to the first
argument of ARGV, which must contain one single value.
Throws an error if no value provided, or value not correct.
cmd_list_element *quit_cmd
= add_com ("quit", class_support, quit_command, _("\
Exit gdb.\n\
-Usage: quit [EXPR]\n\
+Usage: quit [EXPR] or exit [EXPR]\n\
The optional expression EXPR, if present, is evaluated and the result\n\
used as GDB's exit code. The default is zero."));
cmd_list_element *help_cmd
_("Print list of commands."));
set_cmd_completer (help_cmd, command_completer);
add_com_alias ("q", quit_cmd, class_support, 1);
+ add_com_alias ("exit", quit_cmd, class_support, 1);
add_com_alias ("h", help_cmd, class_support, 1);
add_setshow_boolean_cmd ("verbose", class_support, &info_verbose, _("\
set_cmd_completer_handle_brkchars (c, alias_command_completer);
+ add_setshow_boolean_cmd ("suppress-cli-notifications", no_class,
+ &user_wants_cli_suppress_notification,
+ _("\
+Set whether printing notifications on CLI is suppressed."), _("\
+Show whether printing notifications on CLI is suppressed."), _("\
+When on, printing notifications (such as inferior/thread switch)\n\
+on CLI is suppressed."),
+ set_suppress_cli_notifications,
+ show_suppress_cli_notifications,
+ &setlist,
+ &showlist);
+
const char *source_help_text = xstrprintf (_("\
Read commands from a file named FILE.\n\
\n\
-v: each command in FILE is echoed as it is executed.\n\
\n\
Note that the file \"%s\" is read automatically in this way\n\
-when GDB is started."), GDBINIT);
+when GDB is started."), GDBINIT).release ();
c = add_cmd ("source", class_support, source_command,
source_help_text, &cmdlist);
set_cmd_completer (c, filename_completer);