22#include "readline/tilde.h"
25#include "gdbsupport/gdb_wait.h"
27#include "gdbsupport/gdb_regex.h"
39#include "gdbsupport/filestuff.h"
58#include "gdbsupport/pathstuff.h"
59#include "gdbsupport/gdb_tilde_expand.h"
74 const char *format, ...)
208 error (_(
"Argument required (%s)."), why);
229 error (_(
"Missing arguments."));
231 const char *delim = strstr (args,
"--");
232 const char *nested_cmd =
nullptr;
235 error (_(
"Missing setting before '--' delimiter"));
237 if (delim ==
nullptr || *skip_spaces (&delim[2]) ==
'\0')
244 gdb_assert (
set_cmd !=
nullptr);
246 if (!
set_cmd->var.has_value ())
247 error (_(
"Cannot use this setting with the \"with\" command"));
249 std::string temp_value
250 = (delim ==
nullptr ? args : std::string (args, delim - args));
252 if (nested_cmd ==
nullptr)
253 nested_cmd = skip_spaces (delim + 2);
255 gdb_assert (
set_cmd->var.has_value ());
263 scoped_restore save_async = make_scoped_restore (&
current_ui->
async, 0);
268 catch (
const gdb_exception &ex)
277 catch (
const gdb_exception &ex2)
279 warning (_(
"Couldn't restore setting: %s"), ex2.what ());
298 const char *delim = strstr (text,
"--");
304 || !isspace (delim[-1])
305 || !(isspace (delim[2]) || delim[2] ==
'\0'))
307 std::string new_text = std::string (set_cmd_prefix) + text;
314 const char *nested_cmd = skip_spaces (delim + 2);
332 const char *text,
const char * )
347 const char *orig_text = *text;
350 if (*text ==
nullptr || skip_spaces (*text) ==
nullptr)
351 error (_(
"ALIAS missing."));
375 (std::string (orig_text, *text - orig_text).c_str (),
376 &
alias, prefix_cmd, &cmd);
377 gdb_assert (cmd !=
nullptr);
378 gdb_assert (cmd == lcmd);
379 if (
alias !=
nullptr)
410 " completion is disabled.\n"));
418 int quote_char =
'\0';
425 std::string arg_prefix (arg, word - arg);
449 arg_prefix.c_str (), word,
491 error (_(
"Not confirmed."));
497 catch (
const gdb_exception_error &ex)
499 if (ex.error == TARGET_CLOSE_ERROR)
508 quit_force (args ? &exit_code : NULL, from_tty);
515 error (_(
"The \"pwd\" command does not take an argument: %s"), args);
517 gdb::unique_xmalloc_ptr<char> cwd (getcwd (NULL, 0));
520 error (_(
"Error finding name of working directory: %s"),
521 safe_strerror (errno));
523 if (strcmp (cwd.get (), current_directory) != 0)
524 gdb_printf (_(
"Working directory %ps\n (canonically %ps).\n"),
546 gdb::unique_xmalloc_ptr<char> dir_holder
547 (tilde_expand (dir != NULL ? dir :
"~"));
548 dir = dir_holder.get ();
551 perror_with_name (dir);
553#ifdef HAVE_DOS_BASED_FILE_SYSTEM
557 gdb::unique_xmalloc_ptr<char> cwd (getcwd (NULL, 0));
562 if (IS_DIR_SEPARATOR (dir[len - 1]))
567#ifdef HAVE_DOS_BASED_FILE_SYSTEM
568 && !(len == 3 && dir[1] ==
':')
574 dir_holder.reset (savestring (dir, len));
575 if (IS_ABSOLUTE_PATH (dir_holder.get ()))
577 xfree (current_directory);
578 current_directory = dir_holder.release ();
582 if (IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1]))
583 current_directory = concat (current_directory, dir_holder.get (),
586 current_directory = concat (current_directory, SLASH_STRING,
587 dir_holder.get (), (
char *) NULL);
593 for (p = current_directory; *p;)
595 if (IS_DIR_SEPARATOR (p[0]) && p[1] ==
'.'
596 && (p[2] == 0 || IS_DIR_SEPARATOR (p[2])))
597 memmove (p, p + 2, strlen (p + 2) + 1);
598 else if (IS_DIR_SEPARATOR (p[0]) && p[1] ==
'.' && p[2] ==
'.'
599 && (p[3] == 0 || IS_DIR_SEPARATOR (p[3])))
607 while (q != current_directory && !IS_DIR_SEPARATOR (q[-1]))
610 if (q == current_directory)
616 memmove (q - 1, p + 3, strlen (p + 3) + 1);
645 _(
"Script filename extension recognition is \"%s\".\n"),
658gdb::optional<open_script>
663 gdb::optional<open_script> opened;
665 gdb::unique_xmalloc_ptr<char> file (tilde_expand (script_file));
672 gdb::unique_xmalloc_ptr<char> full_path;
674 file.get (), O_RDONLY, &full_path);
679 FILE *result = fdopen (fd, FOPEN_RT);
682 int save_errno = errno;
688 opened.emplace (gdb_file_up (result), std::move (full_path));
702 const char *file_to_open)
716 gdb_assert (sourcer != NULL);
717 sourcer (extlang, stream, file_to_open);
742 if (file == NULL || *file == 0)
743 error (_(
"source command requires file name of file to source."));
753 perror_with_name (file);
766 const char *file_to_open;
767 std::string tilde_expanded_file;
769 file_to_open = opened->full_path.get ();
772 tilde_expanded_file = gdb_tilde_expand (file);
773 file_to_open = tilde_expanded_file.c_str ();
790 const char *file = args;
793 scoped_restore save_source_verbose = make_scoped_restore (&
source_verbose);
803 while (args[0] !=
'\0')
807 args = skip_spaces (args);
812 if (args[1] ==
'v' && isspace (args[2]))
819 else if (args[1] ==
's' && isspace (args[2]))
830 file = skip_spaces (args);
840 const char *p = text;
844 while ((c = *p++) !=
'\0')
881 if (WIFEXITED (exit_status))
884 else if (WIFSIGNALED (exit_status) && WTERMSIG (exit_status) == -1)
895 else if (WIFSIGNALED (exit_status))
898 warning (_(
"unexpected shell command exit status %d"), exit_status);
907#if defined(CANT_FORK) || \
908 (!defined(HAVE_WORKING_VFORK) && !defined(HAVE_WORKING_FORK))
911 int rc = system (arg ? arg :
"");
914 arg =
"inferior shell";
918 safe_strerror (errno));
924 chdir (current_directory);
930 if ((
pid = vfork ()) == 0)
932 const char *p, *user_shell = get_shell ();
937 p = lbasename (user_shell);
940 execl (user_shell, p, (
char *) 0);
942 execl (user_shell, p,
"-c", arg, (
char *) 0);
945 safe_strerror (errno));
952 error (_(
"Fork failed"));
996 error (_(
"No default source file yet."));
1009 error (_(
"Junk at end of line specification."));
1011 std::vector<symtab_and_line> sals =
decode_line_1 (locspec.get (),
1021 if (sals.size () > 1)
1024 _(
"Specified line is ambiguous:\n"));
1039 error (_(
"No source file for address %s."),
1061 error (_(
"No line number known for %s."), arg);
1064 if ((editor = getenv (
"EDITOR")) == NULL)
1071 gdb::unique_xmalloc_ptr<char> p
1072 = xstrprintf (
"%s +%d \"%s\"", editor, sal.
line, fn);
1090 N_(
"Indicates to use the specified delimiter string to separate\n\
1091COMMAND from SHELL_COMMAND, in alternative to |. This is useful in\n\
1092case COMMAND contains a | character."),
1117 const char *delim =
"|";
1118 if (!opts.delimiter.empty ())
1119 delim = opts.delimiter.c_str ();
1121 const char *command = arg;
1122 if (command ==
nullptr)
1123 error (_(
"Missing COMMAND"));
1125 arg = strstr (arg, delim);
1128 error (_(
"Missing delimiter before SHELL_COMMAND"));
1130 std::string gdb_cmd (command, arg - command);
1132 arg += strlen (delim);
1134 if (gdb_cmd.empty ())
1139 error (_(
"Missing SHELL_COMMAND"));
1143 if (to_shell_command ==
nullptr)
1154 pclose (to_shell_command);
1158 int exit_status = pclose (to_shell_command);
1160 if (exit_status < 0)
1162 safe_strerror (errno));
1171 const char *text,
const char *word_ignored)
1175 const char *org_text = text;
1181 const char *delimiter =
"|";
1182 if (!opts.delimiter.empty ())
1183 delimiter = opts.delimiter.c_str ();
1186 if (text > org_text && !isspace (text[-1]))
1189 const char *delim = strstr (text, delimiter);
1193 if (delim ==
nullptr || delim == text)
1218 if (arg != NULL && arg[0] ==
'-'
1233 int linenum_beg = 0;
1237 if (arg == NULL || ((arg[0] ==
'+' || arg[0] ==
'-' || arg[0] ==
'.') && arg[1] ==
'\0'))
1251 else if (arg ==
nullptr || arg[0] ==
'+')
1258 error (_(
"End of the file was already reached, use \"list .\" to"
1259 " list the current location again"));
1265 else if (arg[0] ==
'-')
1268 error (_(
"Already at the start of %s."),
1276 else if (arg[0] ==
'.')
1311 error (_(
"No symbol table is loaded. Use the \"file\" command."));
1313 std::vector<symtab_and_line> sals;
1330 error (_(
"Junk at end of line specification."));
1346 for (p = arg; p != arg1 && *p >=
'0' && *p <=
'9'; p++);
1347 linenum_beg = (p == arg1);
1351 const char *beg = arg;
1352 size_t beg_len = arg1 - beg;
1354 while (*arg1 ==
' ' || *arg1 ==
'\t')
1359 if (sals.size () > 1)
1362 _(
"Specified first line '%.*s' is ambiguous:\n"),
1363 (
int) beg_len, beg);
1367 while (*arg1 ==
' ' || *arg1 ==
'\t')
1375 const char *end_arg = arg1;
1381 error (_(
"Junk at end of line specification."));
1383 std::vector<symtab_and_line> sals_end
1391 if (sals_end.empty ())
1393 if (sals_end.size () > 1)
1396 _(
"Specified last line '%s' is ambiguous:\n"),
1400 sal_end = sals_end[0];
1405 error (_(
"Junk at end of line specification."));
1407 if (!no_end && !dummy_beg && !dummy_end
1409 error (_(
"Specified first and last lines are in different files."));
1410 if (dummy_beg && dummy_end)
1411 error (_(
"Two empty args do not say what lines to list."));
1423 error (_(
"No source file for address %s."),
1443 if (!linenum_beg && sal.
symtab == 0)
1444 error (_(
"No line number known for %s."), arg);
1452 if (dummy_beg && sal_end.
symtab == 0)
1453 error (_(
"No default source file yet. Do \"help list\"."));
1460 else if (sal.
symtab == 0)
1461 error (_(
"No default source file yet. Do \"help list\"."));
1464 for (
int i = 0; i < sals.size (); i++)
1470 if (sals.size () > 1)
1494 CORE_ADDR low, CORE_ADDR high,
1496 gdb_disassembly_flags
flags)
1524 CORE_ADDR range_low =
range.start ();
1525 CORE_ADDR range_high =
range.end ();
1527 gdb_printf (_(
"Address range %ps to %ps:\n"),
1533 range_low, range_high);
1548 CORE_ADDR low, high, pc;
1556 error (_(
"No function contains program counter for selected frame."));
1600 CORE_ADDR low, high;
1604 gdb_disassembly_flags
flags;
1617 error (_(
"Missing modifier."));
1619 while (*p && ! isspace (*p))
1636 error (_(
"Invalid disassembly modifier."));
1640 p = skip_spaces (p);
1645 error (_(
"Cannot specify both /m and /s."));
1661 error (_(
"No function contains specified address."));
1683 p = skip_spaces (p);
1704 std::string cmd = std::string (
"make ") + arg;
1717 const char *comname = args;
1721 error (_(
"Not a user command."));
1750 subcommand !=
nullptr;
1751 subcommand = subcommand->next)
1772 const char *curr_cmd = text;
1773 const char *after = skip_to_space (text);
1774 const size_t curr_cmd_len = after - text;
1775 text = skip_spaces (after);
1779 if (strlen (c->name) == curr_cmd_len
1780 && strncmp (c->name, curr_cmd, curr_cmd_len) == 0)
1782 if (c->subcommands ==
nullptr)
1793 const int wordlen = strlen (word);
1797 if (strncmp (c->name, word, wordlen) == 0)
1799 (gdb::unique_xmalloc_ptr<char> (xstrdup (c->name)));
1811 if (arg == NULL || *arg ==
'\0')
1812 error (_(
"REGEXP string is empty"));
1814 compiled_regex pattern (arg, REG_ICASE,
1815 _(
"Error in regular expression"));
1832 [] (
alias_opts *opts) {
return &opts->abbrev_flag; },
1833 N_(
"Specify that ALIAS is an abbreviation of COMMAND.\n\
1834Abbreviations are not used in command completion."),
1853 const char *text,
const char *word)
1863 const char *delim = strchr (text,
'=');
1870 && isspace (delim[-1])
1871 && (isspace (delim[1]) || delim[1] ==
'\0'))
1873 std::string new_text = std::string (delim + 1);
1898 gdb_assert (argv != NULL);
1899 gdb_assert (n >= 0 && n <= countargv (argv));
1901 for (i = 0; i < n; ++i)
1925 std::string default_args;
1930 error (_(
"Invalid command to alias to: %s"), command);
1932 if (!default_args.empty ())
1933 error (_(
"Cannot define an alias of an alias that has default args"));
1943 error (_(
"Usage: alias [-a] [--] ALIAS = COMMAND [DEFAULT-ARGS...]"));
1957 int i, alias_argc, command_argc;
1959 const char *
alias, *command;
1961 if (args == NULL || strchr (args,
'=') == NULL)
1964 equals = strchr (args,
'=');
1965 std::string args2 (args, equals - args);
1967 gdb_argv built_alias_argv (args2.c_str ());
1969 const char *default_args = equals + 1;
1973 std::string command_argv_str (equals + 1,
1975 ? strlen (equals + 1)
1977 gdb_argv command_argv (command_argv_str.c_str ());
1979 char **alias_argv = built_alias_argv.get ();
1981 if (alias_argv[0] == NULL || command_argv[0] == NULL
1982 || *alias_argv[0] ==
'\0' || *command_argv[0] ==
'\0')
1985 for (i = 0; alias_argv[i] != NULL; ++i)
1990 error (_(
"Invalid command name: %s"), alias_argv[i]);
1992 error (_(
"Invalid command element name: %s"), alias_argv[i]);
1996 alias_argc = countargv (alias_argv);
1997 command_argc = command_argv.count ();
2004 command = command_string.c_str ();
2008 std::string alias_string (
argv_to_string (alias_argv, alias_argc));
2009 alias = alias_string.c_str ();
2015 const char *alias_name = alias_argv[alias_argc-1];
2020 if (alias_cmd !=
nullptr
2021 && alias_cmd->
prefix == prefix_cmd
2022 && strcmp (alias_name, alias_cmd->
name) == 0)
2023 error (_(
"Alias already exists: %s"),
alias);
2027 if (cmd->
prefix == prefix_cmd
2028 && strcmp (alias_name, cmd->
name) == 0)
2029 error (_(
"Alias %s is the name of an existing command"),
alias);
2045 if (alias_argc == 1)
2048 alias_cmd =
add_com_alias (xstrdup (alias_argv[0]), target_cmd,
2053 const char *alias_prefix, *command_prefix;
2056 if (alias_argc != command_argc)
2057 error (_(
"Mismatched command length between ALIAS and COMMAND."));
2064 std::string command_prefix_string (
argv_to_string (command_argv.get (),
2066 alias_prefix = alias_prefix_string.c_str ();
2067 command_prefix = command_prefix_string.c_str ();
2071 gdb_assert (c_command != NULL
2075 if (c_alias != c_command)
2076 error (_(
"ALIAS and COMMAND prefixes do not match."));
2079 alias_cmd =
add_alias_cmd (xstrdup (alias_argv[alias_argc - 1]),
2084 gdb_assert (alias_cmd !=
nullptr);
2103 const char *sym_name = NULL;
2106 gdb_printf (_(
"file: \"%s\", line number: %d, symbol: \"%s\"\n"),
2108 sal.
line, sym_name != NULL ? sym_name :
"???");
2120 const char *format, ...)
2123 va_start (ap, format);
2127 for (
const auto &sal : sals)
2146 else if (dirb == NULL)
2153 r = filename_cmp (dira, dirb);
2164 return sala.
line == salb.
line ? 0 : 1;
2174 auto from = std::remove_if (sals.begin (), sals.end (),
2176 { return (sal.pspace != current_program_space || sal.symtab == NULL); });
2179 std::sort (sals.begin (), from,
2181 { return cmp_symtabs (sala, salb) < 0; });
2183 from = std::unique (sals.begin (), from,
2186 { return cmp_symtabs (sala, salb) == 0; });
2188 sals.erase (from, sals.end ());
2198 _(
"Verbose printing of informational messages is %s.\n"),
2208 gdb_printf (file, _(
"History expansion on command input is %s.\n"),
2217 _(
"The max call depth for user-defined commands is %s.\n"),
2227 gdb_printf (file, _(
"Suppression of printing CLI notifications "
2228 "is %s.\n"),
value);
2250 int argc,
struct value **argv)
2253 error (_(
"You must provide an argument to %s"), fnname);
2255 error (_(
"You can only provide one argument to %s"), fnname);
2259 if (type0->
code () != TYPE_CODE_ARRAY
2260 && type0->
code () != TYPE_CODE_STRING)
2261 error (_(
"First argument of %s must be a string."), fnname);
2267 const std::string
setting ((
const char *) argv[0]->contents ().data (),
2269 const char *a0 =
setting.c_str ();
2275 std::vector<std::string> components
2277 std::string full_name = components[0];
2278 for (
int i = 1; i < components.size (); ++i)
2279 full_name +=
" " + components[i];
2280 error (_(
"First argument of %s must be a valid setting of the "
2281 "'%s' command."), fnname, full_name.c_str ());
2289static struct value *
2292 switch (var.
type ())
2300 ?
static_cast<LONGEST
> (var.
get<
unsigned int> ())
2301 :
static_cast<LONGEST
> (var.
get<
int> ()));
2307 if (
value == l->use)
2309 if (l->val.has_value ())
2319 static_cast<unsigned int> (
value));
2323 static_cast<int> (
value));
2327 var.
get<
bool> () ? 1 : 0);
2344 gdb_assert_not_reached (
"invalid var_auto_boolean");
2360 len = strlen (
value);
2364 const std::string &st = var.
get<std::string> ();
2365 value = st.c_str ();
2372 gdb_assert_not_reached (
"bad var_type");
2378static struct value *
2381 void *cookie,
int argc,
struct value **argv)
2386 gdb_assert (
show_cmd->var.has_value ());
2393static struct value *
2396 void *cookie,
int argc,
struct value **argv)
2401 gdb_assert (
show_cmd->var.has_value ());
2408static struct value *
2411 switch (var.
type ())
2440 len = strlen (
value);
2444 const std::string &st = var.
get<std::string> ();
2445 value = st.c_str ();
2452 gdb_assert_not_reached (
"bad var_type");
2458static struct value *
2461 void *cookie,
int argc,
struct value **argv)
2466 gdb_assert (
show_cmd->var.has_value ());
2474static struct value *
2477 void *cookie,
int argc,
struct value **argv)
2483 gdb_assert (
show_cmd->var.has_value ());
2490static struct value *
2493 void *cookie,
int argc,
struct value **argv)
2496 error (_(
"You must provide one argument for $_shell."));
2498 value *val = argv[0];
2502 error (_(
"Argument must be a string."));
2511 gdb_assert (stream.
size () >= 2);
2515 std::string str = stream.
release ();
2516 str[str.size () - 1] = 0;
2517 const char *command = str.c_str () + 1;
2526 if (WIFEXITED (exit_status))
2529 else if (WIFSIGNALED (exit_status) && WTERMSIG (exit_status) == -1)
2535 else if (WIFSIGNALED (exit_status))
2555Maintenance commands.\n\
2556Some gdb commands are provided just for use by gdb maintainers.\n\
2557These commands are subject to frequent change, and may not be as\n\
2558well documented as user commands."),
2562 _(
"User-defined aliases of other commands."), &
cmdlist);
2564User-defined commands.\n\
2565The commands in this class are those defined by the user.\n\
2566Use the \"define\" command to define a command."), &
cmdlist);
2572 _(
"Making program stop at certain points."), &
cmdlist);
2575Examining the stack.\n\
2576The stack is made up of stack frames. Gdb assigns numbers to stack frames\n\
2577counting from zero for the innermost (currently executing) frame.\n\n\
2578At any time gdb identifies one frame as the \"selected\" frame.\n\
2579Variable lookups are done with respect to the selected frame.\n\
2580When the program being debugged stops, gdb selects the innermost frame.\n\
2581The commands below can be used to select other frames by number or address."),
2585 _(
"TUI is the GDB text based interface.\n\
2586In TUI mode, GDB can display several text windows showing\n\
2587the source file, the processor registers, the program disassembly, ..."), &
cmdlist);
2594Print working directory.\n\
2595This is used for your program as well."));
2598Set working directory to DIR for debugger.\n\
2599The debugger's current working directory specifies where scripts and other\n\
2600files that can be loaded by GDB are located.\n\
2601In order to change the inferior's current working directory, the recommended\n\
2602way is to use the \"set cwd\" command."), &
cmdlist);
2606Print a constant string. Give string as argument.\n\
2607C escape sequences may be used in the argument.\n\
2608No newline is added at the end of the argument;\n\
2609use \"\\n\" if you want a newline to be printed.\n\
2610Since leading and trailing whitespace are ignored in command arguments,\n\
2611if you want to print some you must use \"\\\" before leading whitespace\n\
2612to be printed or after trailing whitespace."));
2616Set mode for script filename extension recognition."), _(
"\
2617Show mode for script filename extension recognition."), _(
"\
2618off == no filename extension recognition (all sourced files are GDB scripts)\n\
2619soft == evaluate script according to filename extension, fallback to GDB script"
2621strict == evaluate script according to filename extension, error if not supported"
2630Usage: quit [EXPR] or exit [EXPR]\n\
2631The optional expression EXPR, if present, is evaluated and the result\n\
2632used as GDB's exit code. The default is zero."));
2635 _(
"Print list of commands."));
2642Set verbosity."), _(
"\
2643Show verbosity."), NULL,
2650 _(
"Generic command for setting command history parameters."),
2651 _(
"Generic command for showing command history parameters."),
2655Set history expansion on command input."), _(
"\
2656Show history expansion on command input."), _(
"\
2657Without an argument, history expansion is enabled."),
2664Generic command for showing things about the program being debugged."),
2670 _(
"List the completions for the rest of the line as a command."));
2673Generic command for showing things about the debugger."),
2680Temporarily set SETTING to VALUE, run COMMAND, and restore SETTING.\n\
2681Usage: with SETTING [VALUE] [-- COMMAND]\n\
2682Usage: w SETTING [VALUE] [-- COMMAND]\n\
2683With no COMMAND, repeats the last executed command.\n\
2685SETTING is any setting you can change with the \"set\" subcommands.\n\
2687 with language pascal -- print obj\n\
2688 with print elements unlimited -- print obj\n\
2690You can change multiple settings using nested with, and use\n\
2691abbreviations for commands and/or values. E.g.:\n\
2692 w la p -- w p el u -- p obj"));
2697$_gdb_setting_str - returns the value of a GDB setting as a string.\n\
2698Usage: $_gdb_setting_str (setting)\n\
2700auto-boolean values are \"off\", \"on\", \"auto\".\n\
2701boolean values are \"off\", \"on\".\n\
2702Some integer settings accept an unlimited value, returned\n\
2707$_gdb_setting - returns the value of a GDB setting.\n\
2708Usage: $_gdb_setting (setting)\n\
2709auto-boolean values are \"off\", \"on\", \"auto\".\n\
2710boolean values are \"off\", \"on\".\n\
2711Some integer settings accept an unlimited value, returned\n\
2712as 0 or -1 depending on the setting."),
2716$_gdb_maint_setting_str - returns the value of a GDB maintenance setting as a string.\n\
2717Usage: $_gdb_maint_setting_str (setting)\n\
2719auto-boolean values are \"off\", \"on\", \"auto\".\n\
2720boolean values are \"off\", \"on\".\n\
2721Some integer settings accept an unlimited value, returned\n\
2726$_gdb_maint_setting - returns the value of a GDB maintenance setting.\n\
2727Usage: $_gdb_maint_setting (setting)\n\
2728auto-boolean values are \"off\", \"on\", \"auto\".\n\
2729boolean values are \"off\", \"on\".\n\
2730Some integer settings accept an unlimited value, returned\n\
2731as 0 or -1 depending on the setting."),
2735$_shell - execute a shell command and return the result.\n\
2737 Usage: $_shell (COMMAND)\n\
2741 COMMAND: The command to execute. Must be a string.\n\
2744 The command's exit code: zero on success, non-zero otherwise."),
2748Show the history of commands you typed.\n\
2749You can supply a command number to start with, or a `+' to start after\n\
2750the previous command number shown."),
2754 _(
"Show what version of GDB this is."), &
showlist);
2757 _(
"Show how GDB was configured at build time."), &
showlist);
2760 _(
"Generic command for setting gdb debugging flags."),
2761 _(
"Generic command for showing gdb debugging flags."),
2767Execute the rest of the line as a shell command.\n\
2768With no arguments, run an inferior shell."));
2774Edit specified file or function.\n\
2775With no argument, edits file containing most recent line listed.\n\
2776Editing targets can be specified in these ways:\n\
2777 FILE:LINENUM, to edit at that line in that file,\n\
2778 FUNCTION, to edit at the beginning of that function,\n\
2779 FILE:FUNCTION, to distinguish among like-named static functions.\n\
2780 *ADDRESS, to edit at the line containing that address.\n\
2781Uses EDITOR environment variable contents as editor (or ex as default)."));
2787Send the output of a gdb command to a shell command.\n\
2788Usage: | [COMMAND] | SHELL_COMMAND\n\
2789Usage: | -d DELIM COMMAND DELIM SHELL_COMMAND\n\
2790Usage: pipe [COMMAND] | SHELL_COMMAND\n\
2791Usage: pipe -d DELIM COMMAND DELIM SHELL_COMMAND\n\
2793Executes COMMAND and sends its output to SHELL_COMMAND.\n\
2795The -d option indicates to use the string DELIM to separate COMMAND\n\
2796from SHELL_COMMAND, in alternative to |. This is useful in\n\
2797case COMMAND contains a | character.\n\
2799With no COMMAND, repeat the last executed command\n\
2800and send its output to SHELL_COMMAND."));
2806List specified function or line.\n\
2807With no argument, lists ten more lines after or around previous listing.\n\
2808\"list +\" lists the ten lines following a previous ten-line listing.\n\
2809\"list -\" lists the ten lines before a previous ten-line listing.\n\
2810\"list .\" lists ten lines around the point of execution in the current frame.\n\
2811One argument specifies a line, and ten lines are listed around that line.\n\
2812Two arguments with comma between specify starting and ending lines to list.\n\
2813Lines can be specified in these ways:\n\
2814 LINENUM, to list around that line in current file,\n\
2815 FILE:LINENUM, to list around that line in that file,\n\
2816 FUNCTION, to list around beginning of that function,\n\
2817 FILE:FUNCTION, to distinguish among like-named static functions.\n\
2818 *ADDRESS, to list around the line containing that address.\n\
2819With two args, if one is empty, it stands for ten lines away from\n\
2822By default, when a single location is given, display ten lines.\n\
2823This can be changed using \"set listsize\", and the current value\n\
2824can be shown using \"show listsize\"."));
2829Disassemble a specified section of memory.\n\
2830Usage: disassemble[/m|/r|/s] START [, END]\n\
2831Default is the function surrounding the pc of the selected frame.\n\
2833With a /s modifier, source lines are included (if available).\n\
2834In this mode, the output is displayed in PC address order, and\n\
2835file names and contents for all relevant source files are displayed.\n\
2837With a /m modifier, source lines are included (if available).\n\
2838This view is \"source centric\": the output is in source line order,\n\
2839regardless of any optimization that is present. Only the main source file\n\
2840is displayed, not those of, e.g., any inlined functions.\n\
2841This modifier hasn't proved useful in practice and is deprecated\n\
2844With a /r modifier, raw instructions in hex are included.\n\
2846With a single argument, the function surrounding that address is dumped.\n\
2847Two arguments (separated by a comma) are taken as a range of memory to dump,\n\
2848 in the form of \"start,end\", or \"start,+length\".\n\
2850Note that the address is interpreted as an expression, not as a location\n\
2851like in the \"break\" command.\n\
2852So, for example, if you want to disassemble function bar in file foo.c\n\
2853you must type \"disassemble 'foo.c'::bar\" and not \"disassemble foo.c:bar\"."));
2857Run the ``make'' program using the rest of the line as arguments."));
2860Show definitions of non-python/scheme user defined commands.\n\
2861Argument is the name of the user defined command.\n\
2862With no argument, show definitions of all user defined commands."), &
showlist);
2865Search for commands matching a REGEXP.\n\
2866Usage: apropos [-v] REGEXP\n\
2867Flag -v indicates to produce a verbose output, showing full documentation\n\
2868of the matching commands."));
2872Set the max call depth for non-python/scheme user-defined commands."), _(
"\
2873Show the max call depth for non-python/scheme user-defined commands."), NULL,
2879Set tracing of GDB CLI commands."), _(
"\
2880Show state of GDB CLI command tracing."), _(
"\
2881When 'on', each command is displayed as it is executed."),
2888 static std::string alias_help
2890Define a new command that is an alias of an existing command.\n\
2891Usage: alias [-a] [--] ALIAS = COMMAND [DEFAULT-ARGS...]\n\
2892ALIAS is the name of the alias command to create.\n\
2893COMMAND is the command being aliased to.\n\
2898GDB will automatically prepend the provided DEFAULT-ARGS to the list\n\
2899of arguments explicitly provided when using ALIAS.\n\
2900Use \"help aliases\" to list all user defined aliases and their default args.\n\
2903Make \"spe\" an alias of \"set print elements\":\n\
2904 alias spe = set print elements\n\
2905Make \"elms\" an alias of \"elements\" in the \"set print\" command:\n\
2906 alias -a set print elms = set print elements\n\
2907Make \"btf\" an alias of \"backtrace -full -past-entry -past-main\" :\n\
2908 alias btf = backtrace -full -past-entry -past-main\n\
2909Make \"wLapPeu\" an alias of 2 nested \"with\":\n\
2910 alias wLapPeu = with language pascal -- with print elements unlimited --"),
2914 alias_help.c_str ());
2921Set whether printing notifications on CLI is suppressed."), _(
"\
2922Show whether printing notifications on CLI is suppressed."), _(
"\
2923When on, printing notifications (such as inferior/thread switch)\n\
2924on CLI is suppressed."),
2930 const char *source_help_text = xstrprintf (_(
"\
2931Read commands from a file named FILE.\n\
2933Usage: source [-s] [-v] FILE\n\
2934-s: search for the script in the source search path,\n\
2935 even if FILE contains directories.\n\
2936-v: each command in FILE is echoed as it is executed.\n\
2938Note that the file \"%s\" is read automatically in this way\n\
2939when GDB is started."),
GDBINIT).release ();
struct gdbarch * get_current_arch(void)
bool find_pc_partial_function_sym(CORE_ADDR pc, const struct general_symbol_info **sym, CORE_ADDR *address, CORE_ADDR *endaddr, const struct block **block)
struct symbol * find_pc_function(CORE_ADDR pc)
bool find_pc_partial_function(CORE_ADDR pc, const char **name, CORE_ADDR *address, CORE_ADDR *endaddr, const struct block **block)
ui_file_style style() const
void add_completion(gdb::unique_xmalloc_ptr< char > name, completion_match_for_lcd *match_for_lcd=NULL, const char *text=NULL, const char *word=NULL)
void advance_custom_word_point_by(int len)
void set_use_custom_word_point(bool enable)
struct cmd_list_element * showlist
static gdb::option::option_def_group make_alias_options_def_group(alias_opts *a_opts)
static void print_sal_location(const symtab_and_line &sal)
static struct value * gdb_setting_str_internal_fn(struct gdbarch *gdbarch, const struct language_defn *language, void *cookie, int argc, struct value **argv)
static void disassemble_current_function(gdb_disassembly_flags flags)
struct cmd_list_element * showprintlist
static cmd_list_element * validate_aliased_command(const char *command)
static void print_disassembly(struct gdbarch *gdbarch, const char *name, CORE_ADDR low, CORE_ADDR high, const struct block *block, gdb_disassembly_flags flags)
static void echo_command(const char *text, int from_tty)
static void list_around_line(const char *arg, symtab_and_line cursal)
static void pwd_command(const char *args, int from_tty)
unsigned int max_user_call_depth
static const char script_ext_soft[]
static void show_configuration(const char *args, int from_tty)
static void show_script_ext_mode(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static struct value * gdb_maint_setting_str_internal_fn(struct gdbarch *gdbarch, const struct language_defn *language, void *cookie, int argc, struct value **argv)
static int run_under_shell(const char *arg, int from_tty)
struct cmd_list_element * infolist
struct cmd_list_element * deletelist
static void with_command(const char *args, int from_tty)
static struct value * shell_internal_fn(struct gdbarch *gdbarch, const struct language_defn *language, void *cookie, int argc, struct value **argv)
static bool has_user_subcmd(struct cmd_list_element *command)
struct cmd_list_element * showhistlist
struct cmd_list_element * maintenanceprintlist
static void alias_usage_error(void)
static void disassemble_command(const char *arg, int from_tty)
static void source_script_from_stream(FILE *stream, const char *file, const char *file_to_open)
struct cmd_list_element * setsourcelist
static void complete_command(const char *arg, int from_tty)
struct cmd_list_element * maintenancechecklist
static const gdb::option::option_def alias_option_defs[]
struct cmd_list_element * stoplist
static void make_command(const char *arg, int from_tty)
static void alias_command(const char *args, int from_tty)
static struct value * gdb_setting_internal_fn(struct gdbarch *gdbarch, const struct language_defn *language, void *cookie, int argc, struct value **argv)
void error_no_arg(const char *why)
struct cmd_list_element * setchecklist
struct cmd_list_element * cmdlist
void cd_command(const char *dir, int from_tty)
static const char *const script_ext_enums[]
static void source_command(const char *args, int from_tty)
struct cmd_list_element * setprintlist
static const char script_ext_off[]
static void show_info_verbose(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
struct cmd_list_element * setlist
static void pipe_command(const char *arg, int from_tty)
static void source_script_with_search(const char *file, int from_tty, int search_path)
struct cmd_list_element * showdebuglist
static struct value * str_value_from_setting(const setting &var, struct gdbarch *gdbarch)
static void shell_escape(const char *arg, int from_tty)
struct cmd_list_element * detachlist
static const char * script_ext_mode
static void show_user_completer(cmd_list_element *, completion_tracker &tracker, const char *text, const char *word)
struct cmd_list_element * disablelist
static void show_version(const char *args, int from_tty)
struct cmd_list_element * showchecklist
struct cmd_list_element * maintenanceflushlist
static void list_command(const char *arg, int from_tty)
static void set_suppress_cli_notifications(const char *args, int from_tty, cmd_list_element *c)
gdb::optional< open_script > find_and_open_script(const char *script_file, int search_path)
void source_script(const char *file, int from_tty)
static struct value * value_from_setting(const setting &var, struct gdbarch *gdbarch)
static int cmp_symtabs(const symtab_and_line &sala, const symtab_and_line &salb)
static void shell_command(const char *arg, int from_tty)
struct cmd_list_element * showsourcelist
static void show_max_user_call_depth(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static void show_user(const char *args, int from_tty)
static bool user_wants_cli_suppress_notification
static void exit_status_set_internal_vars(int exit_status)
static void with_command_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *)
static void show_history_expansion_p(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
struct cmd_list_element * maintenancelist
static void edit_command(const char *arg, int from_tty)
static void help_command(const char *command, int from_tty)
static struct value * gdb_maint_setting_internal_fn(struct gdbarch *gdbarch, const struct language_defn *language, void *cookie, int argc, struct value **argv)
static const char script_ext_strict[]
struct cmd_list_element * enablelist
int is_complete_command(struct cmd_list_element *c)
static void apropos_command(const char *arg, int from_tty)
void with_command_completer_1(const char *set_cmd_prefix, completion_tracker &tracker, const char *text)
struct cmd_list_element * unsethistlist
void with_command_1(const char *set_cmd_prefix, cmd_list_element *setlist, const char *args, int from_tty)
static gdb::option::option_def_group make_pipe_cmd_options_def_group(pipe_cmd_opts *opts)
static void ambiguous_line_spec(gdb::array_view< const symtab_and_line > sals, const char *format,...) ATTRIBUTE_PRINTF(2
static struct cmd_list_element * lookup_cmd_for_default_args(const char **text, struct cmd_list_element **prefix_cmd)
struct cmd_list_element * maintenanceinfolist
static void pipe_command_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word_ignored)
static void info_command(const char *arg, int from_tty)
static std::string argv_to_string(char **argv, int n)
struct cmd_list_element * killlist
static void show_suppress_cli_notifications(ui_file *file, int from_tty, cmd_list_element *c, const char *value)
struct cmd_list_element * setdebuglist
struct cmd_list_element * sethistlist
static const gdb::option::option_def pipe_cmd_option_defs[]
void quit_command(const char *args, int from_tty)
static void alias_command_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
static void static void filter_sals(std::vector< symtab_and_line > &)
void _initialize_cli_cmds()
struct cmd_list_element * unsetlist
static cmd_list_element * setting_cmd(const char *fnname, struct cmd_list_element *showlist, int argc, struct value **argv)
struct cmd_list_element * maintenance_show_cmdlist
struct cmd_list_element * add_alias_cmd(const char *name, cmd_list_element *target, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
struct cmd_list_element * lookup_cmd(const char **line, struct cmd_list_element *list, const char *cmdtype, std::string *default_args, int allow_unknown, int ignore_help_classes)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
void set_cmd_completer_handle_brkchars(struct cmd_list_element *cmd, completer_handle_brkchars_ftype *func)
void help_cmd(const char *command, struct ui_file *stream)
cmd_list_element * add_com_alias(const char *name, cmd_list_element *target, command_class theclass, int abbrev_flag)
struct cmd_list_element * lookup_cmd_1(const char **text, struct cmd_list_element *clist, struct cmd_list_element **result_list, std::string *default_args, int ignore_help_classes, bool lookup_for_completion_p)
void help_list(struct cmd_list_element *list, const char *cmdtype, enum command_class theclass, struct ui_file *stream)
void set_cmd_completer(struct cmd_list_element *cmd, completer_ftype *completer)
struct cmd_list_element * add_show_prefix_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list)
void apropos_cmd(struct ui_file *stream, struct cmd_list_element *commandlist, bool verbose, compiled_regex ®ex)
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc)
set_show_commands add_setshow_uinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const literal_def *extra_literals, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
set_show_commands add_setshow_enum_cmd(const char *name, enum command_class theclass, const char *const *enumlist, const char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
set_show_commands add_setshow_prefix_cmd(const char *name, command_class theclass, const char *set_doc, const char *show_doc, cmd_list_element **set_subcommands_list, cmd_list_element **show_subcommands_list, cmd_list_element **set_list, cmd_list_element **show_list)
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list)
bool valid_user_defined_cmd_name_p(const char *name)
set_show_commands add_setshow_boolean_cmd(const char *name, enum command_class theclass, bool *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
int cmd_simple_func_eq(struct cmd_list_element *cmd, cmd_simple_func_ftype *simple_func)
int lookup_cmd_composition(const char *text, struct cmd_list_element **alias, struct cmd_list_element **prefix_cmd, struct cmd_list_element **cmd)
int cli_user_command_p(struct cmd_list_element *cmd)
void show_user_1(struct cmd_list_element *c, const char *prefix, const char *name, struct ui_file *stream)
void script_from_file(FILE *stream, const char *file)
void do_set_command(const char *arg, int from_tty, struct cmd_list_element *c)
std::string get_setshow_command_value_string(const setting &var)
cli_style_option address_style
cli_style_option function_name_style
cli_style_option file_name_style
int check_for_argument(const char **str, const char *arg, int arg_len)
const char * repeat_previous()
void set_repeat_arguments(const char *args)
void command_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
const char * get_max_completions_reached_message(void)
void complete_nested_command_line(completion_tracker &tracker, const char *text)
completion_result complete(const char *line, char const **word, int *quote_char)
void location_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *)
void filename_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
@ DISASSEMBLY_SOURCE_DEPRECATED
void gdb_disassembly(struct gdbarch *gdbarch, struct ui_out *uiout, gdb_disassembly_flags flags, int how_many, CORE_ADDR low, CORE_ADDR high)
struct value * parse_and_eval(const char *exp, parser_flags flags)
struct value * parse_to_comma_and_eval(const char **expp)
CORE_ADDR parse_and_eval_address(const char *exp)
void exception_print(struct ui_file *file, const struct gdb_exception &e)
int ext_lang_present_p(const struct extension_language_defn *extlang)
script_sourcer_func * ext_lang_script_sourcer(const struct extension_language_defn *extlang)
void throw_ext_lang_unsupported(const struct extension_language_defn *extlang)
const struct extension_language_defn * get_ext_lang_of_file(const char *file)
void script_sourcer_func(const struct extension_language_defn *, FILE *stream, const char *filename)
CORE_ADDR get_frame_pc(frame_info_ptr frame)
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
frame_info_ptr get_selected_frame(const char *message)
CORE_ADDR get_frame_address_in_block(frame_info_ptr this_frame)
static void ATTRIBUTE_PRINTF(1, 0)
CORE_ADDR gdbarch_deprecated_function_start_offset(struct gdbarch *gdbarch)
void execute_command(const char *, int)
void execute_command_to_ui_file(struct ui_file *file, const char *p, int from_tty)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
struct type * check_typedef(struct type *type)
mach_port_t kern_return_t mach_port_t mach_msg_type_name_t msgportsPoly mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int status
const struct language_defn * current_language
static const char * range
std::vector< symtab_and_line > decode_line_1(const location_spec *locspec, int flags, struct program_space *search_pspace, struct symtab *default_symtab, int default_line)
location_spec_up string_to_location_spec(const char **stringp, const struct language_defn *language, symbol_name_match_type match_type)
std::unique_ptr< location_spec > location_spec_up
bool process_options(const char **args, process_options_mode mode, gdb::array_view< const option_def_group > options_group)
@ PROCESS_OPTIONS_UNKNOWN_IS_ERROR
@ PROCESS_OPTIONS_UNKNOWN_IS_OPERAND
std::string build_help(const char *help_tmpl, gdb::array_view< const option_def_group > options_group)
bool complete_options(completion_tracker &tracker, const char **args, process_options_mode mode, gdb::array_view< const option_def_group > options_group)
int have_partial_symbols(void)
int have_full_symbols(void)
void set_current_program_space(struct program_space *pspace)
int openp(const char *path, openp_flags opts, const char *string, int mode, gdb::unique_xmalloc_ptr< char > *filename_opened)
const char * symtab_to_fullname(struct symtab *s)
const char * symtab_to_filename_for_display(struct symtab *symtab)
struct symtab_and_line get_current_source_symtab_and_line(void)
void clear_current_source_symtab_and_line(void)
int get_first_line_listed(void)
void forget_cached_source_info(void)
int last_symtab_line(struct symtab *s)
void set_default_source_symtab_and_line(void)
void print_source_lines(struct symtab *s, int line, int stopline, print_source_lines_flags flags)
int get_lines_to_list(void)
bool is_contiguous() const
gdb::array_view< blockrange > ranges()
struct type * builtin_int
bool user_selected_context
std::vector< std::string > command_components() const
struct cmd_list_element ** subcommands
completer_ftype * completer
struct cmd_list_element * prefix
__extension__ enum cmd_types type
struct cmd_list_element * next
struct objfile * objfile() const
const char * dirname() const
const char * print_name() const
const char * linkage_name() const
virtual struct value * value_string(struct gdbarch *gdbarch, const char *ptr, ssize_t len) const
struct gdbarch * arch() const
const literal_def * extra_literals() const
setting_func_types< T >::type get() const
struct program_space * pspace
struct compunit_symtab * compunit() const
static struct value * allocate_optimized_out(struct type *type)
static struct value * allocate(struct type *type)
struct type * type() const
struct symtab_and_line find_pc_line(CORE_ADDR pc, int notcurrent)
void print_gdb_version(struct ui_file *stream, bool interactive)
void quit_force(int *exit_arg, int from_tty)
void print_gdb_configuration(struct ui_file *stream)
void show_commands(const char *args, int from_tty)
void set_verbose(const char *args, int from_tty, struct cmd_list_element *c)
void query_if_trace_running(int from_tty)
CORE_ADDR tui_get_low_disassembly_address(struct gdbarch *gdbarch, CORE_ADDR low, CORE_ADDR pc)
void tui_show_assembly(struct gdbarch *gdbarch, CORE_ADDR addr)
bool tui_is_window_visible(enum tui_win_type type)
static styled_string_s * styled_string(const ui_file_style &style, const char *str, styled_string_s &&tmp={})
void gdb_vprintf(struct ui_file *stream, const char *format, va_list args)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
void perror_warning_with_name(const char *string)
int parse_escape(struct gdbarch *gdbarch, const char **string_ptr)
void gdb_printf(struct ui_file *stream, const char *format,...)
void gdb_flush(struct ui_file *stream)
void printf_unfiltered(const char *format,...)
void value_print(struct value *val, struct ui_file *stream, const struct value_print_options *options)
void get_no_prettyformat_print_options(struct value_print_options *opts)
void clear_internalvar(struct internalvar *var)
CORE_ADDR value_as_address(struct value *val)
struct value * value_from_ulongest(struct type *type, ULONGEST num)
struct value * value_from_longest(struct type *type, LONGEST num)
void add_internal_function(const char *name, const char *doc, internal_function_fn handler, void *cookie)
struct internalvar * lookup_internalvar(const char *name)
LONGEST value_as_long(struct value *val)
void set_internalvar_integer(struct internalvar *var, LONGEST l)