/* GDB CLI commands.
- Copyright (C) 2000-2020 Free Software Foundation, Inc.
+ Copyright (C) 2000-2021 Free Software Foundation, Inc.
This file is part of GDB.
#include "extension.h"
#include "gdbsupport/pathstuff.h"
+#include "gdbsupport/gdb_tilde_expand.h"
#ifdef TUI
#include "tui/tui.h" /* For tui_active et.al. */
struct cmd_list_element *maintenancechecklist;
+/* Chain containing all defined "maintenance flush" subcommands. */
+
+struct cmd_list_element *maintenanceflushlist;
+
struct cmd_list_element *setprintlist;
struct cmd_list_element *showprintlist;
if (cwd == NULL)
error (_("Error finding name of working directory: %s"),
- safe_strerror (errno));
+ safe_strerror (errno));
if (strcmp (cwd.get (), current_directory) != 0)
printf_unfiltered (_("Working directory %ps\n (canonically %ps).\n"),
if (IS_DIR_SEPARATOR (dir[len - 1]))
{
/* Remove the trailing slash unless this is a root directory
- (including a drive letter on non-Unix systems). */
+ (including a drive letter on non-Unix systems). */
if (!(len == 1) /* "/" */
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
&& !(len == 3 && dir[1] == ':') /* "d:/" */
if (found_real_path)
{
/* Search backwards for the directory just before the "/.."
- and obliterate it and the "/..". */
+ and obliterate it and the "/..". */
char *q = p;
while (q != current_directory && !IS_DIR_SEPARATOR (q[-1]))
if (!opened)
{
/* The script wasn't found, or was otherwise inaccessible.
- If the source command was invoked interactively, throw an
+ If the source command was invoked interactively, throw an
error. Otherwise (e.g. if it was invoked by a script),
just emit a warning, rather than cause an error. */
if (from_tty)
anyway so that error messages show the actual file used. But only do
this if we (may have) used search_path, as printing the full path in
errors for the non-search case can be more noise than signal. */
- source_script_from_stream (opened->stream.get (), file,
- search_path ? opened->full_path.get () : file);
+ const char *file_to_open;
+ gdb::unique_xmalloc_ptr<char> tilde_expanded_file;
+ if (search_path)
+ file_to_open = opened->full_path.get ();
+ else
+ {
+ tilde_expanded_file = gdb_tilde_expand_up (file);
+ file_to_open = tilde_expanded_file.get ();
+ }
+ source_script_from_stream (opened->stream.get (), file, file_to_open);
}
/* Wrapper around source_script_with_search to export it to main.c
sal = sals[0];
if (*arg1)
- error (_("Junk at end of line specification."));
+ 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
- failed to give a filename. */
+ line, and which file. In this case, sal.symtab == 0 means
+ address is outside of all known source files, not that user
+ failed to give a filename. */
if (*arg == '*')
- {
+ {
struct gdbarch *gdbarch;
- if (sal.symtab == 0)
+ if (sal.symtab == 0)
error (_("No source file for address %s."),
paddress (get_current_arch (), sal.pc));
gdbarch = SYMTAB_OBJFILE (sal.symtab)->arch ();
- sym = find_pc_function (sal.pc);
- if (sym)
+ sym = find_pc_function (sal.pc);
+ if (sym)
printf_filtered ("%s is in %s (%s:%d).\n",
paddress (gdbarch, sal.pc),
sym->print_name (),
symtab_to_filename_for_display (sal.symtab),
sal.line);
- else
+ else
printf_filtered ("%s is at %s:%d.\n",
paddress (gdbarch, sal.pc),
symtab_to_filename_for_display (sal.symtab),
sal.line);
- }
+ }
/* If what was given does not imply a symtab, it must be an
- undebuggable symbol which means no source code. */
+ undebuggable symbol which means no source code. */
if (sal.symtab == 0)
- error (_("No line number known for %s."), arg);
+ error (_("No line number known for %s."), arg);
}
if ((editor = getenv ("EDITOR")) == NULL)
if (exit_status < 0)
error (_("shell command \"%s\" failed: %s"), shell_command,
- safe_strerror (errno));
+ safe_strerror (errno));
exit_status_set_internal_vars (exit_status);
}
else
#endif
{
- printf_filtered ("Dump of assembler code ");
+ printf_filtered (_("Dump of assembler code "));
if (name != NULL)
- printf_filtered ("for function %s:\n", name);
+ printf_filtered (_("for function %ps:\n"),
+ styled_string (function_name_style.style (), name));
if (block == nullptr || BLOCK_CONTIGUOUS_P (block))
- {
+ {
if (name == NULL)
- printf_filtered ("from %s to %s:\n",
- paddress (gdbarch, low), paddress (gdbarch, high));
+ printf_filtered (_("from %ps to %ps:\n"),
+ styled_string (address_style.style (),
+ paddress (gdbarch, low)),
+ styled_string (address_style.style (),
+ paddress (gdbarch, high)));
/* Dump the specified range. */
gdb_disassembly (gdbarch, current_uiout, flags, -1, low, high);
}
else
- {
+ {
for (int i = 0; i < BLOCK_NRANGES (block); i++)
{
CORE_ADDR range_low = BLOCK_RANGE_START (block, i);
CORE_ADDR range_high = BLOCK_RANGE_END (block, i);
- printf_filtered (_("Address range %s to %s:\n"),
- paddress (gdbarch, range_low),
- paddress (gdbarch, range_high));
+ printf_filtered (_("Address range %ps to %ps:\n"),
+ styled_string (address_style.style (),
+ paddress (gdbarch, range_low)),
+ styled_string (address_style.style (),
+ paddress (gdbarch, range_high)));
gdb_disassembly (gdbarch, current_uiout, flags, -1,
range_low, range_high);
}
}
- printf_filtered ("End of assembler dump.\n");
+ printf_filtered (_("End of assembler dump.\n"));
}
}
{
struct gdbarch *gdbarch = get_current_arch ();
CORE_ADDR low, high;
+ const general_symbol_info *symbol = nullptr;
const char *name;
CORE_ADDR pc;
gdb_disassembly_flags flags;
if (p[0] == '\0')
{
/* One argument. */
- if (find_pc_partial_function (pc, &name, &low, &high, &block) == 0)
+ if (!find_pc_partial_function_sym (pc, &symbol, &low, &high, &block))
error (_("No function contains specified address."));
+
+ if (asm_demangle)
+ name = symbol->print_name ();
+ else
+ name = symbol->linkage_name ();
+
#if defined(TUI)
/* NOTE: cagney/2003-02-13 The `tui_active' was previously
`tui_version'. */
{
for (c = cmdlist; c; c = c->next)
{
- if (cli_user_command_p (c) || c->prefixlist != NULL)
+ if (cli_user_command_p (c) || c->is_prefix ())
show_user_1 (c, "", c->name, gdb_stdout);
}
}
/* We've already tried to look up COMMAND. */
gdb_assert (c_command != NULL
&& c_command != (struct cmd_list_element *) -1);
- gdb_assert (c_command->prefixlist != NULL);
+ gdb_assert (c_command->is_prefix ());
c_alias = lookup_cmd_1 (& alias_prefix, cmdlist, NULL, NULL, 1);
if (c_alias != c_command)
error (_("ALIAS and COMMAND prefixes do not match."));
alias_cmd = add_alias_cmd (xstrdup (alias_argv[alias_argc - 1]),
command_argv[command_argc - 1],
class_alias, a_opts.abbrev_flag,
- c_command->prefixlist);
+ c_command->subcommands);
}
gdb_assert (alias_cmd != nullptr);
value);
}
-static void
-show_remote_debug (struct ui_file *file, int from_tty,
- struct cmd_list_element *c, const char *value)
-{
- fprintf_filtered (file, _("Debugging of remote protocol is %s.\n"),
- value);
-}
-
-static void
-show_remote_timeout (struct ui_file *file, int from_tty,
- struct cmd_list_element *c, const char *value)
-{
- fprintf_filtered (file,
- _("Timeout limit to wait for target to respond is %s.\n"),
- value);
-}
-
static void
show_max_user_call_depth (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
add_basic_prefix_cmd ("history", class_support, _("\
Generic command for setting command history parameters."),
- &sethistlist, "set history ", 0, &setlist);
+ &sethistlist, 0, &setlist);
add_show_prefix_cmd ("history", class_support, _("\
Generic command for showing command history parameters."),
- &showhistlist, "show history ", 0, &showlist);
+ &showhistlist, 0, &showlist);
add_setshow_boolean_cmd ("expansion", no_class, &history_expansion_p, _("\
Set history expansion on command input."), _("\
add_prefix_cmd ("info", class_info, info_command, _("\
Generic command for showing things about the program being debugged."),
- &infolist, "info ", 0, &cmdlist);
+ &infolist, 0, &cmdlist);
add_com_alias ("i", "info", class_info, 1);
add_com_alias ("inf", "info", class_info, 1);
c = add_show_prefix_cmd ("show", class_info, _("\
Generic command for showing things about the debugger."),
- &showlist, "show ", 0, &cmdlist);
+ &showlist, 0, &cmdlist);
/* Another way to get at the same thing. */
add_alias_cmd ("set", c, class_info, 0, &infolist);
add_cmd ("configuration", no_set_class, show_configuration,
_("Show how GDB was configured at build time."), &showlist);
- add_setshow_zinteger_cmd ("remote", no_class, &remote_debug, _("\
-Set debugging of remote protocol."), _("\
-Show debugging of remote protocol."), _("\
-When enabled, each packet sent or received with the remote target\n\
-is displayed."),
- NULL,
- show_remote_debug,
- &setdebuglist, &showdebuglist);
-
- add_setshow_zuinteger_unlimited_cmd ("remotetimeout", no_class,
- &remote_timeout, _("\
-Set timeout limit to wait for target to respond."), _("\
-Show timeout limit to wait for target to respond."), _("\
-This value is used to set the time limit for gdb to wait for a response\n\
-from the target."),
- NULL,
- show_remote_timeout,
- &setlist, &showlist);
-
add_basic_prefix_cmd ("debug", no_class,
_("Generic command for setting gdb debugging flags."),
- &setdebuglist, "set debug ", 0, &setlist);
+ &setdebuglist, 0, &setlist);
add_show_prefix_cmd ("debug", no_class,
_("Generic command for showing gdb debugging flags."),
- &showdebuglist, "show debug ", 0, &showlist);
+ &showdebuglist, 0, &showlist);
c = add_com ("shell", class_support, shell_command, _("\
Execute the rest of the line as a shell command.\n\
\n\
Examples:\n\
Make \"spe\" an alias of \"set print elements\":\n\
- alias spe set print elements\n\
+ alias spe = set print elements\n\
Make \"elms\" an alias of \"elements\" in the \"set print\" command:\n\
- alias -a set print elms set print elements\n\
+ alias -a set print elms = set print elements\n\
Make \"btf\" an alias of \"backtrace -full -past-entry -past-main\" :\n\
alias btf = backtrace -full -past-entry -past-main\n\
Make \"wLapPeu\" an alias of 2 nested \"with\":\n\