gdb/python/py-auto-load.c - gdb

Global variables defined

Functions defined

Source code

  1. /* GDB routines for supporting auto-loaded scripts.

  2.    Copyright (C) 2010-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #include "defs.h"
  15. #include "top.h"
  16. #include "gdbcmd.h"
  17. #include "objfiles.h"
  18. #include "python.h"
  19. #include "auto-load.h"
  20. #include "python-internal.h"

  21. /* User-settable option to enable/disable auto-loading of Python scripts:
  22.    set auto-load python-scripts on|off
  23.    This is true if we should auto-load associated Python scripts when an
  24.    objfile is opened, false otherwise.  */
  25. static int auto_load_python_scripts = 1;

  26. /* "show" command for the auto_load_python_scripts configuration variable.  */

  27. static void
  28. show_auto_load_python_scripts (struct ui_file *file, int from_tty,
  29.                                struct cmd_list_element *c, const char *value)
  30. {
  31.   fprintf_filtered (file, _("Auto-loading of Python scripts is %s.\n"), value);
  32. }

  33. /* Return non-zero if auto-loading Python scripts is enabled.
  34.    This is the extension_language_script_ops.auto_load_enabled "method".  */

  35. int
  36. gdbpy_auto_load_enabled (const struct extension_language_defn *extlang)
  37. {
  38.   return auto_load_python_scripts;
  39. }

  40. /* Wrapper for "info auto-load python-scripts".  */

  41. static void
  42. info_auto_load_python_scripts (char *pattern, int from_tty)
  43. {
  44.   auto_load_info_scripts (pattern, from_tty, &extension_language_python);
  45. }

  46. int
  47. gdbpy_initialize_auto_load (void)
  48. {
  49.   struct cmd_list_element *cmd;
  50.   const char *cmd_name;

  51.   add_setshow_boolean_cmd ("python-scripts", class_support,
  52.                            &auto_load_python_scripts, _("\
  53. Set the debugger's behaviour regarding auto-loaded Python scripts."), _("\
  54. Show the debugger's behaviour regarding auto-loaded Python scripts."), _("\
  55. If enabled, auto-loaded Python scripts are loaded when the debugger reads\n\
  56. an executable or shared library.\n\
  57. This options has security implications for untrusted inferiors."),
  58.                            NULL, show_auto_load_python_scripts,
  59.                            auto_load_set_cmdlist_get (),
  60.                            auto_load_show_cmdlist_get ());

  61.   add_setshow_boolean_cmd ("auto-load-scripts", class_support,
  62.                            &auto_load_python_scripts, _("\
  63. Set the debugger's behaviour regarding auto-loaded Python scripts, "
  64.                                                                  "deprecated."),
  65.                            _("\
  66. Show the debugger's behaviour regarding auto-loaded Python scripts, "
  67.                                                                  "deprecated."),
  68.                            NULL, NULL, show_auto_load_python_scripts,
  69.                            &setlist, &showlist);
  70.   cmd_name = "auto-load-scripts";
  71.   cmd = lookup_cmd (&cmd_name, setlist, "", -1, 1);
  72.   deprecate_cmd (cmd, "set auto-load python-scripts");

  73.   /* It is needed because lookup_cmd updates the CMD_NAME pointer.  */
  74.   cmd_name = "auto-load-scripts";
  75.   cmd = lookup_cmd (&cmd_name, showlist, "", -1, 1);
  76.   deprecate_cmd (cmd, "show auto-load python-scripts");

  77.   add_cmd ("python-scripts", class_info, info_auto_load_python_scripts,
  78.            _("Print the list of automatically loaded Python scripts.\n\
  79. Usage: info auto-load python-scripts [REGEXP]"),
  80.            auto_load_info_cmdlist_get ());

  81.   cmd = add_info ("auto-load-scripts", info_auto_load_python_scripts, _("\
  82. Print the list of automatically loaded Python scripts, deprecated."));
  83.   deprecate_cmd (cmd, "info auto-load python-scripts");

  84.   return 0;
  85. }