scm-auto-load.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* GDB routines for supporting auto-loaded Guile scripts.
  2. Copyright (C) 2010-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #include "defs.h"
  15. #include "top.h"
  16. #include "gdbcmd.h"
  17. #include "objfiles.h"
  18. #include "cli/cli-cmds.h"
  19. #include "auto-load.h"
  20. #include "guile.h"
  21. #include "guile-internal.h"
  22. /* User-settable option to enable/disable auto-loading of Guile scripts:
  23. set auto-load guile-scripts on|off
  24. This is true if we should auto-load associated Guile scripts when an
  25. objfile is opened, false otherwise. */
  26. static bool auto_load_guile_scripts = true;
  27. /* "show" command for the auto_load_guile_scripts configuration variable. */
  28. static void
  29. show_auto_load_guile_scripts (struct ui_file *file, int from_tty,
  30. struct cmd_list_element *c, const char *value)
  31. {
  32. gdb_printf (file, _("Auto-loading of Guile scripts is %s.\n"), value);
  33. }
  34. /* See guile-internal.h. */
  35. bool
  36. gdbscm_auto_load_enabled (const struct extension_language_defn *extlang)
  37. {
  38. return auto_load_guile_scripts;
  39. }
  40. /* Wrapper for "info auto-load guile-scripts". */
  41. static void
  42. info_auto_load_guile_scripts (const char *pattern, int from_tty)
  43. {
  44. auto_load_info_scripts (pattern, from_tty, &extension_language_guile);
  45. }
  46. void
  47. gdbscm_initialize_auto_load (void)
  48. {
  49. add_setshow_boolean_cmd ("guile-scripts", class_support,
  50. &auto_load_guile_scripts, _("\
  51. Set the debugger's behaviour regarding auto-loaded Guile scripts."), _("\
  52. Show the debugger's behaviour regarding auto-loaded Guile scripts."), _("\
  53. If enabled, auto-loaded Guile scripts are loaded when the debugger reads\n\
  54. an executable or shared library.\n\
  55. This options has security implications for untrusted inferiors."),
  56. NULL, show_auto_load_guile_scripts,
  57. auto_load_set_cmdlist_get (),
  58. auto_load_show_cmdlist_get ());
  59. add_cmd ("guile-scripts", class_info, info_auto_load_guile_scripts,
  60. _("Print the list of automatically loaded Guile scripts.\n\
  61. Usage: info auto-load guile-scripts [REGEXP]"),
  62. auto_load_info_cmdlist_get ());
  63. }