along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
-#include "exceptions.h"
#include "arch-utils.h"
#include "dyn-string.h"
#include "readline/readline.h"
#include "target.h" /* For baud_rate, remote_debug and remote_timeout. */
#include "gdb_wait.h" /* For shell escape implementation. */
#include "gdb_regex.h" /* Used by apropos_command. */
-#include <string.h>
#include "gdb_vfork.h"
#include "linespec.h"
#include "expression.h"
#include "cli/cli-cmds.h"
#include "cli/cli-utils.h"
-#include "python/python.h"
+#include "extension.h"
#ifdef TUI
#include "tui/tui.h" /* For tui_active et.al. */
none is supplied. */
void
-error_no_arg (char *why)
+error_no_arg (const char *why)
{
error (_("Argument required (%s)."), why);
}
{
printf_unfiltered (_("\"info\" must be followed by "
"the name of an info command.\n"));
- help_list (infolist, "info ", -1, gdb_stdout);
+ help_list (infolist, "info ", all_commands, gdb_stdout);
}
/* The "show" command with no arguments shows all the settings. */
static void
source_script_from_stream (FILE *stream, const char *file)
{
- if (script_ext_mode != script_ext_off
- && strlen (file) > 3 && !strcmp (&file[strlen (file) - 3], ".py"))
+ if (script_ext_mode != script_ext_off)
{
- if (have_python ())
- source_python_script (stream, file);
- else if (script_ext_mode == script_ext_soft)
+ const struct extension_language_defn *extlang
+ = get_ext_lang_of_file (file);
+
+ if (extlang != NULL)
{
- /* Fallback to GDB script mode. */
- script_from_file (stream, file);
+ if (ext_lang_present_p (extlang))
+ {
+ script_sourcer_func *sourcer
+ = ext_lang_script_sourcer (extlang);
+
+ gdb_assert (sourcer != NULL);
+ sourcer (extlang, stream, file);
+ return;
+ }
+ else if (script_ext_mode == script_ext_soft)
+ {
+ /* Assume the file is a gdb script.
+ This is handled below. */
+ }
+ else
+ throw_ext_lang_unsupported (extlang);
}
- else
- error (_("Python scripting is not supported in this copy of GDB."));
}
- else
- script_from_file (stream, file);
+
+ script_from_file (stream, file);
}
/* Worker to perform the "source" command.
error (_("No source file for address %s."),
paddress (get_current_arch (), sal.pc));
- gdbarch = get_objfile_arch (sal.symtab->objfile);
+ gdbarch = get_objfile_arch (SYMTAB_OBJFILE (sal.symtab));
sym = find_pc_function (sal.pc);
if (sym)
printf_filtered ("%s is in %s (%s:%d).\n",
{
set_default_source_symtab_and_line ();
cursal = get_current_source_symtab_and_line ();
+
+ /* If this is the first "list" since we've set the current
+ source line, center the listing around that line. */
+ if (get_first_line_listed () == 0)
+ {
+ int first;
+
+ first = max (cursal.line - get_lines_to_list () / 2, 1);
+
+ /* A small special case --- if listing backwards, and we
+ should list only one line, list the preceding line,
+ instead of the exact line we've just shown after e.g.,
+ stopping for a breakpoint. */
+ if (arg != NULL && arg[0] == '-'
+ && get_lines_to_list () == 1 && first > 1)
+ first -= 1;
+
+ print_source_lines (cursal.symtab, first,
+ first + get_lines_to_list (), 0);
+ return;
+ }
}
/* "l" or "l +" lists next ten lines. */
error (_("No source file for address %s."),
paddress (get_current_arch (), sal.pc));
- gdbarch = get_objfile_arch (sal.symtab->objfile);
+ gdbarch = get_objfile_arch (SYMTAB_OBJFILE (sal.symtab));
sym = find_pc_function (sal.pc);
if (sym)
printf_filtered ("%s is in %s (%s:%d).\n",
const char *comname = args;
c = lookup_cmd (&comname, cmdlist, "", 0, 1);
- /* c->user_commands would be NULL if it's a python command. */
- if (c->class != class_user || !c->user_commands)
+ if (!cli_user_command_p (c))
error (_("Not a user command."));
show_user_1 (c, "", args, gdb_stdout);
}
{
for (c = cmdlist; c; c = c->next)
{
- if (c->class == class_user || c->prefixlist != NULL)
+ if (cli_user_command_p (c) || c->prefixlist != NULL)
show_user_1 (c, "", c->name, gdb_stdout);
}
}
{
printf_unfiltered (_("\"set debug\" must be followed by "
"the name of a debug subcommand.\n"));
- help_list (setdebuglist, "set debug ", -1, gdb_stdout);
+ help_list (setdebuglist, "set debug ", all_commands, gdb_stdout);
}
static void
show_script_ext_mode,
&setlist, &showlist);
- add_com ("quit", class_support, quit_command, _("Exit gdb."));
+ add_com ("quit", class_support, quit_command, _("\
+Exit gdb.\n\
+Usage: quit [EXPR]\n\
+The optional expression EXPR, if present, is evaluated and the result\n\
+used as GDB's exit code. The default is zero."));
c = add_com ("help", class_support, help_command,
_("Print list of commands."));
set_cmd_completer (c, command_completer);
Run the ``make'' program using the rest of the line as arguments."));
set_cmd_completer (c, filename_completer);
add_cmd ("user", no_class, show_user, _("\
-Show definitions of non-python user defined commands.\n\
+Show definitions of non-python/scheme user defined commands.\n\
Argument is the name of the user defined command.\n\
With no argument, show definitions of all user defined commands."), &showlist);
add_com ("apropos", class_support, apropos_command,
add_setshow_uinteger_cmd ("max-user-call-depth", no_class,
&max_user_call_depth, _("\
-Set the max call depth for non-python user-defined commands."), _("\
-Show the max call depth for non-python user-defined commands."), NULL,
+Set the max call depth for non-python/scheme user-defined commands."), _("\
+Show the max call depth for non-python/scheme user-defined commands."), NULL,
NULL,
show_max_user_call_depth,
&setlist, &showlist);