From f1d10cfb3275dbbe933f988a83ca81c54de41f87 Mon Sep 17 00:00:00 2001 From: Andrew Stubbs Date: Wed, 29 Nov 2006 12:27:01 +0000 Subject: [PATCH] 2006-11-29 Andrew Stubbs * solib.c (solib_open): Treat bare file names as relative paths. --- gdb/ChangeLog | 4 ++++ gdb/solib.c | 40 +++++++++++++++++----------------------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index dc4257f947..9c7b5d12e6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2006-11-29 Andrew Stubbs + + * solib.c (solib_open): Treat bare file names as relative paths. + 2006-11-29 Vladimir Prus * varobj.c (varobj_set_value): Don't compare the old diff --git a/gdb/solib.c b/gdb/solib.c index 4fa9fce65f..215d82bcbc 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -1,7 +1,7 @@ /* Handle shared libraries for GDB, the GNU Debugger. Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2005 + 1999, 2000, 2001, 2002, 2003, 2005, 2006 Free Software Foundation, Inc. This file is part of GDB. @@ -151,33 +151,27 @@ solib_open (char *in_pathname, char **found_pathname) solib_absolute_prefix_is_empty = (solib_absolute_prefix == NULL || *solib_absolute_prefix == 0); - while (*p && !IS_DIR_SEPARATOR (*p)) - p++; - - if (*p) + if (! IS_ABSOLUTE_PATH (in_pathname) || solib_absolute_prefix_is_empty) + temp_pathname = in_pathname; + else { - if (! IS_ABSOLUTE_PATH (in_pathname) || solib_absolute_prefix_is_empty) - temp_pathname = in_pathname; - else - { - int prefix_len = strlen (solib_absolute_prefix); + int prefix_len = strlen (solib_absolute_prefix); - /* Remove trailing slashes from absolute prefix. */ - while (prefix_len > 0 - && IS_DIR_SEPARATOR (solib_absolute_prefix[prefix_len - 1])) - prefix_len--; + /* Remove trailing slashes from absolute prefix. */ + while (prefix_len > 0 + && IS_DIR_SEPARATOR (solib_absolute_prefix[prefix_len - 1])) + prefix_len--; - /* Cat the prefixed pathname together. */ - temp_pathname = alloca (prefix_len + strlen (in_pathname) + 1); - strncpy (temp_pathname, solib_absolute_prefix, prefix_len); - temp_pathname[prefix_len] = '\0'; - strcat (temp_pathname, in_pathname); - } - - /* Now see if we can open it. */ - found_file = open (temp_pathname, O_RDONLY | O_BINARY, 0); + /* Cat the prefixed pathname together. */ + temp_pathname = alloca (prefix_len + strlen (in_pathname) + 1); + strncpy (temp_pathname, solib_absolute_prefix, prefix_len); + temp_pathname[prefix_len] = '\0'; + strcat (temp_pathname, in_pathname); } + /* Now see if we can open it. */ + found_file = open (temp_pathname, O_RDONLY | O_BINARY, 0); + /* If the search in solib_absolute_prefix failed, and the path name is absolute at this point, make it relative. (openp will try and open the file according to its absolute path otherwise, which is not what we want.)