gdb/
[external/binutils.git] / gdb / auto-load.c
1 /* GDB routines for supporting auto-loaded scripts.
2
3    Copyright (C) 2012 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 "auto-load.h"
22 #include "progspace.h"
23 #include "python/python.h"
24 #include "gdb_regex.h"
25 #include "ui-out.h"
26 #include "filenames.h"
27 #include "command.h"
28 #include "observer.h"
29 #include "objfiles.h"
30 #include "exceptions.h"
31 #include "cli/cli-script.h"
32 #include "gdbcmd.h"
33 #include "cli/cli-decode.h"
34 #include "cli/cli-setshow.h"
35
36 /* The suffix of per-objfile scripts to auto-load as non-Python command files.
37    E.g. When the program loads libfoo.so, look for libfoo-gdb.gdb.  */
38 #define GDB_AUTO_FILE_NAME "-gdb.gdb"
39
40 static void source_gdb_script_for_objfile (struct objfile *objfile, FILE *file,
41                                            const char *filename);
42
43 /* User-settable option to enable/disable auto-loading of GDB_AUTO_FILE_NAME
44    scripts:
45    set auto-load gdb-scripts on|off
46    This is true if we should auto-load associated scripts when an objfile
47    is opened, false otherwise.  */
48 static int auto_load_gdb_scripts = 1;
49
50 /* "show" command for the auto_load_gdb_scripts configuration variable.  */
51
52 static void
53 show_auto_load_gdb_scripts (struct ui_file *file, int from_tty,
54                             struct cmd_list_element *c, const char *value)
55 {
56   fprintf_filtered (file, _("Auto-loading of canned sequences of commands "
57                             "scripts is %s.\n"),
58                     value);
59 }
60
61 /* Internal-use flag to enable/disable auto-loading.
62    This is true if we should auto-load python code when an objfile is opened,
63    false otherwise.
64
65    Both auto_load_scripts && global_auto_load must be true to enable
66    auto-loading.
67
68    This flag exists to facilitate deferring auto-loading during start-up
69    until after ./.gdbinit has been read; it may augment the search directories
70    used to find the scripts.  */
71 int global_auto_load = 1;
72
73 /* Auto-load .gdbinit file from the current directory?  */
74 int auto_load_local_gdbinit = 1;
75
76 /* Absolute pathname to the current directory .gdbinit, if it exists.  */
77 char *auto_load_local_gdbinit_pathname = NULL;
78
79 /* Boolean value if AUTO_LOAD_LOCAL_GDBINIT_PATHNAME has been loaded.  */
80 int auto_load_local_gdbinit_loaded = 0;
81
82 /* "show" command for the auto_load_local_gdbinit configuration variable.  */
83
84 static void
85 show_auto_load_local_gdbinit (struct ui_file *file, int from_tty,
86                               struct cmd_list_element *c, const char *value)
87 {
88   fprintf_filtered (file, _("Auto-loading of .gdbinit script from current "
89                             "directory is %s.\n"),
90                     value);
91 }
92
93 /* Definition of script language for GDB canned sequences of commands.  */
94
95 static const struct script_language script_language_gdb
96   = { GDB_AUTO_FILE_NAME, source_gdb_script_for_objfile };
97
98 static void
99 source_gdb_script_for_objfile (struct objfile *objfile, FILE *file,
100                                const char *filename)
101 {
102   struct auto_load_pspace_info *pspace_info;
103   volatile struct gdb_exception e;
104
105   /* Add this script to the hash table too so "info auto-load gdb-scripts"
106      can print it.  */
107   pspace_info = get_auto_load_pspace_data_for_loading (current_program_space);
108   maybe_add_script (pspace_info, filename, filename, &script_language_gdb);
109
110   TRY_CATCH (e, RETURN_MASK_ALL)
111     {
112       script_from_file (file, filename);
113     }
114   exception_print (gdb_stderr, e);
115 }
116
117 /* For scripts specified in .debug_gdb_scripts, multiple objfiles may load
118    the same script.  There's no point in loading the script multiple times,
119    and there can be a lot of objfiles and scripts, so we keep track of scripts
120    loaded this way.  */
121
122 struct auto_load_pspace_info
123 {
124   /* For each program space we keep track of loaded scripts.  */
125   struct htab *loaded_scripts;
126
127   /* Non-zero if we've issued the warning about an auto-load script not being
128      found.  We only want to issue this warning once.  */
129   int script_not_found_warning_printed;
130 };
131
132 /* Objects of this type are stored in the loaded script hash table.  */
133
134 struct loaded_script
135 {
136   /* Name as provided by the objfile.  */
137   const char *name;
138
139   /* Full path name or NULL if script wasn't found (or was otherwise
140      inaccessible).  */
141   const char *full_path;
142
143   const struct script_language *language;
144 };
145
146 /* Per-program-space data key.  */
147 static const struct program_space_data *auto_load_pspace_data;
148
149 static void
150 auto_load_pspace_data_cleanup (struct program_space *pspace, void *arg)
151 {
152   struct auto_load_pspace_info *info;
153
154   info = program_space_data (pspace, auto_load_pspace_data);
155   if (info != NULL)
156     {
157       if (info->loaded_scripts)
158         htab_delete (info->loaded_scripts);
159       xfree (info);
160     }
161 }
162
163 /* Get the current autoload data.  If none is found yet, add it now.  This
164    function always returns a valid object.  */
165
166 static struct auto_load_pspace_info *
167 get_auto_load_pspace_data (struct program_space *pspace)
168 {
169   struct auto_load_pspace_info *info;
170
171   info = program_space_data (pspace, auto_load_pspace_data);
172   if (info == NULL)
173     {
174       info = XZALLOC (struct auto_load_pspace_info);
175       set_program_space_data (pspace, auto_load_pspace_data, info);
176     }
177
178   return info;
179 }
180
181 /* Hash function for the loaded script hash.  */
182
183 static hashval_t
184 hash_loaded_script_entry (const void *data)
185 {
186   const struct loaded_script *e = data;
187
188   return htab_hash_string (e->name) ^ htab_hash_pointer (e->language);
189 }
190
191 /* Equality function for the loaded script hash.  */
192
193 static int
194 eq_loaded_script_entry (const void *a, const void *b)
195 {
196   const struct loaded_script *ea = a;
197   const struct loaded_script *eb = b;
198
199   return strcmp (ea->name, eb->name) == 0 && ea->language == eb->language;
200 }
201
202 /* Initialize the table to track loaded scripts.
203    Each entry is hashed by the full path name.  */
204
205 static void
206 init_loaded_scripts_info (struct auto_load_pspace_info *pspace_info)
207 {
208   /* Choose 31 as the starting size of the hash table, somewhat arbitrarily.
209      Space for each entry is obtained with one malloc so we can free them
210      easily.  */
211
212   pspace_info->loaded_scripts = htab_create (31,
213                                              hash_loaded_script_entry,
214                                              eq_loaded_script_entry,
215                                              xfree);
216
217   pspace_info->script_not_found_warning_printed = FALSE;
218 }
219
220 /* Wrapper on get_auto_load_pspace_data to also allocate the hash table
221    for loading scripts.  */
222
223 struct auto_load_pspace_info *
224 get_auto_load_pspace_data_for_loading (struct program_space *pspace)
225 {
226   struct auto_load_pspace_info *info;
227
228   info = get_auto_load_pspace_data (pspace);
229   if (info->loaded_scripts == NULL)
230     init_loaded_scripts_info (info);
231
232   return info;
233 }
234
235 /* Add script NAME in LANGUAGE to hash table of PSPACE_INFO.
236    FULL_PATH is NULL if the script wasn't found.  The result is
237    true if the script was already in the hash table.  */
238
239 int
240 maybe_add_script (struct auto_load_pspace_info *pspace_info,
241                   const char *name, const char *full_path,
242                   const struct script_language *language)
243 {
244   struct htab *htab = pspace_info->loaded_scripts;
245   struct loaded_script **slot, entry;
246   int in_hash_table;
247
248   entry.name = name;
249   entry.language = language;
250   slot = (struct loaded_script **) htab_find_slot (htab, &entry, INSERT);
251   in_hash_table = *slot != NULL;
252
253   /* If this script is not in the hash table, add it.  */
254
255   if (! in_hash_table)
256     {
257       char *p;
258
259       /* Allocate all space in one chunk so it's easier to free.  */
260       *slot = xmalloc (sizeof (**slot)
261                        + strlen (name) + 1
262                        + (full_path != NULL ? (strlen (full_path) + 1) : 0));
263       p = ((char*) *slot) + sizeof (**slot);
264       strcpy (p, name);
265       (*slot)->name = p;
266       if (full_path != NULL)
267         {
268           p += strlen (p) + 1;
269           strcpy (p, full_path);
270           (*slot)->full_path = p;
271         }
272       else
273         (*slot)->full_path = NULL;
274       (*slot)->language = language;
275     }
276
277   return in_hash_table;
278 }
279
280 /* Clear the table of loaded section scripts.  */
281
282 static void
283 clear_section_scripts (void)
284 {
285   struct program_space *pspace = current_program_space;
286   struct auto_load_pspace_info *info;
287
288   info = program_space_data (pspace, auto_load_pspace_data);
289   if (info != NULL && info->loaded_scripts != NULL)
290     {
291       htab_delete (info->loaded_scripts);
292       info->loaded_scripts = NULL;
293       info->script_not_found_warning_printed = FALSE;
294     }
295 }
296
297 /* Look for the auto-load script in LANGUAGE associated with OBJFILE and load
298    it.  */
299
300 void
301 auto_load_objfile_script (struct objfile *objfile,
302                           const struct script_language *language)
303 {
304   char *realname;
305   char *filename, *debugfile;
306   int len;
307   FILE *input;
308   struct cleanup *cleanups;
309
310   realname = gdb_realpath (objfile->name);
311   len = strlen (realname);
312   filename = xmalloc (len + strlen (language->suffix) + 1);
313   memcpy (filename, realname, len);
314   strcpy (filename + len, language->suffix);
315
316   cleanups = make_cleanup (xfree, filename);
317   make_cleanup (xfree, realname);
318
319   input = fopen (filename, "r");
320   debugfile = filename;
321
322   if (!input && debug_file_directory)
323     {
324       /* Also try the same file in the separate debug info directory.  */
325       debugfile = xmalloc (strlen (filename)
326                            + strlen (debug_file_directory) + 1);
327       strcpy (debugfile, debug_file_directory);
328       /* FILENAME is absolute, so we don't need a "/" here.  */
329       strcat (debugfile, filename);
330
331       make_cleanup (xfree, debugfile);
332       input = fopen (debugfile, "r");
333     }
334
335   if (!input && gdb_datadir)
336     {
337       /* Also try the same file in a subdirectory of gdb's data
338          directory.  */
339       debugfile = xmalloc (strlen (gdb_datadir) + strlen (filename)
340                            + strlen ("/auto-load") + 1);
341       strcpy (debugfile, gdb_datadir);
342       strcat (debugfile, "/auto-load");
343       /* FILENAME is absolute, so we don't need a "/" here.  */
344       strcat (debugfile, filename);
345
346       make_cleanup (xfree, debugfile);
347       input = fopen (debugfile, "r");
348     }
349
350   if (input)
351     {
352       make_cleanup_fclose (input);
353
354       /* To preserve existing behaviour we don't check for whether the
355          script was already in the table, and always load it.
356          It's highly unlikely that we'd ever load it twice,
357          and these scripts are required to be idempotent under multiple
358          loads anyway.  */
359       language->source_script_for_objfile (objfile, input, debugfile);
360     }
361
362   do_cleanups (cleanups);
363 }
364
365 /* Load any auto-loaded scripts for OBJFILE.  */
366
367 void
368 load_auto_scripts_for_objfile (struct objfile *objfile)
369 {
370   if (!global_auto_load)
371     return;
372
373   if (auto_load_gdb_scripts)
374     auto_load_objfile_script (objfile, &script_language_gdb);
375
376   gdbpy_load_auto_scripts_for_objfile (objfile);
377 }
378
379 /* This is a new_objfile observer callback to auto-load scripts.
380
381    Two flavors of auto-loaded scripts are supported.
382    1) based on the path to the objfile
383    2) from .debug_gdb_scripts section  */
384
385 static void
386 auto_load_new_objfile (struct objfile *objfile)
387 {
388   if (!objfile)
389     {
390       /* OBJFILE is NULL when loading a new "main" symbol-file.  */
391       clear_section_scripts ();
392       return;
393     }
394
395   load_auto_scripts_for_objfile (objfile);
396 }
397
398 /* Collect scripts to be printed in a vec.  */
399
400 typedef struct loaded_script *loaded_script_ptr;
401 DEF_VEC_P (loaded_script_ptr);
402
403 struct collect_matching_scripts_data
404 {
405   VEC (loaded_script_ptr) **scripts_p;
406
407   const struct script_language *language;
408 };
409
410 /* Traversal function for htab_traverse.
411    Collect the entry if it matches the regexp.  */
412
413 static int
414 collect_matching_scripts (void **slot, void *info)
415 {
416   struct loaded_script *script = *slot;
417   struct collect_matching_scripts_data *data = info;
418
419   if (script->language == data->language && re_exec (script->name))
420     VEC_safe_push (loaded_script_ptr, *data->scripts_p, script);
421
422   return 1;
423 }
424
425 /* Print SCRIPT.  */
426
427 static void
428 print_script (struct loaded_script *script)
429 {
430   struct ui_out *uiout = current_uiout;
431   struct cleanup *chain;
432
433   chain = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
434
435   ui_out_field_string (uiout, "loaded", script->full_path ? "Yes" : "Missing");
436   ui_out_field_string (uiout, "script", script->name);
437   ui_out_text (uiout, "\n");
438
439   /* If the name isn't the full path, print it too.  */
440   if (script->full_path != NULL
441       && strcmp (script->name, script->full_path) != 0)
442     {
443       ui_out_text (uiout, "\tfull name: ");
444       ui_out_field_string (uiout, "full_path", script->full_path);
445       ui_out_text (uiout, "\n");
446     }
447
448   do_cleanups (chain);
449 }
450
451 /* Helper for info_auto_load_scripts to sort the scripts by name.  */
452
453 static int
454 sort_scripts_by_name (const void *ap, const void *bp)
455 {
456   const struct loaded_script *a = *(const struct loaded_script **) ap;
457   const struct loaded_script *b = *(const struct loaded_script **) bp;
458
459   return FILENAME_CMP (a->name, b->name);
460 }
461
462 /* Special internal GDB value of auto_load_info_scripts's PATTERN identify
463    the "info auto-load XXX" command has been executed through the general
464    "info auto-load" invocation.  Extra newline will be printed if needed.  */
465 char auto_load_info_scripts_pattern_nl[] = "";
466
467 /* Implementation for "info auto-load gdb-scripts"
468    (and "info auto-load python-scripts").  List scripts in LANGUAGE matching
469    PATTERN.  FROM_TTY is the usual GDB boolean for user interactivity.  */
470
471 void
472 auto_load_info_scripts (char *pattern, int from_tty,
473                         const struct script_language *language)
474 {
475   struct ui_out *uiout = current_uiout;
476   struct auto_load_pspace_info *pspace_info;
477   struct cleanup *script_chain;
478   VEC (loaded_script_ptr) *scripts;
479   int nr_scripts;
480
481   dont_repeat ();
482
483   pspace_info = get_auto_load_pspace_data (current_program_space);
484
485   if (pattern && *pattern)
486     {
487       char *re_err = re_comp (pattern);
488
489       if (re_err)
490         error (_("Invalid regexp: %s"), re_err);
491     }
492   else
493     {
494       re_comp ("");
495     }
496
497   /* We need to know the number of rows before we build the table.
498      Plus we want to sort the scripts by name.
499      So first traverse the hash table collecting the matching scripts.  */
500
501   scripts = VEC_alloc (loaded_script_ptr, 10);
502   script_chain = make_cleanup (VEC_cleanup (loaded_script_ptr), &scripts);
503
504   if (pspace_info != NULL && pspace_info->loaded_scripts != NULL)
505     {
506       struct collect_matching_scripts_data data = { &scripts, language };
507
508       immediate_quit++;
509       /* Pass a pointer to scripts as VEC_safe_push can realloc space.  */
510       htab_traverse_noresize (pspace_info->loaded_scripts,
511                               collect_matching_scripts, &data);
512       immediate_quit--;
513     }
514
515   nr_scripts = VEC_length (loaded_script_ptr, scripts);
516
517   /* Table header shifted right by preceding "gdb-scripts:  " would not match
518      its columns.  */
519   if (nr_scripts > 0 && pattern == auto_load_info_scripts_pattern_nl)
520     ui_out_text (uiout, "\n");
521
522   make_cleanup_ui_out_table_begin_end (uiout, 2, nr_scripts,
523                                        "AutoLoadedScriptsTable");
524
525   ui_out_table_header (uiout, 7, ui_left, "loaded", "Loaded");
526   ui_out_table_header (uiout, 70, ui_left, "script", "Script");
527   ui_out_table_body (uiout);
528
529   if (nr_scripts > 0)
530     {
531       int i;
532       loaded_script_ptr script;
533
534       qsort (VEC_address (loaded_script_ptr, scripts),
535              VEC_length (loaded_script_ptr, scripts),
536              sizeof (loaded_script_ptr), sort_scripts_by_name);
537       for (i = 0; VEC_iterate (loaded_script_ptr, scripts, i, script); ++i)
538         print_script (script);
539     }
540
541   do_cleanups (script_chain);
542
543   if (nr_scripts == 0)
544     {
545       if (pattern && *pattern)
546         ui_out_message (uiout, 0, "No auto-load scripts matching %s.\n",
547                         pattern);
548       else
549         ui_out_message (uiout, 0, "No auto-load scripts.\n");
550     }
551 }
552
553 /* Wrapper for "info auto-load gdb-scripts".  */
554
555 static void
556 info_auto_load_gdb_scripts (char *pattern, int from_tty)
557 {
558   auto_load_info_scripts (pattern, from_tty, &script_language_gdb);
559 }
560
561 /* Implement 'info auto-load local-gdbinit'.  */
562
563 static void
564 info_auto_load_local_gdbinit (char *args, int from_tty)
565 {
566   if (auto_load_local_gdbinit_pathname == NULL)
567     printf_filtered (_("Local .gdbinit file was not found.\n"));
568   else if (auto_load_local_gdbinit_loaded)
569     printf_filtered (_("Local .gdbinit file \"%s\" has been loaded.\n"),
570                      auto_load_local_gdbinit_pathname);
571   else
572     printf_filtered (_("Local .gdbinit file \"%s\" has not been loaded.\n"),
573                      auto_load_local_gdbinit_pathname);
574 }
575
576 /* Return non-zero if SCRIPT_NOT_FOUND_WARNING_PRINTED of PSPACE_INFO was unset
577    before calling this function.  Always set SCRIPT_NOT_FOUND_WARNING_PRINTED
578    of PSPACE_INFO.  */
579
580 int
581 script_not_found_warning_print (struct auto_load_pspace_info *pspace_info)
582 {
583   int retval = !pspace_info->script_not_found_warning_printed;
584
585   pspace_info->script_not_found_warning_printed = 1;
586
587   return retval;
588 }
589
590 /* The only valid "set auto-load" argument is off|0|no|disable.  */
591
592 static void
593 set_auto_load_cmd (char *args, int from_tty)
594 {
595   struct cmd_list_element *list;
596   size_t length;
597
598   /* See parse_binary_operation in use by the sub-commands.  */
599
600   length = args ? strlen (args) : 0;
601
602   while (length > 0 && (args[length - 1] == ' ' || args[length - 1] == '\t'))
603     length--;
604
605   if (length == 0 || (strncmp (args, "off", length) != 0
606                       && strncmp (args, "0", length) != 0
607                       && strncmp (args, "no", length) != 0
608                       && strncmp (args, "disable", length) != 0))
609     error (_("Valid is only global 'set auto-load no'; "
610              "otherwise check the auto-load sub-commands."));
611
612   for (list = *auto_load_set_cmdlist_get (); list != NULL; list = list->next)
613     if (list->var_type == var_boolean)
614       {
615         gdb_assert (list->type == set_cmd);
616         do_setshow_command (args, from_tty, list);
617       }
618 }
619
620 /* Initialize "set auto-load " commands prefix and return it.  */
621
622 struct cmd_list_element **
623 auto_load_set_cmdlist_get (void)
624 {
625   static struct cmd_list_element *retval;
626
627   if (retval == NULL)
628     add_prefix_cmd ("auto-load", class_maintenance, set_auto_load_cmd, _("\
629 Auto-loading specific settings.\n\
630 Configure various auto-load-specific variables such as\n\
631 automatic loading of Python scripts."),
632                     &retval, "set auto-load ",
633                     1/*allow-unknown*/, &setlist);
634
635   return &retval;
636 }
637
638 /* Command "show auto-load" displays summary of all the current
639    "show auto-load " settings.  */
640
641 static void
642 show_auto_load_cmd (char *args, int from_tty)
643 {
644   cmd_show_list (*auto_load_show_cmdlist_get (), from_tty, "");
645 }
646
647 /* Initialize "show auto-load " commands prefix and return it.  */
648
649 struct cmd_list_element **
650 auto_load_show_cmdlist_get (void)
651 {
652   static struct cmd_list_element *retval;
653
654   if (retval == NULL)
655     add_prefix_cmd ("auto-load", class_maintenance, show_auto_load_cmd, _("\
656 Show auto-loading specific settings.\n\
657 Show configuration of various auto-load-specific variables such as\n\
658 automatic loading of Python scripts."),
659                     &retval, "show auto-load ",
660                     0/*allow-unknown*/, &showlist);
661
662   return &retval;
663 }
664
665 /* Command "info auto-load" displays whether the various auto-load files have
666    been loaded.  This is reimplementation of cmd_show_list which inserts
667    newlines at proper places.  */
668
669 static void
670 info_auto_load_cmd (char *args, int from_tty)
671 {
672   struct cmd_list_element *list;
673   struct cleanup *infolist_chain;
674   struct ui_out *uiout = current_uiout;
675
676   infolist_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "infolist");
677
678   for (list = *auto_load_info_cmdlist_get (); list != NULL; list = list->next)
679     {
680       struct cleanup *option_chain
681         = make_cleanup_ui_out_tuple_begin_end (uiout, "option");
682
683       gdb_assert (!list->prefixlist);
684       gdb_assert (list->type == not_set_cmd);
685
686       ui_out_field_string (uiout, "name", list->name);
687       ui_out_text (uiout, ":  ");
688       cmd_func (list, auto_load_info_scripts_pattern_nl, from_tty);
689
690       /* Close the tuple.  */
691       do_cleanups (option_chain);
692     }
693
694   /* Close the tuple.  */
695   do_cleanups (infolist_chain);
696 }
697
698 /* Initialize "info auto-load " commands prefix and return it.  */
699
700 struct cmd_list_element **
701 auto_load_info_cmdlist_get (void)
702 {
703   static struct cmd_list_element *retval;
704
705   if (retval == NULL)
706     add_prefix_cmd ("auto-load", class_info, info_auto_load_cmd, _("\
707 Print current status of auto-loaded files.\n\
708 Print whether various files like Python scripts or .gdbinit files have been\n\
709 found and/or loaded."),
710                     &retval, "info auto-load ",
711                     0/*allow-unknown*/, &infolist);
712
713   return &retval;
714 }
715
716 void _initialize_auto_load (void);
717
718 void
719 _initialize_auto_load (void)
720 {
721   auto_load_pspace_data
722     = register_program_space_data_with_cleanup (auto_load_pspace_data_cleanup);
723
724   observer_attach_new_objfile (auto_load_new_objfile);
725
726   add_setshow_boolean_cmd ("gdb-scripts", class_support,
727                            &auto_load_gdb_scripts, _("\
728 Enable or disable auto-loading of canned sequences of commands scripts."), _("\
729 Show whether auto-loading of canned sequences of commands scripts is enabled."),
730                            _("\
731 If enabled, canned sequences of commands are loaded when the debugger reads\n\
732 an executable or shared library.\n\
733 This options has security implications for untrusted inferiors."),
734                            NULL, show_auto_load_gdb_scripts,
735                            auto_load_set_cmdlist_get (),
736                            auto_load_show_cmdlist_get ());
737
738   add_cmd ("gdb-scripts", class_info, info_auto_load_gdb_scripts,
739            _("Print the list of automatically loaded sequences of commands.\n\
740 Usage: info auto-load gdb-scripts [REGEXP]"),
741            auto_load_info_cmdlist_get ());
742
743   add_setshow_boolean_cmd ("local-gdbinit", class_support,
744                            &auto_load_local_gdbinit, _("\
745 Enable or disable auto-loading of .gdbinit script in current directory."), _("\
746 Show whether auto-loading .gdbinit script in current directory is enabled."),
747                            _("\
748 If enabled, canned sequences of commands are loaded when debugger starts\n\
749 from .gdbinit file in current directory.  Such files are deprecated,\n\
750 use a script associated with inferior executable file instead.\n\
751 This options has security implications for untrusted inferiors."),
752                            NULL, show_auto_load_local_gdbinit,
753                            auto_load_set_cmdlist_get (),
754                            auto_load_show_cmdlist_get ());
755
756   add_cmd ("local-gdbinit", class_info, info_auto_load_local_gdbinit,
757            _("Print whether current directory .gdbinit file has been loaded.\n\
758 Usage: info auto-load local-gdbinit"),
759            auto_load_info_cmdlist_get ());
760 }