/* GDB CLI commands.
- Copyright (C) 2000-2013 Free Software Foundation, Inc.
+ Copyright (C) 2000-2014 Free Software Foundation, Inc.
This file is part of GDB.
#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. */
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)
{
- volatile struct gdb_exception e;
+ const struct extension_language_defn *extlang
+ = get_ext_lang_of_file (file);
- TRY_CATCH (e, RETURN_MASK_ERROR)
+ if (extlang != NULL)
{
- source_python_script (stream, file);
- }
- if (e.reason < 0)
- {
- /* Should we fallback to ye olde GDB script mode? */
- if (script_ext_mode == script_ext_soft
- && e.reason == RETURN_ERROR && e.error == UNSUPPORTED_ERROR)
+ if (ext_lang_present_p (extlang))
{
- fseek (stream, 0, SEEK_SET);
- script_from_file (stream, (char*) file);
+ script_sourcer_func *sourcer
+ = ext_lang_script_sourcer (extlang);
+
+ gdb_assert (sourcer != NULL);
+ sourcer (extlang, stream, file);
+ return;
}
- else
+ else if (script_ext_mode == script_ext_soft)
{
- /* Nope, just punt. */
- throw_exception (e);
+ /* Assume the file is a gdb script.
+ This is handled below. */
}
+ else
+ throw_ext_lang_unsupported (extlang);
}
}
- else
- script_from_file (stream, file);
+
+ script_from_file (stream, file);
}
/* Worker to perform the "source" command.
struct gdbarch *gdbarch;
if (sal.symtab == 0)
- /* FIXME-32x64--assumes sal.pc fits in long. */
error (_("No source file for address %s."),
- hex_string ((unsigned long) sal.pc));
+ paddress (get_current_arch (), sal.pc));
gdbarch = get_objfile_arch (sal.symtab->objfile);
sym = find_pc_function (sal.pc);
struct gdbarch *gdbarch;
if (sal.symtab == 0)
- /* FIXME-32x64--assumes sal.pc fits in long. */
error (_("No source file for address %s."),
- hex_string ((unsigned long) sal.pc));
+ paddress (get_current_arch (), sal.pc));
gdbarch = get_objfile_arch (sal.symtab->objfile);
sym = find_pc_function (sal.pc);
const char *comname = args;
c = lookup_cmd (&comname, cmdlist, "", 0, 1);
- /* c->user_commands would be NULL if it's a python command. */
+ /* c->user_commands would be NULL if it's a python/scheme command. */
if (c->class != class_user || !c->user_commands)
error (_("Not a user command."));
show_user_1 (c, "", args, gdb_stdout);
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);