1 /* GDB routines for supporting auto-loaded scripts.
3 Copyright (C) 2010-2014 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 #include "exceptions.h"
27 #include "auto-load.h"
28 #include "python-internal.h"
30 /* User-settable option to enable/disable auto-loading of Python scripts:
31 set auto-load python-scripts on|off
32 This is true if we should auto-load associated Python scripts when an
33 objfile is opened, false otherwise. */
34 static int auto_load_python_scripts = 1;
36 /* "show" command for the auto_load_python_scripts configuration variable. */
39 show_auto_load_python_scripts (struct ui_file *file, int from_tty,
40 struct cmd_list_element *c, const char *value)
42 fprintf_filtered (file, _("Auto-loading of Python scripts is %s.\n"), value);
45 /* Return non-zero if auto-loading Python scripts is enabled.
46 This is the extension_language_script_ops.auto_load_enabled "method". */
49 gdbpy_auto_load_enabled (const struct extension_language_defn *extlang)
51 return auto_load_python_scripts;
54 /* Wrapper for "info auto-load python-scripts". */
57 info_auto_load_python_scripts (char *pattern, int from_tty)
59 auto_load_info_scripts (pattern, from_tty, &extension_language_python);
63 gdbpy_initialize_auto_load (void)
65 struct cmd_list_element *cmd;
68 add_setshow_boolean_cmd ("python-scripts", class_support,
69 &auto_load_python_scripts, _("\
70 Set the debugger's behaviour regarding auto-loaded Python scripts."), _("\
71 Show the debugger's behaviour regarding auto-loaded Python scripts."), _("\
72 If enabled, auto-loaded Python scripts are loaded when the debugger reads\n\
73 an executable or shared library.\n\
74 This options has security implications for untrusted inferiors."),
75 NULL, show_auto_load_python_scripts,
76 auto_load_set_cmdlist_get (),
77 auto_load_show_cmdlist_get ());
79 add_setshow_boolean_cmd ("auto-load-scripts", class_support,
80 &auto_load_python_scripts, _("\
81 Set the debugger's behaviour regarding auto-loaded Python scripts, "
84 Show the debugger's behaviour regarding auto-loaded Python scripts, "
86 NULL, NULL, show_auto_load_python_scripts,
88 cmd_name = "auto-load-scripts";
89 cmd = lookup_cmd (&cmd_name, setlist, "", -1, 1);
90 deprecate_cmd (cmd, "set auto-load python-scripts");
92 /* It is needed because lookup_cmd updates the CMD_NAME pointer. */
93 cmd_name = "auto-load-scripts";
94 cmd = lookup_cmd (&cmd_name, showlist, "", -1, 1);
95 deprecate_cmd (cmd, "show auto-load python-scripts");
97 add_cmd ("python-scripts", class_info, info_auto_load_python_scripts,
98 _("Print the list of automatically loaded Python scripts.\n\
99 Usage: info auto-load python-scripts [REGEXP]"),
100 auto_load_info_cmdlist_get ());
102 cmd = add_info ("auto-load-scripts", info_auto_load_python_scripts, _("\
103 Print the list of automatically loaded Python scripts, deprecated."));
104 deprecate_cmd (cmd, "info auto-load python-scripts");