Commit | Line | Data |
---|---|---|
8a1ea21f DE |
1 | /* GDB routines for supporting auto-loaded scripts. |
2 | ||
3666a048 | 3 | Copyright (C) 2010-2021 Free Software Foundation, Inc. |
8a1ea21f DE |
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" | |
8a1ea21f | 21 | #include "top.h" |
8a1ea21f | 22 | #include "gdbcmd.h" |
8a1ea21f DE |
23 | #include "objfiles.h" |
24 | #include "python.h" | |
e2207b9a | 25 | #include "auto-load.h" |
88a1906b DE |
26 | #include "python-internal.h" |
27 | ||
bf88dd68 JK |
28 | /* User-settable option to enable/disable auto-loading of Python scripts: |
29 | set auto-load python-scripts on|off | |
30 | This is true if we should auto-load associated Python scripts when an | |
31 | objfile is opened, false otherwise. */ | |
491144b5 | 32 | static bool auto_load_python_scripts = true; |
bf88dd68 | 33 | |
bf88dd68 JK |
34 | /* "show" command for the auto_load_python_scripts configuration variable. */ |
35 | ||
36 | static void | |
37 | show_auto_load_python_scripts (struct ui_file *file, int from_tty, | |
38 | struct cmd_list_element *c, const char *value) | |
39 | { | |
40 | fprintf_filtered (file, _("Auto-loading of Python scripts is %s.\n"), value); | |
41 | } | |
42 | ||
db972fce | 43 | /* See python-internal.h. */ |
bf88dd68 | 44 | |
db972fce | 45 | bool |
6dddc817 | 46 | gdbpy_auto_load_enabled (const struct extension_language_defn *extlang) |
bf88dd68 | 47 | { |
5b2bf947 | 48 | return auto_load_python_scripts; |
bf88dd68 | 49 | } |
8a1ea21f | 50 | |
bf88dd68 JK |
51 | /* Wrapper for "info auto-load python-scripts". */ |
52 | ||
53 | static void | |
1d12d88f | 54 | info_auto_load_python_scripts (const char *pattern, int from_tty) |
bf88dd68 | 55 | { |
6dddc817 | 56 | auto_load_info_scripts (pattern, from_tty, &extension_language_python); |
bf88dd68 | 57 | } |
8a1ea21f | 58 | \f |
999633ed | 59 | int |
8a1ea21f DE |
60 | gdbpy_initialize_auto_load (void) |
61 | { | |
bf88dd68 | 62 | struct cmd_list_element *cmd; |
6f937416 | 63 | const char *cmd_name; |
bf88dd68 JK |
64 | |
65 | add_setshow_boolean_cmd ("python-scripts", class_support, | |
66 | &auto_load_python_scripts, _("\ | |
67 | Set the debugger's behaviour regarding auto-loaded Python scripts."), _("\ | |
68 | Show the debugger's behaviour regarding auto-loaded Python scripts."), _("\ | |
69 | If enabled, auto-loaded Python scripts are loaded when the debugger reads\n\ | |
70 | an executable or shared library.\n\ | |
71 | This options has security implications for untrusted inferiors."), | |
72 | NULL, show_auto_load_python_scripts, | |
73 | auto_load_set_cmdlist_get (), | |
74 | auto_load_show_cmdlist_get ()); | |
75 | ||
a86caf66 | 76 | add_setshow_boolean_cmd ("auto-load-scripts", class_support, |
bf88dd68 JK |
77 | &auto_load_python_scripts, _("\ |
78 | Set the debugger's behaviour regarding auto-loaded Python scripts, " | |
79 | "deprecated."), | |
80 | _("\ | |
81 | Show the debugger's behaviour regarding auto-loaded Python scripts, " | |
82 | "deprecated."), | |
83 | NULL, NULL, show_auto_load_python_scripts, | |
84 | &setlist, &showlist); | |
85 | cmd_name = "auto-load-scripts"; | |
cf00cd6f | 86 | cmd = lookup_cmd (&cmd_name, setlist, "", NULL, -1, 1); |
bf88dd68 JK |
87 | deprecate_cmd (cmd, "set auto-load python-scripts"); |
88 | ||
89 | /* It is needed because lookup_cmd updates the CMD_NAME pointer. */ | |
90 | cmd_name = "auto-load-scripts"; | |
cf00cd6f | 91 | cmd = lookup_cmd (&cmd_name, showlist, "", NULL, -1, 1); |
bf88dd68 JK |
92 | deprecate_cmd (cmd, "show auto-load python-scripts"); |
93 | ||
94 | add_cmd ("python-scripts", class_info, info_auto_load_python_scripts, | |
95 | _("Print the list of automatically loaded Python scripts.\n\ | |
96 | Usage: info auto-load python-scripts [REGEXP]"), | |
97 | auto_load_info_cmdlist_get ()); | |
98 | ||
99 | cmd = add_info ("auto-load-scripts", info_auto_load_python_scripts, _("\ | |
100 | Print the list of automatically loaded Python scripts, deprecated.")); | |
101 | deprecate_cmd (cmd, "info auto-load python-scripts"); | |
999633ed TT |
102 | |
103 | return 0; | |
8a1ea21f | 104 | } |