From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 328 invoked by alias); 3 Dec 2003 19:47:06 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 321 invoked from network); 3 Dec 2003 19:47:05 -0000 Received: from unknown (HELO hub.ott.qnx.com) (209.226.137.76) by sources.redhat.com with SMTP; 3 Dec 2003 19:47:05 -0000 Received: from smtp.ott.qnx.com (smtp.ott.qnx.com [10.0.2.158]) by hub.ott.qnx.com (8.9.3/8.9.3) with ESMTP id OAA07560 for ; Wed, 3 Dec 2003 14:59:46 -0500 Received: from catdog ([10.4.2.2]) by smtp.ott.qnx.com (8.8.8/8.6.12) with SMTP id OAA14788 for ; Wed, 3 Dec 2003 14:47:04 -0500 Message-ID: <064801c3b9d6$5de8e5b0$0202040a@catdog> From: "Kris Warkentin" To: "Gdb@Sources.Redhat.Com" Subject: interesting solib-absolute-prefix problem Date: Wed, 03 Dec 2003 19:47:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-SW-Source: 2003-12/txt/msg00057.txt.bz2 Ah....good old solib_open() and finding shared libraries. Our setup is such that even on self-hosted Neutrino, we still have directories /x86, /mipsle, /armbe, etc. which have a full heirarchy of bin, lib, usr/lib, etc. underneath. We set solib-absolute-prefix to point to these when debugging. On a different host, it might be something like c:/QNXsdk/target/qnx6/ppcbe but the principle is the same. We use solib-absolute-prefix and stuff gets found. Now say I'm debugging a program /home/kewarken/myprog which is linked to /home/kewarken/libmylib.so. Given that the linker fills in /home/kewarken/libmylib.so and this path gets passed to solib_open(), you would think you wouldn't get a misleading error like: Error while mapping shared library sections: /home/kewarken/libmylib.so: No such file or directory. Now it's fairly obvious why this doesn't happen: solib_open uses solib-absolute-prefix and various other things but never actually just tries opening the file. The logic of this is quite apparent. We don't want, for example, /lib/libc.so to get opened on my Solaris system when I'm really looking for /opt/QNXsdk/target/qnx6/shle/lib/libc.so. That would be bad. The problem of course is that having gdb complain that it can't find a file which is clearly there is quite ugly. Note that setting solib-search-path avoids all these problems. Not really great though. You'd think that if the linker says "/some/path/to/libalib.so" that it would be found. One would think that not initializing solib-absolute-prefix when doing native debugging would work but the problem for us is that we need to find /x86/usr/lib/ldqnx.so (our linker) rather than /proc/boot/libc.so since our image builder strips all the section information from binaries and gdb uses the .dynamic section. To make a long story short, I put an 'open() of last resort' in solib_open right at the end where if all else fails, it tries to open the exact path it was given. It would seem to me that this is probably not too dangerous but someone might be able to comment on this better than I. cheers, Kris $ cvs diff -c solib.c Index: solib.c =================================================================== RCS file: /product/tools/gdb/gdb/solib.c,v retrieving revision 1.8 diff -c -r1.8 solib.c *** solib.c 17 Jun 2003 19:21:38 -0000 1.8 --- solib.c 3 Dec 2003 19:25:24 -0000 *************** *** 104,109 **** --- 104,110 ---- int found_file = -1; char *temp_pathname = NULL; char *p = in_pathname; + char *orig = in_pathname; while (*p && !IS_DIR_SEPARATOR (*p)) p++; *************** *** 175,180 **** --- 176,185 ---- if (found_file < 0) found_file = openp (get_in_environ (inferior_environ, "LD_LIBRARY_PATH"), 1, in_pathname, O_RDONLY, 0, &temp_pathname); + + /* If all else fails, at least try the original without any window dressing. */ + if (found_file < 0 && (found_file = open (orig, O_RDONLY, 0)) > -1) + temp_pathname = orig; /* Done. If not found, tough luck. Return found_file and (optionally) found_pathname. */