Extension Language API
[deliverable/binutils-gdb.git] / gdb / python / py-auto-load.c
1 /* GDB routines for supporting auto-loaded scripts.
2
3 Copyright (C) 2010-2014 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
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.
11
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.
16
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/>. */
19
20 #include "defs.h"
21 #include <string.h>
22 #include "top.h"
23 #include "exceptions.h"
24 #include "gdbcmd.h"
25 #include "objfiles.h"
26 #include "python.h"
27 #include "auto-load.h"
28 #include "python-internal.h"
29
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;
35
36 /* "show" command for the auto_load_python_scripts configuration variable. */
37
38 static void
39 show_auto_load_python_scripts (struct ui_file *file, int from_tty,
40 struct cmd_list_element *c, const char *value)
41 {
42 fprintf_filtered (file, _("Auto-loading of Python scripts is %s.\n"), value);
43 }
44
45 /* Return non-zero if auto-loading Python scripts is enabled.
46 This is the extension_language_script_ops.auto_load_enabled "method". */
47
48 int
49 gdbpy_auto_load_enabled (const struct extension_language_defn *extlang)
50 {
51 return auto_load_python_scripts;
52 }
53
54 /* Wrapper for "info auto-load python-scripts". */
55
56 static void
57 info_auto_load_python_scripts (char *pattern, int from_tty)
58 {
59 auto_load_info_scripts (pattern, from_tty, &extension_language_python);
60 }
61 \f
62 int
63 gdbpy_initialize_auto_load (void)
64 {
65 struct cmd_list_element *cmd;
66 const char *cmd_name;
67
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 ());
78
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, "
82 "deprecated."),
83 _("\
84 Show the debugger's behaviour regarding auto-loaded Python scripts, "
85 "deprecated."),
86 NULL, NULL, show_auto_load_python_scripts,
87 &setlist, &showlist);
88 cmd_name = "auto-load-scripts";
89 cmd = lookup_cmd (&cmd_name, setlist, "", -1, 1);
90 deprecate_cmd (cmd, "set auto-load python-scripts");
91
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");
96
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 ());
101
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");
105
106 return 0;
107 }
This page took 0.034253 seconds and 4 git commands to generate.