]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/python/py-auto-load.c
gas: introduce .errif and .warnif
[thirdparty/binutils-gdb.git] / gdb / python / py-auto-load.c
CommitLineData
8a1ea21f
DE
1/* GDB routines for supporting auto-loaded scripts.
2
d01e8234 3 Copyright (C) 2010-2025 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
8a1ea21f 20#include "top.h"
5b9707eb 21#include "cli/cli-cmds.h"
8a1ea21f
DE
22#include "objfiles.h"
23#include "python.h"
e2207b9a 24#include "auto-load.h"
88a1906b
DE
25#include "python-internal.h"
26
bf88dd68
JK
27/* User-settable option to enable/disable auto-loading of Python scripts:
28 set auto-load python-scripts on|off
29 This is true if we should auto-load associated Python scripts when an
30 objfile is opened, false otherwise. */
491144b5 31static bool auto_load_python_scripts = true;
bf88dd68 32
bf88dd68
JK
33/* "show" command for the auto_load_python_scripts configuration variable. */
34
35static void
36show_auto_load_python_scripts (struct ui_file *file, int from_tty,
37 struct cmd_list_element *c, const char *value)
38{
6cb06a8c 39 gdb_printf (file, _("Auto-loading of Python scripts is %s.\n"), value);
bf88dd68
JK
40}
41
db972fce 42/* See python-internal.h. */
bf88dd68 43
db972fce 44bool
6dddc817 45gdbpy_auto_load_enabled (const struct extension_language_defn *extlang)
bf88dd68 46{
5b2bf947 47 return auto_load_python_scripts;
bf88dd68 48}
8a1ea21f 49
bf88dd68
JK
50/* Wrapper for "info auto-load python-scripts". */
51
52static void
1d12d88f 53info_auto_load_python_scripts (const char *pattern, int from_tty)
bf88dd68 54{
74ce4f8e
SM
55 auto_load_info_scripts (current_program_space, pattern, from_tty,
56 &extension_language_python);
bf88dd68 57}
8a1ea21f 58\f
3965bff5 59static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
8a1ea21f
DE
60gdbpy_initialize_auto_load (void)
61{
bf88dd68
JK
62 add_setshow_boolean_cmd ("python-scripts", class_support,
63 &auto_load_python_scripts, _("\
ac51afb5
TV
64Set the debugger's behavior regarding auto-loaded Python scripts."), _("\
65Show the debugger's behavior regarding auto-loaded Python scripts."), _("\
bf88dd68
JK
66If enabled, auto-loaded Python scripts are loaded when the debugger reads\n\
67an executable or shared library.\n\
68This options has security implications for untrusted inferiors."),
69 NULL, show_auto_load_python_scripts,
70 auto_load_set_cmdlist_get (),
71 auto_load_show_cmdlist_get ());
72
9f260536
SM
73 set_show_commands auto_load_scripts_cmds
74 = add_setshow_boolean_cmd ("auto-load-scripts", class_support,
75 &auto_load_python_scripts, _("\
ac51afb5 76Set the debugger's behavior regarding auto-loaded Python scripts, "
bf88dd68 77 "deprecated."),
9f260536 78 _("\
ac51afb5 79Show the debugger's behavior regarding auto-loaded Python scripts, "
bf88dd68 80 "deprecated."),
9f260536
SM
81 NULL, NULL, show_auto_load_python_scripts,
82 &setlist, &showlist);
83 deprecate_cmd (auto_load_scripts_cmds.set, "set auto-load python-scripts");
84 deprecate_cmd (auto_load_scripts_cmds.show, "show auto-load python-scripts");
bf88dd68
JK
85
86 add_cmd ("python-scripts", class_info, info_auto_load_python_scripts,
87 _("Print the list of automatically loaded Python scripts.\n\
88Usage: info auto-load python-scripts [REGEXP]"),
89 auto_load_info_cmdlist_get ());
90
9f260536
SM
91 cmd_list_element *info_auto_load_scripts_cmd
92 = add_info ("auto-load-scripts", info_auto_load_python_scripts, _("\
bf88dd68 93Print the list of automatically loaded Python scripts, deprecated."));
9f260536 94 deprecate_cmd (info_auto_load_scripts_cmd, "info auto-load python-scripts");
999633ed
TT
95
96 return 0;
8a1ea21f 97}
3965bff5
AB
98
99GDBPY_INITIALIZE_FILE (gdbpy_initialize_auto_load);