diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2012-05-11 18:20:26 +0000 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2012-05-11 18:20:26 +0000 |
commit | 7349ff92c20df6a9f4ea3e53383d99622960d74d (patch) | |
tree | 8dcb7146e055552867a6caaf37a9f62ae24cbaa0 /gdb/auto-load.c | |
parent | 4723351a020971562868ce3d500be1824e820a51 (diff) | |
download | gdb-7349ff92c20df6a9f4ea3e53383d99622960d74d.zip gdb-7349ff92c20df6a9f4ea3e53383d99622960d74d.tar.gz gdb-7349ff92c20df6a9f4ea3e53383d99622960d74d.tar.bz2 |
gdb/
Implement multi-component --with-auto-load-dir.
* NEWS (set auto-load scripts-directory, --with-auto-load-dir): New
entries.
(--with-auto-load-safe-path): Update the default value description.
* auto-load.c (auto_load_dir, set_auto_load_dir, show_auto_load_dir):
New.
(auto_load_objfile_script): Add DEBUG_AUTO_LOAD output. Remove
GDB_DATADIR NULL check. Replace GDB_DATADIR/auto-load by
AUTO_LOAD_DIR. Support $ddir and multiple components in it.
(_initialize_auto_load): Initialize also auto_load_dir. Install new
"set auto-load scripts-directory".
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac (--with-auto-load-dir): New configure option.
(--auto-load-safe-path): Change the default to --with-auto-load-dir.
gdb/doc/
Implement multi-component --with-auto-load-dir.
* gdb.texinfo (Auto-loading): New references
for 'set auto-load scripts-directory'
and 'show auto-load scripts-directory'.
(Auto-loading safe path): Describe the new default. Move $ddir
substituation reference to 'objfile-gdb.py file'.
(objfile-gdb.py file): Describe script-name alias. Change real-name to
script-name. Describe new 'set auto-load scripts-directory'
and 'show auto-load scripts-directory'.
Diffstat (limited to 'gdb/auto-load.c')
-rw-r--r-- | gdb/auto-load.c | 100 |
1 files changed, 90 insertions, 10 deletions
diff --git a/gdb/auto-load.c b/gdb/auto-load.c index 171c9b1..5ee117f 100644 --- a/gdb/auto-load.c +++ b/gdb/auto-load.c @@ -108,6 +108,35 @@ show_auto_load_local_gdbinit (struct ui_file *file, int from_tty, value); } +/* Directory list from which to load auto-loaded scripts. It is not checked + for absolute paths but they are strongly recommended. It is initialized by + _initialize_auto_load. */ +static char *auto_load_dir; + +/* "set" command for the auto_load_dir configuration variable. */ + +static void +set_auto_load_dir (char *args, int from_tty, struct cmd_list_element *c) +{ + /* Setting the variable to "" resets it to the compile time defaults. */ + if (auto_load_dir[0] == '\0') + { + xfree (auto_load_dir); + auto_load_dir = xstrdup (AUTO_LOAD_DIR); + } +} + +/* "show" command for the auto_load_dir configuration variable. */ + +static void +show_auto_load_dir (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + fprintf_filtered (file, _("List of directories from which to load " + "auto-loaded scripts is %s.\n"), + value); +} + /* Directory list safe to hold auto-loaded files. It is not checked for absolute paths but they are strongly recommended. It is initialized by _initialize_auto_load. */ @@ -602,6 +631,9 @@ auto_load_objfile_script (struct objfile *objfile, input = fopen (filename, "r"); debugfile = filename; + if (debug_auto_load) + fprintf_unfiltered (gdb_stdlog, _("auto-load: Attempted file \"%s\" %s.\n"), + debugfile, input ? _("exists") : _("does not exist")); if (!input) { @@ -612,6 +644,12 @@ auto_load_objfile_script (struct objfile *objfile, debugdir_vec = dirnames_to_char_ptr_vec (debug_file_directory); make_cleanup_free_char_ptr_vec (debugdir_vec); + if (debug_auto_load) + fprintf_unfiltered (gdb_stdlog, + _("auto-load: Searching 'set debug-file-directory' " + "path \"%s\".\n"), + debug_file_directory); + for (ix = 0; VEC_iterate (char_ptr, debugdir_vec, ix, debugdir); ++ix) { /* Also try the same file in the separate debug info directory. */ @@ -623,24 +661,53 @@ auto_load_objfile_script (struct objfile *objfile, make_cleanup (xfree, debugfile); input = fopen (debugfile, "r"); + if (debug_auto_load) + fprintf_unfiltered (gdb_stdlog, _("auto-load: Attempted file " + "\"%s\" %s.\n"), + debugfile, + input ? _("exists") : _("does not exist")); if (input != NULL) break; } } - if (!input && gdb_datadir) + if (!input) { + VEC (char_ptr) *vec; + int ix; + char *dir; + /* Also try the same file in a subdirectory of gdb's data directory. */ - debugfile = xmalloc (strlen (gdb_datadir) + strlen (filename) - + strlen ("/auto-load") + 1); - strcpy (debugfile, gdb_datadir); - strcat (debugfile, "/auto-load"); - /* FILENAME is absolute, so we don't need a "/" here. */ - strcat (debugfile, filename); - - make_cleanup (xfree, debugfile); - input = fopen (debugfile, "r"); + + vec = dirnames_to_char_ptr_vec (auto_load_dir); + make_cleanup_free_char_ptr_vec (vec); + + if (debug_auto_load) + fprintf_unfiltered (gdb_stdlog, _("auto-load: Searching 'set auto-load " + "scripts-directory' path \"%s\".\n"), + auto_load_dir); + + for (ix = 0; VEC_iterate (char_ptr, vec, ix, dir); ++ix) + { + debugfile = xstrdup (dir); + substitute_path_component (&debugfile, "$ddir", gdb_datadir); + debugfile = xrealloc (debugfile, (strlen (debugfile) + + strlen (filename) + 1)); + + /* FILENAME is absolute, so we don't need a "/" here. */ + strcat (debugfile, filename); + + make_cleanup (xfree, debugfile); + input = fopen (debugfile, "r"); + if (debug_auto_load) + fprintf_unfiltered (gdb_stdlog, _("auto-load: Attempted file " + "\"%s\" %s.\n"), + debugfile, + input ? _("exists") : _("does not exist")); + if (input != NULL) + break; + } } if (input) @@ -1056,6 +1123,19 @@ This options has security implications for untrusted inferiors."), Usage: info auto-load local-gdbinit"), auto_load_info_cmdlist_get ()); + auto_load_dir = xstrdup (AUTO_LOAD_DIR); + add_setshow_optional_filename_cmd ("scripts-directory", class_support, + &auto_load_dir, _("\ +Set the list of directories from which to load auto-loaded scripts."), _("\ +Show the list of directories from which to load auto-loaded scripts."), _("\ +Automatically loaded Python scripts and GDB scripts are located in one of the\n\ +directories listed by this option. This option is ignored for the kinds of\n\ +scripts having 'set auto-load ... off'. Directories listed here need to be\n\ +present also in the 'set auto-load safe-path' option."), + set_auto_load_dir, show_auto_load_dir, + auto_load_set_cmdlist_get (), + auto_load_show_cmdlist_get ()); + auto_load_safe_path = xstrdup (AUTO_LOAD_SAFE_PATH); auto_load_safe_path_vec_update (); add_setshow_optional_filename_cmd ("safe-path", class_support, |