From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19340 invoked by alias); 27 Nov 2001 15:03:58 -0000 Mailing-List: contact gdb-patches-help@sourceware.cygnus.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 19294 invoked from network); 27 Nov 2001 15:03:49 -0000 Received: from unknown (HELO miranda.axis.se) (193.13.178.2) by hostedprojects.ges.redhat.com with SMTP; 27 Nov 2001 15:03:49 -0000 Received: from ironmaiden.axis.se (ironmaiden.axis.se [10.13.8.120]) by miranda.axis.se (8.12.1/8.12.1/Debian -2) with ESMTP id fARF3jXX002116; Tue, 27 Nov 2001 16:03:45 +0100 Received: from axis.com (localhost [127.0.0.1]) by ironmaiden.axis.se (8.9.3/8.9.3/Debian 8.9.3-21) with ESMTP id QAA10675; Tue, 27 Nov 2001 16:03:45 +0100 X-Authentication-Warning: ironmaiden.axis.se: Host localhost [127.0.0.1] claimed to be axis.com Message-ID: <3C03AB51.DB27B3D4@axis.com> Date: Wed, 14 Nov 2001 12:49:00 -0000 From: Orjan Friberg Organization: Axis Communications AB X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.2.19 i686) X-Accept-Language: en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com CC: Daniel Jacobowitz Subject: [RFC]: Solib search (Was: Re: Cross solib support; continued) References: <3BEAA3A0.586B3046@axis.com> <20011108110955.A12240@nevyn.them.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2001-11/txt/msg00277.txt.bz2 Message-ID: <20011114124900.9yIunDomWeVbcPVqKKehm-wh23Thgbv-pnf6S9VJP24@z> 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 * 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