22#include "readline/tilde.h"
25#include "gdbsupport/gdb_wait.h"
27#include "gdbsupport/gdb_regex.h"
39#include "gdbsupport/filestuff.h"
56#include "gdbsupport/pathstuff.h"
57#include "gdbsupport/gdb_tilde_expand.h"
72 const char *format, ...)
206 error (_(
"Argument required (%s)."), why);
227 error (_(
"Missing arguments."));
229 const char *delim = strstr (args,
"--");
230 const char *nested_cmd =
nullptr;
233 error (_(
"Missing setting before '--' delimiter"));
235 if (delim ==
nullptr || *skip_spaces (&delim[2]) ==
'\0')
242 gdb_assert (
set_cmd !=
nullptr);
244 if (!
set_cmd->var.has_value ())
245 error (_(
"Cannot use this setting with the \"with\" command"));
247 std::string temp_value
248 = (delim ==
nullptr ? args : std::string (args, delim - args));
250 if (nested_cmd ==
nullptr)
251 nested_cmd = skip_spaces (delim + 2);
253 gdb_assert (
set_cmd->var.has_value ());
261 scoped_restore save_async = make_scoped_restore (&
current_ui->
async, 0);
266 catch (
const gdb_exception &ex)
275 catch (
const gdb_exception &ex2)
277 warning (_(
"Couldn't restore setting: %s"), ex2.what ());
296 const char *delim = strstr (text,
"--");
302 || !isspace (delim[-1])
303 || !(isspace (delim[2]) || delim[2] ==
'\0'))
305 std::string new_text = std::string (set_cmd_prefix) + text;
312 const char *nested_cmd = skip_spaces (delim + 2);
330 const char *text,
const char * )
345 const char *orig_text = *text;
348 if (*text ==
nullptr || skip_spaces (*text) ==
nullptr)
349 error (_(
"ALIAS missing."));
373 (std::string (orig_text, *text - orig_text).c_str (),
374 &
alias, prefix_cmd, &cmd);
375 gdb_assert (cmd !=
nullptr);
376 gdb_assert (cmd == lcmd);
377 if (
alias !=
nullptr)
408 " completion is disabled.\n"));
416 int quote_char =
'\0';
423 std::string arg_prefix (arg, word - arg);
447 arg_prefix.c_str (), word,
489 error (_(
"Not confirmed."));
495 catch (
const gdb_exception_error &ex)
497 if (ex.error == TARGET_CLOSE_ERROR)
506 quit_force (args ? &exit_code : NULL, from_tty);
513 error (_(
"The \"pwd\" command does not take an argument: %s"), args);
515 gdb::unique_xmalloc_ptr<char> cwd (getcwd (NULL, 0));
518 error (_(
"Error finding name of working directory: %s"),
519 safe_strerror (errno));
521 if (strcmp (cwd.get (), current_directory) != 0)
522 gdb_printf (_(
"Working directory %ps\n (canonically %ps).\n"),
544 gdb::unique_xmalloc_ptr<char> dir_holder
545 (tilde_expand (dir != NULL ? dir :
"~"));
546 dir = dir_holder.get ();
551#ifdef HAVE_DOS_BASED_FILE_SYSTEM
555 gdb::unique_xmalloc_ptr<char> cwd (getcwd (NULL, 0));
560 if (IS_DIR_SEPARATOR (dir[len - 1]))
565#ifdef HAVE_DOS_BASED_FILE_SYSTEM
566 && !(len == 3 && dir[1] ==
':')
572 dir_holder.reset (savestring (dir, len));
573 if (IS_ABSOLUTE_PATH (dir_holder.get ()))
575 xfree (current_directory);
576 current_directory = dir_holder.release ();
580 if (IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1]))
581 current_directory = concat (current_directory, dir_holder.get (),
584 current_directory = concat (current_directory, SLASH_STRING,
585 dir_holder.get (), (
char *) NULL);
591 for (p = current_directory; *p;)
593 if (IS_DIR_SEPARATOR (p[0]) && p[1] ==
'.'
594 && (p[2] == 0 || IS_DIR_SEPARATOR (p[2])))
595 memmove (p, p + 2, strlen (p + 2) + 1);
596 else if (IS_DIR_SEPARATOR (p[0]) && p[1] ==
'.' && p[2] ==
'.'
597 && (p[3] == 0 || IS_DIR_SEPARATOR (p[3])))
605 while (q != current_directory && !IS_DIR_SEPARATOR (q[-1]))
608 if (q == current_directory)
614 memmove (q - 1, p + 3, strlen (p + 3) + 1);
643 _(
"Script filename extension recognition is \"%s\".\n"),
656gdb::optional<open_script>
661 gdb::optional<open_script> opened;
663 gdb::unique_xmalloc_ptr<char> file (tilde_expand (script_file));
670 gdb::unique_xmalloc_ptr<char> full_path;
672 file.get (), O_RDONLY, &full_path);
677 FILE *result = fdopen (fd, FOPEN_RT);
680 int save_errno = errno;
686 opened.emplace (gdb_file_up (result), std::move (full_path));
700 const char *file_to_open)
714 gdb_assert (sourcer != NULL);
715 sourcer (extlang, stream, file_to_open);
740 if (file == NULL || *file == 0)
741 error (_(
"source command requires file name of file to source."));
764 const char *file_to_open;
765 std::string tilde_expanded_file;
767 file_to_open = opened->full_path.get ();
770 tilde_expanded_file = gdb_tilde_expand (file);
771 file_to_open = tilde_expanded_file.c_str ();
788 const char *file = args;
791 scoped_restore save_source_verbose = make_scoped_restore (&
source_verbose);
801 while (args[0] !=
'\0')
805 args = skip_spaces (args);
810 if (args[1] ==
'v' && isspace (args[2]))
817 else if (args[1] ==
's' && isspace (args[2]))
828 file = skip_spaces (args);
838 const char *p = text;
842 while ((c = *p++) !=
'\0')
876 if (WIFEXITED (exit_status))
879 else if (WIFSIGNALED (exit_status) && WTERMSIG (exit_status) == -1)
890 else if (WIFSIGNALED (exit_status))
893 warning (_(
"unexpected shell command exit status %d"), exit_status);
899#if defined(CANT_FORK) || \
900 (!defined(HAVE_WORKING_VFORK) && !defined(HAVE_WORKING_FORK))
903 int rc = system (arg ? arg :
"");
906 arg =
"inferior shell";
910 safe_strerror (errno));
916 chdir (current_directory);
922 if ((
pid = vfork ()) == 0)
924 const char *p, *user_shell = get_shell ();
929 p = lbasename (user_shell);
932 execl (user_shell, p, (
char *) 0);
934 execl (user_shell, p,
"-c", arg, (
char *) 0);
937 safe_strerror (errno));
944 error (_(
"Fork failed"));
977 error (_(
"No default source file yet."));
990 error (_(
"Junk at end of line specification."));
992 std::vector<symtab_and_line> sals =
decode_line_1 (locspec.get (),
1002 if (sals.size () > 1)
1005 _(
"Specified line is ambiguous:\n"));
1020 error (_(
"No source file for address %s."),
1042 error (_(
"No line number known for %s."), arg);
1045 if ((editor = getenv (
"EDITOR")) == NULL)
1052 gdb::unique_xmalloc_ptr<char> p
1053 = xstrprintf (
"%s +%d \"%s\"", editor, sal.
line, fn);
1071 N_(
"Indicates to use the specified delimiter string to separate\n\
1072COMMAND from SHELL_COMMAND, in alternative to |. This is useful in\n\
1073case COMMAND contains a | character."),
1098 const char *delim =
"|";
1099 if (!opts.delimiter.empty ())
1100 delim = opts.delimiter.c_str ();
1102 const char *command = arg;
1103 if (command ==
nullptr)
1104 error (_(
"Missing COMMAND"));
1106 arg = strstr (arg, delim);
1109 error (_(
"Missing delimiter before SHELL_COMMAND"));
1111 std::string gdb_cmd (command, arg - command);
1113 arg += strlen (delim);
1115 if (gdb_cmd.empty ())
1120 error (_(
"Missing SHELL_COMMAND"));
1124 if (to_shell_command ==
nullptr)
1135 pclose (to_shell_command);
1139 int exit_status = pclose (to_shell_command);
1141 if (exit_status < 0)
1143 safe_strerror (errno));
1152 const char *text,
const char *word_ignored)
1156 const char *org_text = text;
1162 const char *delimiter =
"|";
1163 if (!opts.delimiter.empty ())
1164 delimiter = opts.delimiter.c_str ();
1167 if (text > org_text && !isspace (text[-1]))
1170 const char *delim = strstr (text, delimiter);
1174 if (delim ==
nullptr || delim == text)
1192 int linenum_beg = 0;
1196 if (arg == NULL || ((arg[0] ==
'+' || arg[0] ==
'-') && arg[1] ==
'\0'))
1213 if (arg != NULL && arg[0] ==
'-'
1221 else if (arg == NULL || arg[0] ==
'+')
1227 else if (arg[0] ==
'-')
1230 error (_(
"Already at the start of %s."),
1247 error (_(
"No symbol table is loaded. Use the \"file\" command."));
1249 std::vector<symtab_and_line> sals;
1266 error (_(
"Junk at end of line specification."));
1282 for (p = arg; p != arg1 && *p >=
'0' && *p <=
'9'; p++);
1283 linenum_beg = (p == arg1);
1287 const char *beg = arg;
1288 size_t beg_len = arg1 - beg;
1290 while (*arg1 ==
' ' || *arg1 ==
'\t')
1295 if (sals.size () > 1)
1298 _(
"Specified first line '%.*s' is ambiguous:\n"),
1299 (
int) beg_len, beg);
1303 while (*arg1 ==
' ' || *arg1 ==
'\t')
1311 const char *end_arg = arg1;
1317 error (_(
"Junk at end of line specification."));
1319 std::vector<symtab_and_line> sals_end
1327 if (sals_end.empty ())
1329 if (sals_end.size () > 1)
1332 _(
"Specified last line '%s' is ambiguous:\n"),
1336 sal_end = sals_end[0];
1341 error (_(
"Junk at end of line specification."));
1343 if (!no_end && !dummy_beg && !dummy_end
1345 error (_(
"Specified first and last lines are in different files."));
1346 if (dummy_beg && dummy_end)
1347 error (_(
"Two empty args do not say what lines to list."));
1359 error (_(
"No source file for address %s."),
1379 if (!linenum_beg && sal.
symtab == 0)
1380 error (_(
"No line number known for %s."), arg);
1388 if (dummy_beg && sal_end.
symtab == 0)
1389 error (_(
"No default source file yet. Do \"help list\"."));
1396 else if (sal.
symtab == 0)
1397 error (_(
"No default source file yet. Do \"help list\"."));
1400 for (
int i = 0; i < sals.size (); i++)
1406 if (sals.size () > 1)
1430 CORE_ADDR low, CORE_ADDR high,
1432 gdb_disassembly_flags
flags)
1460 CORE_ADDR range_low =
range.start ();
1461 CORE_ADDR range_high =
range.end ();
1463 gdb_printf (_(
"Address range %ps to %ps:\n"),
1469 range_low, range_high);
1484 CORE_ADDR low, high, pc;
1492 error (_(
"No function contains program counter for selected frame."));
1536 CORE_ADDR low, high;
1540 gdb_disassembly_flags
flags;
1553 error (_(
"Missing modifier."));
1555 while (*p && ! isspace (*p))
1572 error (_(
"Invalid disassembly modifier."));
1576 p = skip_spaces (p);
1581 error (_(
"Cannot specify both /m and /s."));
1597 error (_(
"No function contains specified address."));
1619 p = skip_spaces (p);
1640 std::string cmd = std::string (
"make ") + arg;
1653 const char *comname = args;
1657 error (_(
"Not a user command."));
1686 subcommand !=
nullptr;
1687 subcommand = subcommand->
next)
1708 const char *curr_cmd = text;
1709 const char *after = skip_to_space (text);
1710 const size_t curr_cmd_len = after - text;
1711 text = skip_spaces (after);
1715 if (strlen (c->name) == curr_cmd_len
1716 && strncmp (c->name, curr_cmd, curr_cmd_len) == 0)
1718 if (c->subcommands ==
nullptr)
1729 const int wordlen = strlen (word);
1733 if (strncmp (c->name, word, wordlen) == 0)
1735 (gdb::unique_xmalloc_ptr<char> (xstrdup (c->name)));
1747 if (arg == NULL || *arg ==
'\0')
1748 error (_(
"REGEXP string is empty"));
1750 compiled_regex pattern (arg, REG_ICASE,
1751 _(
"Error in regular expression"));
1768 [] (
alias_opts *opts) {
return &opts->abbrev_flag; },
1769 N_(
"Specify that ALIAS is an abbreviation of COMMAND.\n\
1770Abbreviations are not used in command completion."),
1789 const char *text,
const char *word)
1799 const char *delim = strchr (text,
'=');
1806 && isspace (delim[-1])
1807 && (isspace (delim[1]) || delim[1] ==
'\0'))
1809 std::string new_text = std::string (delim + 1);
1834 gdb_assert (argv != NULL);
1835 gdb_assert (n >= 0 && n <= countargv (argv));
1837 for (i = 0; i < n; ++i)
1861 std::string default_args;
1866 error (_(
"Invalid command to alias to: %s"), command);
1868 if (!default_args.empty ())
1869 error (_(
"Cannot define an alias of an alias that has default args"));
1879 error (_(
"Usage: alias [-a] [--] ALIAS = COMMAND [DEFAULT-ARGS...]"));
1893 int i, alias_argc, command_argc;
1895 const char *
alias, *command;
1897 if (args == NULL || strchr (args,
'=') == NULL)
1900 equals = strchr (args,
'=');
1901 std::string args2 (args, equals - args);
1903 gdb_argv built_alias_argv (args2.c_str ());
1905 const char *default_args = equals + 1;
1909 std::string command_argv_str (equals + 1,
1911 ? strlen (equals + 1)
1913 gdb_argv command_argv (command_argv_str.c_str ());
1915 char **alias_argv = built_alias_argv.get ();
1917 if (alias_argv[0] == NULL || command_argv[0] == NULL
1918 || *alias_argv[0] ==
'\0' || *command_argv[0] ==
'\0')
1921 for (i = 0; alias_argv[i] != NULL; ++i)
1926 error (_(
"Invalid command name: %s"), alias_argv[i]);
1928 error (_(
"Invalid command element name: %s"), alias_argv[i]);
1932 alias_argc = countargv (alias_argv);
1933 command_argc = command_argv.count ();
1940 command = command_string.c_str ();
1944 std::string alias_string (
argv_to_string (alias_argv, alias_argc));
1945 alias = alias_string.c_str ();
1951 const char *alias_name = alias_argv[alias_argc-1];
1956 if (alias_cmd !=
nullptr
1957 && alias_cmd->
prefix == prefix_cmd
1958 && strcmp (alias_name, alias_cmd->
name) == 0)
1959 error (_(
"Alias already exists: %s"),
alias);
1963 if (cmd->
prefix == prefix_cmd
1964 && strcmp (alias_name, cmd->
name) == 0)
1965 error (_(
"Alias %s is the name of an existing command"),
alias);
1981 if (alias_argc == 1)
1984 alias_cmd =
add_com_alias (xstrdup (alias_argv[0]), target_cmd,
1989 const char *alias_prefix, *command_prefix;
1992 if (alias_argc != command_argc)
1993 error (_(
"Mismatched command length between ALIAS and COMMAND."));
2000 std::string command_prefix_string (
argv_to_string (command_argv.get (),
2002 alias_prefix = alias_prefix_string.c_str ();
2003 command_prefix = command_prefix_string.c_str ();
2007 gdb_assert (c_command != NULL
2011 if (c_alias != c_command)
2012 error (_(
"ALIAS and COMMAND prefixes do not match."));
2015 alias_cmd =
add_alias_cmd (xstrdup (alias_argv[alias_argc - 1]),
2020 gdb_assert (alias_cmd !=
nullptr);
2039 const char *sym_name = NULL;
2042 gdb_printf (_(
"file: \"%s\", line number: %d, symbol: \"%s\"\n"),
2044 sal.
line, sym_name != NULL ? sym_name :
"???");
2056 const char *format, ...)
2059 va_start (ap, format);
2063 for (
const auto &sal : sals)
2082 else if (dirb == NULL)
2089 r = filename_cmp (dira, dirb);
2100 return sala.
line == salb.
line ? 0 : 1;
2110 auto from = std::remove_if (sals.begin (), sals.end (),
2112 { return (sal.pspace != current_program_space || sal.symtab == NULL); });
2115 std::sort (sals.begin (), from,
2117 { return cmp_symtabs (sala, salb) < 0; });
2119 from = std::unique (sals.begin (), from,
2122 { return cmp_symtabs (sala, salb) == 0; });
2124 sals.erase (from, sals.end ());
2134 _(
"Verbose printing of informational messages is %s.\n"),
2144 gdb_printf (file, _(
"History expansion on command input is %s.\n"),
2153 _(
"The max call depth for user-defined commands is %s.\n"),
2163 gdb_printf (file, _(
"Suppression of printing CLI notifications "
2164 "is %s.\n"),
value);
2186 int argc,
struct value **argv)
2189 error (_(
"You must provide an argument to %s"), fnname);
2191 error (_(
"You can only provide one argument to %s"), fnname);
2195 if (type0->
code () != TYPE_CODE_ARRAY
2196 && type0->
code () != TYPE_CODE_STRING)
2197 error (_(
"First argument of %s must be a string."), fnname);
2199 const char *a0 = (
const char *)
value_contents (argv[0]).data ();
2203 error (_(
"First argument of %s must be a "
2204 "valid setting of the 'show' command."), fnname);
2211static struct value *
2214 switch (var.
type ())
2228 var.
get<
bool> () ? 1 : 0);
2248 gdb_assert_not_reached (
"invalid var_auto_boolean");
2260 var.
get<
unsigned int> ());
2263 var.
get<
unsigned int> ());
2275 len = strlen (
value);
2279 const std::string &st = var.
get<std::string> ();
2280 value = st.c_str ();
2292 gdb_assert_not_reached (
"bad var_type");
2298static struct value *
2301 void *cookie,
int argc,
struct value **argv)
2306 gdb_assert (
show_cmd->var.has_value ());
2313static struct value *
2316 void *cookie,
int argc,
struct value **argv)
2321 gdb_assert (
show_cmd->var.has_value ());
2328static struct value *
2331 switch (var.
type ())
2362 len = strlen (
value);
2366 const std::string &st = var.
get<std::string> ();
2367 value = st.c_str ();
2379 gdb_assert_not_reached (
"bad var_type");
2385static struct value *
2388 void *cookie,
int argc,
struct value **argv)
2393 gdb_assert (
show_cmd->var.has_value ());
2401static struct value *
2404 void *cookie,
int argc,
struct value **argv)
2410 gdb_assert (
show_cmd->var.has_value ());
2425Maintenance commands.\n\
2426Some gdb commands are provided just for use by gdb maintainers.\n\
2427These commands are subject to frequent change, and may not be as\n\
2428well documented as user commands."),
2432 _(
"User-defined aliases of other commands."), &
cmdlist);
2434User-defined commands.\n\
2435The commands in this class are those defined by the user.\n\
2436Use the \"define\" command to define a command."), &
cmdlist);
2442 _(
"Making program stop at certain points."), &
cmdlist);
2445Examining the stack.\n\
2446The stack is made up of stack frames. Gdb assigns numbers to stack frames\n\
2447counting from zero for the innermost (currently executing) frame.\n\n\
2448At any time gdb identifies one frame as the \"selected\" frame.\n\
2449Variable lookups are done with respect to the selected frame.\n\
2450When the program being debugged stops, gdb selects the innermost frame.\n\
2451The commands below can be used to select other frames by number or address."),
2455 _(
"TUI is the GDB text based interface.\n\
2456In TUI mode, GDB can display several text windows showing\n\
2457the source file, the processor registers, the program disassembly, ..."), &
cmdlist);
2464Print working directory.\n\
2465This is used for your program as well."));
2468Set working directory to DIR for debugger.\n\
2469The debugger's current working directory specifies where scripts and other\n\
2470files that can be loaded by GDB are located.\n\
2471In order to change the inferior's current working directory, the recommended\n\
2472way is to use the \"set cwd\" command."), &
cmdlist);
2476Print a constant string. Give string as argument.\n\
2477C escape sequences may be used in the argument.\n\
2478No newline is added at the end of the argument;\n\
2479use \"\\n\" if you want a newline to be printed.\n\
2480Since leading and trailing whitespace are ignored in command arguments,\n\
2481if you want to print some you must use \"\\\" before leading whitespace\n\
2482to be printed or after trailing whitespace."));
2486Set mode for script filename extension recognition."), _(
"\
2487Show mode for script filename extension recognition."), _(
"\
2488off == no filename extension recognition (all sourced files are GDB scripts)\n\
2489soft == evaluate script according to filename extension, fallback to GDB script"
2491strict == evaluate script according to filename extension, error if not supported"
2500Usage: quit [EXPR] or exit [EXPR]\n\
2501The optional expression EXPR, if present, is evaluated and the result\n\
2502used as GDB's exit code. The default is zero."));
2505 _(
"Print list of commands."));
2512Set verbosity."), _(
"\
2513Show verbosity."), NULL,
2520 _(
"Generic command for setting command history parameters."),
2521 _(
"Generic command for showing command history parameters."),
2525Set history expansion on command input."), _(
"\
2526Show history expansion on command input."), _(
"\
2527Without an argument, history expansion is enabled."),
2534Generic command for showing things about the program being debugged."),
2540 _(
"List the completions for the rest of the line as a command."));
2543Generic command for showing things about the debugger."),
2550Temporarily set SETTING to VALUE, run COMMAND, and restore SETTING.\n\
2551Usage: with SETTING [VALUE] [-- COMMAND]\n\
2552Usage: w SETTING [VALUE] [-- COMMAND]\n\
2553With no COMMAND, repeats the last executed command.\n\
2555SETTING is any setting you can change with the \"set\" subcommands.\n\
2557 with language pascal -- print obj\n\
2558 with print elements unlimited -- print obj\n\
2560You can change multiple settings using nested with, and use\n\
2561abbreviations for commands and/or values. E.g.:\n\
2562 w la p -- w p el u -- p obj"));
2567$_gdb_setting_str - returns the value of a GDB setting as a string.\n\
2568Usage: $_gdb_setting_str (setting)\n\
2570auto-boolean values are \"off\", \"on\", \"auto\".\n\
2571boolean values are \"off\", \"on\".\n\
2572Some integer settings accept an unlimited value, returned\n\
2577$_gdb_setting - returns the value of a GDB setting.\n\
2578Usage: $_gdb_setting (setting)\n\
2579auto-boolean values are \"off\", \"on\", \"auto\".\n\
2580boolean values are \"off\", \"on\".\n\
2581Some integer settings accept an unlimited value, returned\n\
2582as 0 or -1 depending on the setting."),
2586$_gdb_maint_setting_str - returns the value of a GDB maintenance setting as a string.\n\
2587Usage: $_gdb_maint_setting_str (setting)\n\
2589auto-boolean values are \"off\", \"on\", \"auto\".\n\
2590boolean values are \"off\", \"on\".\n\
2591Some integer settings accept an unlimited value, returned\n\
2596$_gdb_maint_setting - returns the value of a GDB maintenance setting.\n\
2597Usage: $_gdb_maint_setting (setting)\n\
2598auto-boolean values are \"off\", \"on\", \"auto\".\n\
2599boolean values are \"off\", \"on\".\n\
2600Some integer settings accept an unlimited value, returned\n\
2601as 0 or -1 depending on the setting."),
2605Show the history of commands you typed.\n\
2606You can supply a command number to start with, or a `+' to start after\n\
2607the previous command number shown."),
2611 _(
"Show what version of GDB this is."), &
showlist);
2614 _(
"Show how GDB was configured at build time."), &
showlist);
2617 _(
"Generic command for setting gdb debugging flags."),
2618 _(
"Generic command for showing gdb debugging flags."),
2624Execute the rest of the line as a shell command.\n\
2625With no arguments, run an inferior shell."));
2631Edit specified file or function.\n\
2632With no argument, edits file containing most recent line listed.\n\
2633Editing targets can be specified in these ways:\n\
2634 FILE:LINENUM, to edit at that line in that file,\n\
2635 FUNCTION, to edit at the beginning of that function,\n\
2636 FILE:FUNCTION, to distinguish among like-named static functions.\n\
2637 *ADDRESS, to edit at the line containing that address.\n\
2638Uses EDITOR environment variable contents as editor (or ex as default)."));
2644Send the output of a gdb command to a shell command.\n\
2645Usage: | [COMMAND] | SHELL_COMMAND\n\
2646Usage: | -d DELIM COMMAND DELIM SHELL_COMMAND\n\
2647Usage: pipe [COMMAND] | SHELL_COMMAND\n\
2648Usage: pipe -d DELIM COMMAND DELIM SHELL_COMMAND\n\
2650Executes COMMAND and sends its output to SHELL_COMMAND.\n\
2652The -d option indicates to use the string DELIM to separate COMMAND\n\
2653from SHELL_COMMAND, in alternative to |. This is useful in\n\
2654case COMMAND contains a | character.\n\
2656With no COMMAND, repeat the last executed command\n\
2657and send its output to SHELL_COMMAND."));
2663List specified function or line.\n\
2664With no argument, lists ten more lines after or around previous listing.\n\
2665\"list -\" lists the ten lines before a previous ten-line listing.\n\
2666One argument specifies a line, and ten lines are listed around that line.\n\
2667Two arguments with comma between specify starting and ending lines to list.\n\
2668Lines can be specified in these ways:\n\
2669 LINENUM, to list around that line in current file,\n\
2670 FILE:LINENUM, to list around that line in that file,\n\
2671 FUNCTION, to list around beginning of that function,\n\
2672 FILE:FUNCTION, to distinguish among like-named static functions.\n\
2673 *ADDRESS, to list around the line containing that address.\n\
2674With two args, if one is empty, it stands for ten lines away from\n\
2677By default, when a single location is given, display ten lines.\n\
2678This can be changed using \"set listsize\", and the current value\n\
2679can be shown using \"show listsize\"."));
2684Disassemble a specified section of memory.\n\
2685Usage: disassemble[/m|/r|/s] START [, END]\n\
2686Default is the function surrounding the pc of the selected frame.\n\
2688With a /s modifier, source lines are included (if available).\n\
2689In this mode, the output is displayed in PC address order, and\n\
2690file names and contents for all relevant source files are displayed.\n\
2692With a /m modifier, source lines are included (if available).\n\
2693This view is \"source centric\": the output is in source line order,\n\
2694regardless of any optimization that is present. Only the main source file\n\
2695is displayed, not those of, e.g., any inlined functions.\n\
2696This modifier hasn't proved useful in practice and is deprecated\n\
2699With a /r modifier, raw instructions in hex are included.\n\
2701With a single argument, the function surrounding that address is dumped.\n\
2702Two arguments (separated by a comma) are taken as a range of memory to dump,\n\
2703 in the form of \"start,end\", or \"start,+length\".\n\
2705Note that the address is interpreted as an expression, not as a location\n\
2706like in the \"break\" command.\n\
2707So, for example, if you want to disassemble function bar in file foo.c\n\
2708you must type \"disassemble 'foo.c'::bar\" and not \"disassemble foo.c:bar\"."));
2712Run the ``make'' program using the rest of the line as arguments."));
2715Show definitions of non-python/scheme user defined commands.\n\
2716Argument is the name of the user defined command.\n\
2717With no argument, show definitions of all user defined commands."), &
showlist);
2720Search for commands matching a REGEXP.\n\
2721Usage: apropos [-v] REGEXP\n\
2722Flag -v indicates to produce a verbose output, showing full documentation\n\
2723of the matching commands."));
2727Set the max call depth for non-python/scheme user-defined commands."), _(
"\
2728Show the max call depth for non-python/scheme user-defined commands."), NULL,
2734Set tracing of GDB CLI commands."), _(
"\
2735Show state of GDB CLI command tracing."), _(
"\
2736When 'on', each command is displayed as it is executed."),
2743 static std::string alias_help
2745Define a new command that is an alias of an existing command.\n\
2746Usage: alias [-a] [--] ALIAS = COMMAND [DEFAULT-ARGS...]\n\
2747ALIAS is the name of the alias command to create.\n\
2748COMMAND is the command being aliased to.\n\
2753GDB will automatically prepend the provided DEFAULT-ARGS to the list\n\
2754of arguments explicitly provided when using ALIAS.\n\
2755Use \"help aliases\" to list all user defined aliases and their default args.\n\
2758Make \"spe\" an alias of \"set print elements\":\n\
2759 alias spe = set print elements\n\
2760Make \"elms\" an alias of \"elements\" in the \"set print\" command:\n\
2761 alias -a set print elms = set print elements\n\
2762Make \"btf\" an alias of \"backtrace -full -past-entry -past-main\" :\n\
2763 alias btf = backtrace -full -past-entry -past-main\n\
2764Make \"wLapPeu\" an alias of 2 nested \"with\":\n\
2765 alias wLapPeu = with language pascal -- with print elements unlimited --"),
2769 alias_help.c_str ());
2776Set whether printing notifications on CLI is suppressed."), _(
"\
2777Show whether printing notifications on CLI is suppressed."), _(
"\
2778When on, printing notifications (such as inferior/thread switch)\n\
2779on CLI is suppressed."),
2785 const char *source_help_text = xstrprintf (_(
"\
2786Read commands from a file named FILE.\n\
2788Usage: source [-s] [-v] FILE\n\
2789-s: search for the script in the source search path,\n\
2790 even if FILE contains directories.\n\
2791-v: each command in FILE is echoed as it is executed.\n\
2793Note that the file \"%s\" is read automatically in this way\n\
2794when 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 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)
struct cmd_list_element * infolist
struct cmd_list_element * deletelist
static void with_command(const char *args, int from_tty)
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
set_show_commands add_setshow_uinteger_cmd(const char *name, enum command_class theclass, unsigned int *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)
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)
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc)
void apropos_cmd(struct ui_file *stream, struct cmd_list_element *commandlist, bool verbose, compiled_regex ®ex, const char *prefix)
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()
@ var_zuinteger_unlimited
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_to_comma_and_eval(const char **expp)
CORE_ADDR parse_and_eval_address(const char *exp)
struct value * parse_and_eval(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)
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)
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
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)
int get_first_line_listed(void)
void forget_cached_source_info(void)
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()
bool user_selected_context
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
struct gdbarch * arch() const
setting_func_types< T >::type get() const
struct program_space * pspace
struct compunit_symtab * compunit() const
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 perror_with_name(const char *string)
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,...)
struct value * value_cstring(const char *ptr, ssize_t len, struct type *char_type)
struct type * value_type(const struct value *value)
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)
gdb::array_view< const gdb_byte > value_contents(struct value *value)
struct internalvar * lookup_internalvar(const char *name)
LONGEST value_as_long(struct value *val)
void set_internalvar_integer(struct internalvar *var, LONGEST l)