This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Open shared libraries from the current directory
- From: Andrew STUBBS <andrew dot stubbs at st dot com>
- To: GDB Patches <gdb-patches at sourceware dot org>
- Date: Wed, 01 Nov 2006 16:54:24 +0000
- Subject: [PATCH] Open shared libraries from the current directory
Hi all,
I raised a point here:
http://sourceware.org/ml/gdb/2006-10/msg00304.html
but, as yet, have not had any response.
The problem, as I see it, is that solib_open does not find shared
libraries even though add-symbol-file with the same name would work
correctly. To my mind a bare file name is the simplest relative path
name, but apparently the code disagrees. The comment says it should do
what I think it should do, however.
The attached patch removes the requirement for a relative path name to
have directory separators in it - I don't understand the motivation for
this requirement.
:ADDPATCH solib.c:
Andrew Stubbs
2006-11-01 Andrew Stubbs <andrew.stubbs@st.com>
* solib.c (solib_open): Treat bare file names as relative paths.
Index: src/gdb/solib.c
===================================================================
--- src.orig/gdb/solib.c 2006-10-11 11:27:00.000000000 +0100
+++ src/gdb/solib.c 2006-11-01 16:34:37.000000000 +0000
@@ -151,33 +151,27 @@ solib_open (char *in_pathname, char **fo
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--;
-
- /* 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);
+ /* 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);
+
/* 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.)