1 /* GDB routines for supporting auto-loaded scripts.
3 Copyright (C) 2010-2013 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"
31 #include "python-internal.h"
33 /* User-settable option to enable/disable auto-loading of Python scripts:
34 set auto-load python-scripts on|off
35 This is true if we should auto-load associated Python scripts when an
36 objfile is opened, false otherwise. */
37 static int auto_load_python_scripts
= 1;
39 /* "show" command for the auto_load_python_scripts configuration variable. */
42 show_auto_load_python_scripts (struct ui_file
*file
, int from_tty
,
43 struct cmd_list_element
*c
, const char *value
)
45 fprintf_filtered (file
, _("Auto-loading of Python scripts is %s.\n"), value
);
48 /* Return non-zero if auto-loading Python scripts is enabled. */
51 auto_load_python_scripts_enabled (void)
53 return auto_load_python_scripts
;
56 /* Definition of script language for Python scripts. */
58 static const struct script_language script_language_python
=
62 auto_load_python_scripts_enabled
,
63 source_python_script_for_objfile
66 /* Return the Python script language definition. */
68 const struct script_language
*
69 gdbpy_script_language_defn (void)
71 return &script_language_python
;
74 /* Wrapper for "info auto-load python-scripts". */
77 info_auto_load_python_scripts (char *pattern
, int from_tty
)
79 auto_load_info_scripts (pattern
, from_tty
, &script_language_python
);
83 gdbpy_initialize_auto_load (void)
85 struct cmd_list_element
*cmd
;
88 add_setshow_boolean_cmd ("python-scripts", class_support
,
89 &auto_load_python_scripts
, _("\
90 Set the debugger's behaviour regarding auto-loaded Python scripts."), _("\
91 Show the debugger's behaviour regarding auto-loaded Python scripts."), _("\
92 If enabled, auto-loaded Python scripts are loaded when the debugger reads\n\
93 an executable or shared library.\n\
94 This options has security implications for untrusted inferiors."),
95 NULL
, show_auto_load_python_scripts
,
96 auto_load_set_cmdlist_get (),
97 auto_load_show_cmdlist_get ());
99 add_setshow_boolean_cmd ("auto-load-scripts", class_support
,
100 &auto_load_python_scripts
, _("\
101 Set the debugger's behaviour regarding auto-loaded Python scripts, "
104 Show the debugger's behaviour regarding auto-loaded Python scripts, "
106 NULL
, NULL
, show_auto_load_python_scripts
,
107 &setlist
, &showlist
);
108 cmd_name
= "auto-load-scripts";
109 cmd
= lookup_cmd (&cmd_name
, setlist
, "", -1, 1);
110 deprecate_cmd (cmd
, "set auto-load python-scripts");
112 /* It is needed because lookup_cmd updates the CMD_NAME pointer. */
113 cmd_name
= "auto-load-scripts";
114 cmd
= lookup_cmd (&cmd_name
, showlist
, "", -1, 1);
115 deprecate_cmd (cmd
, "show auto-load python-scripts");
117 add_cmd ("python-scripts", class_info
, info_auto_load_python_scripts
,
118 _("Print the list of automatically loaded Python scripts.\n\
119 Usage: info auto-load python-scripts [REGEXP]"),
120 auto_load_info_cmdlist_get ());
122 cmd
= add_info ("auto-load-scripts", info_auto_load_python_scripts
, _("\
123 Print the list of automatically loaded Python scripts, deprecated."));
124 deprecate_cmd (cmd
, "info auto-load python-scripts");
129 #else /* ! HAVE_PYTHON */
131 /* Return the Python script language definition.
132 Since support isn't compiled in, return NULL. */
134 const struct script_language
*
135 gdbpy_script_language_defn (void)
140 #endif /* ! HAVE_PYTHON */