gdb: fix python/lib/gdb/__init__.py formatting
[deliverable/binutils-gdb.git] / gdb / python / py-auto-load.c
index d5450b37bc6605f5265bad4f5f40c4d627e3917b..20659858a56458aa5614c12311960588a5113d9c 100644 (file)
@@ -1,6 +1,6 @@
 /* GDB routines for supporting auto-loaded scripts.
 
-   Copyright (C) 2010-2013 Free Software Foundation, Inc.
+   Copyright (C) 2010-2021 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include <string.h>
 #include "top.h"
-#include "exceptions.h"
 #include "gdbcmd.h"
 #include "objfiles.h"
 #include "python.h"
 #include "auto-load.h"
-
-#ifdef HAVE_PYTHON
-
 #include "python-internal.h"
 
 /* User-settable option to enable/disable auto-loading of Python scripts:
    set auto-load python-scripts on|off
    This is true if we should auto-load associated Python scripts when an
    objfile is opened, false otherwise.  */
-static int auto_load_python_scripts = 1;
+static bool auto_load_python_scripts = true;
 
 /* "show" command for the auto_load_python_scripts configuration variable.  */
 
@@ -45,46 +40,25 @@ show_auto_load_python_scripts (struct ui_file *file, int from_tty,
   fprintf_filtered (file, _("Auto-loading of Python scripts is %s.\n"), value);
 }
 
-/* Return non-zero if auto-loading Python scripts is enabled.  */
+/* See python-internal.h.  */
 
-static int
-auto_load_python_scripts_enabled (void)
+bool
+gdbpy_auto_load_enabled (const struct extension_language_defn *extlang)
 {
   return auto_load_python_scripts;
 }
 
-/* Definition of script language for Python scripts.  */
-
-static const struct script_language script_language_python =
-{
-  "python",
-  GDBPY_AUTO_FILE_NAME,
-  auto_load_python_scripts_enabled,
-  source_python_script_for_objfile
-};
-
-/* Return the Python script language definition.  */
-
-const struct script_language *
-gdbpy_script_language_defn (void)
-{
-  return &script_language_python;
-}
-
 /* Wrapper for "info auto-load python-scripts".  */
 
 static void
-info_auto_load_python_scripts (char *pattern, int from_tty)
+info_auto_load_python_scripts (const char *pattern, int from_tty)
 {
-  auto_load_info_scripts (pattern, from_tty, &script_language_python);
+  auto_load_info_scripts (pattern, from_tty, &extension_language_python);
 }
 \f
 int
 gdbpy_initialize_auto_load (void)
 {
-  struct cmd_list_element *cmd;
-  const char *cmd_name;
-
   add_setshow_boolean_cmd ("python-scripts", class_support,
                           &auto_load_python_scripts, _("\
 Set the debugger's behaviour regarding auto-loaded Python scripts."), _("\
@@ -96,45 +70,28 @@ This options has security implications for untrusted inferiors."),
                           auto_load_set_cmdlist_get (),
                           auto_load_show_cmdlist_get ());
 
-  add_setshow_boolean_cmd ("auto-load-scripts", class_support,
-                          &auto_load_python_scripts, _("\
+  set_show_commands auto_load_scripts_cmds
+    = add_setshow_boolean_cmd ("auto-load-scripts", class_support,
+                              &auto_load_python_scripts, _("\
 Set the debugger's behaviour regarding auto-loaded Python scripts, "
                                                                 "deprecated."),
-                          _("\
+                              _("\
 Show the debugger's behaviour regarding auto-loaded Python scripts, "
                                                                 "deprecated."),
-                          NULL, NULL, show_auto_load_python_scripts,
-                          &setlist, &showlist);
-  cmd_name = "auto-load-scripts";
-  cmd = lookup_cmd (&cmd_name, setlist, "", -1, 1);
-  deprecate_cmd (cmd, "set auto-load python-scripts");
-
-  /* It is needed because lookup_cmd updates the CMD_NAME pointer.  */
-  cmd_name = "auto-load-scripts";
-  cmd = lookup_cmd (&cmd_name, showlist, "", -1, 1);
-  deprecate_cmd (cmd, "show auto-load python-scripts");
+                              NULL, NULL, show_auto_load_python_scripts,
+                              &setlist, &showlist);
+  deprecate_cmd (auto_load_scripts_cmds.set, "set auto-load python-scripts");
+  deprecate_cmd (auto_load_scripts_cmds.show, "show auto-load python-scripts");
 
   add_cmd ("python-scripts", class_info, info_auto_load_python_scripts,
           _("Print the list of automatically loaded Python scripts.\n\
 Usage: info auto-load python-scripts [REGEXP]"),
           auto_load_info_cmdlist_get ());
 
-  cmd = add_info ("auto-load-scripts", info_auto_load_python_scripts, _("\
+  cmd_list_element *info_auto_load_scripts_cmd
+    = add_info ("auto-load-scripts", info_auto_load_python_scripts, _("\
 Print the list of automatically loaded Python scripts, deprecated."));
-  deprecate_cmd (cmd, "info auto-load python-scripts");
+  deprecate_cmd (info_auto_load_scripts_cmd, "info auto-load python-scripts");
 
   return 0;
 }
-
-#else /* ! HAVE_PYTHON */
-
-/* Return the Python script language definition.
-   Since support isn't compiled in, return NULL.  */
-
-const struct script_language *
-gdbpy_script_language_defn (void)
-{
-  return NULL;
-}
-
-#endif /* ! HAVE_PYTHON */
This page took 0.030967 seconds and 4 git commands to generate.