From 76420d4630b6d072ec8dba3add80c76adfe7bd08 Mon Sep 17 00:00:00 2001 From: Stu Grossman Date: Wed, 17 Jul 1996 06:41:25 +0000 Subject: [PATCH] * 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. --- gdb/ChangeLog | 11 ++++++++++ gdb/command.c | 9 +++++--- gdb/solib.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 72 insertions(+), 6 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3f744e97ae9..05f9e81dff3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +Tue Jul 16 23:37:25 1996 Stu Grossman (grossman@critters.cygnus.com) + + * command.c (do_setshow_command): Don't segfault when showing + var_string and var_string_noescape vars that are NULL. + Mon Jul 15 16:55:48 1996 Doug Evans * win32-nat.c (handle_load_dll): dos_path_to_unix_path renamed to @@ -421,6 +426,12 @@ Tue May 28 11:14:58 1996 Tom Tromey * aclocal.m4 (CY_AC_PATH_TCLH): Don't use AC_TRY_RUN. (CY_AC_PATH_TKH): Don't use AC_TRY_RUN. +Sun May 26 16:56:35 1996 Miles Bader + + * 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. + Sun May 26 14:14:49 1996 Fred Fish Changes from: David Mosberger-Tang diff --git a/gdb/command.c b/gdb/command.c index a5477ddd327..9afbf82e59a 100644 --- a/gdb/command.c +++ b/gdb/command.c @@ -1273,9 +1273,11 @@ do_setshow_command (arg, from_tty, c) case var_string: { unsigned char *p; + fputs_filtered ("\"", gdb_stdout); - for (p = *(unsigned char **) c->var; *p != '\0'; p++) - gdb_printchar (*p, gdb_stdout, '"'); + if (*(unsigned char **)c->var) + for (p = *(unsigned char **) c->var; *p != '\0'; p++) + gdb_printchar (*p, gdb_stdout, '"'); fputs_filtered ("\"", gdb_stdout); } break; @@ -1283,7 +1285,8 @@ do_setshow_command (arg, from_tty, c) case var_filename: case var_enum: fputs_filtered ("\"", gdb_stdout); - fputs_filtered (*(char **) c->var, gdb_stdout); + if (*(char **)c->var) + fputs_filtered (*(char **) c->var, gdb_stdout); fputs_filtered ("\"", gdb_stdout); break; case var_boolean: diff --git a/gdb/solib.c b/gdb/solib.c index 9e50c1666b4..b8fffd75d43 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 */ } -- 2.30.2