diff options
author | Stu Grossman <grossman@cygnus> | 1996-07-17 06:41:25 +0000 |
---|---|---|
committer | Stu Grossman <grossman@cygnus> | 1996-07-17 06:41:25 +0000 |
commit | 76420d4630b6d072ec8dba3add80c76adfe7bd08 (patch) | |
tree | 3adab4b02907455af6cb01f90414dc7a7e2ce2b9 /gdb/solib.c | |
parent | 647e52ea3a4b9ced141f6bd1b8c88174193c337c (diff) | |
download | gdb-76420d4630b6d072ec8dba3add80c76adfe7bd08.zip gdb-76420d4630b6d072ec8dba3add80c76adfe7bd08.tar.gz gdb-76420d4630b6d072ec8dba3add80c76adfe7bd08.tar.bz2 |
* command.c (do_setshow_command): Don't segfault when showing
var_string and var_string_noescape vars that are NULL.
From the fsf:
* solib.c (solib_absolute_prefix, solib_search_path): New variables.
(_initialize_solib): Add set/show commands for those variables.
(solib_map_sections): Implement searching using them.
Diffstat (limited to 'gdb/solib.c')
-rw-r--r-- | gdb/solib.c | 58 |
1 files changed, 55 insertions, 3 deletions
diff --git a/gdb/solib.c b/gdb/solib.c index 9e50c16..b8fffd7 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -198,6 +198,15 @@ solib_add_common_symbols PARAMS ((struct rtc_symb *)); #endif +/* If non-zero, this is a prefix that will be added to the front of the name + shared libraries with an absolute filename for loading. */ +static char *solib_absolute_prefix = NULL; + +/* If non-empty, this is a search path for loading non-absolute shared library + symbol files. This takes precedence over the environment variables PATH + and LD_LIBRARY_PATH. */ +static char *solib_search_path = NULL; + /* LOCAL FUNCTION @@ -237,10 +246,38 @@ solib_map_sections (so) bfd *abfd; filename = tilde_expand (so -> so_name); - old_chain = make_cleanup (free, filename); - scratch_chan = openp (get_in_environ (inferior_environ, "PATH"), - 1, filename, O_RDONLY, 0, &scratch_pathname); + if (solib_absolute_prefix && ROOTED_P (filename)) + /* Prefix shared libraries with absolute filenames with + SOLIB_ABSOLUTE_PREFIX. */ + { + char *pfxed_fn; + int pfx_len; + + pfx_len = strlen (solib_absolute_prefix); + + /* Remove trailing slashes. */ + while (pfx_len > 0 && SLASH_P (solib_absolute_prefix[pfx_len - 1])) + pfx_len--; + + pfxed_fn = xmalloc (pfx_len + strlen (filename) + 1); + strcpy (pfxed_fn, solib_absolute_prefix); + strcat (pfxed_fn, filename); + free (filename); + + filename = pfxed_fn; + } + + old_chain = make_cleanup (free, filename); + + scratch_chan = -1; + + if (solib_search_path) + scratch_chan = openp (solib_search_path, + 1, filename, O_RDONLY, 0, &scratch_pathname); + if (scratch_chan < 0) + scratch_chan = openp (get_in_environ (inferior_environ, "PATH"), + 1, filename, O_RDONLY, 0, &scratch_pathname); if (scratch_chan < 0) { scratch_chan = openp (get_in_environ @@ -1707,5 +1744,20 @@ must be loaded manually, using `sharedlibrary'.", &setlist), &showlist); + add_show_from_set + (add_set_cmd ("solib-absolute-prefix", class_support, var_filename, + (char *) &solib_absolute_prefix, + "Set prefix for loading absolute shared library symbol files.\n +For other (relative) files, you can add values using `set solib-search-path'.", + &setlist), + &showlist); + add_show_from_set + (add_set_cmd ("solib-search-path", class_support, var_string, + (char *) &solib_search_path, + "Set the search path for loading non-absolute shared library symbol files.\n +This takes precedence over the environment variables PATH and LD_LIBRARY_PATH.", + &setlist), + &showlist); + #endif /* HAVE_LINK_H */ } |