From: Orjan Friberg <orjan.friberg@axis.com>
To: gdb-patches@sources.redhat.com
Cc: Daniel Jacobowitz <drow@mvista.com>
Subject: [RFC]: Solib search (Was: Re: Cross solib support; continued)
Date: Wed, 14 Nov 2001 12:49:00 -0000 [thread overview]
Message-ID: <3C03AB51.DB27B3D4@axis.com> (raw)
Message-ID: <20011114124900.9yIunDomWeVbcPVqKKehm-wh23Thgbv-pnf6S9VJP24@z> (raw)
In-Reply-To: <20011108110955.A12240@nevyn.them.org>
Daniel Jacobowitz wrote:
>
> Other than that, we should fall back to solib-search-path and the
> basename if solib-absolute-path fails for us, IMO. Would that work for
> you? Set the absolute-path to /dev/null or so and then add the
> fallback code.
A quick recap: I'm doing solib debugging in a cross-environment, but the path to the
target's solibs on my host doesn't correspond to the path on the target. More
specifically, the path where I want to get the solibs from on my host doesn't end in
/lib.
This is a first shot at it. The latter part of the patch implements what Daniel
suggested, but the first part is more controversial. The problem is when in_pathname
contains an absolute path (say /lib/libc.so.6), but it's not found in the path
specified by solib_absolute_prefix. When we try and search for the solib in
solib_search_path, openp will find that the file name is an absolute path and open it
(ignoring the supplied solib_search_path). As a result, it will pick up
/lib/libc.so.6 on my host.
My thought was to make the path relative if the search for the absolute path failed,
by simply getting rid of the leading '/'. (It won't work with DOS based file
systems, as the dir separator could be '\\', but that would be easy to add.)
Needless to say, this works for me, but I'm not sure it's The Right Thing to do.
(Another approach would be to change openp, but I'm sure there's a good reason for
its current behaviour.)
2001-11-27 Orjan Friberg <orjanf@axis.com>
* solib.c (solib_open): Make path relative if search for absolute path
failed. If search for relative path in solib_search_path failed, fall
back to search for basename only.
Index: solib.c
===================================================================
RCS file: /cvs/src/src/gdb/solib.c,v
retrieving revision 1.45
diff -u -r1.45 solib.c
--- solib.c 2001/11/01 16:17:08 1.45
+++ solib.c 2001/11/27 14:31:15
@@ -131,10 +131,25 @@
found_file = open (temp_pathname, O_RDONLY, 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.)
+ Affects all subsequent searches for this solib. */
+ if (found_file < 0 && IS_DIR_SEPARATOR (in_pathname[0]))
+ in_pathname++;
+
/* If not found, next search the solib_search_path (if any). */
if (found_file < 0 && solib_search_path != NULL)
found_file = openp (solib_search_path,
1, in_pathname, O_RDONLY, 0, &temp_pathname);
+
+ /* If not found, next search the solib_search_path (if any) for the
+ basename only (ignoring the path). This is to allow reading solibs
+ from a path that doesn't end in, say, /lib. */
+ if (found_file < 0 && solib_search_path != NULL)
+ found_file = openp (solib_search_path,
+ 1, lbasename (in_pathname), O_RDONLY, 0,
+ &temp_pathname);
/* If not found, next search the inferior's $PATH environment variable. */
if (found_file < 0 && solib_search_path != NULL)
--
Orjan Friberg
Axis Communications AB
next prev parent reply other threads:[~2001-11-27 15:03 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <3BEAA3A0.586B3046@axis.com>
[not found] ` <20011108110955.A12240@nevyn.them.org>
2001-11-06 10:49 ` Cross solib support; continued Orjan Friberg
2001-11-06 11:57 ` Kevin Buettner
2001-11-27 7:03 ` Orjan Friberg [this message]
2001-11-14 12:49 ` [RFC]: Solib search (Was: Re: Cross solib support; continued) Orjan Friberg
2001-11-27 7:12 ` Daniel Jacobowitz
2001-11-14 12:59 ` Daniel Jacobowitz
2001-11-14 13:21 ` Orjan Friberg
2001-11-14 13:53 ` Daniel Jacobowitz
2001-11-14 18:20 ` Orjan Friberg
2001-11-27 10:26 ` Orjan Friberg
2001-11-27 10:45 ` Daniel Jacobowitz
2001-11-14 18:28 ` Daniel Jacobowitz
2001-11-14 18:33 ` Orjan Friberg
2001-11-27 11:15 ` Orjan Friberg
2001-11-27 11:29 ` Daniel Jacobowitz
2001-11-14 18:55 ` Daniel Jacobowitz
2001-11-16 13:47 ` Orjan Friberg
2001-11-28 1:03 ` Orjan Friberg
2001-11-27 15:44 ` Kevin Buettner
2001-11-15 8:00 ` Daniel Jacobowitz
2001-11-15 9:16 ` Kevin Buettner
2001-11-27 16:00 ` Kevin Buettner
2001-11-27 15:47 ` Daniel Jacobowitz
2001-11-15 8:00 ` Kevin Buettner
2001-11-27 7:43 ` Daniel Jacobowitz
2001-11-27 7:36 ` Orjan Friberg
2001-11-27 8:00 ` Eli Zaretskii
2001-11-14 15:22 ` Eli Zaretskii
2001-11-27 10:16 ` Orjan Friberg
2001-11-14 18:14 ` Orjan Friberg
2001-11-14 20:58 ` Eli Zaretskii
2001-11-27 12:42 ` Eli Zaretskii
2001-11-28 0:55 ` Orjan Friberg
2001-11-16 13:24 ` Orjan Friberg
2001-11-28 2:00 ` Orjan Friberg
2001-11-16 14:02 ` Orjan Friberg
2001-11-17 2:18 ` Eli Zaretskii
2001-11-28 8:37 ` Eli Zaretskii
2001-11-28 9:43 ` Orjan Friberg
2001-11-17 4:03 ` Orjan Friberg
2001-11-17 12:37 ` Eli Zaretskii
2001-11-29 5:52 ` Orjan Friberg
2001-11-19 11:44 ` Orjan Friberg
2001-12-03 17:19 ` Kevin Buettner
2001-12-04 1:35 ` Orjan Friberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3C03AB51.DB27B3D4@axis.com \
--to=orjan.friberg@axis.com \
--cc=drow@mvista.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox