From: "Kris Warkentin" <kewarken@qnx.com>
To: "Gdb@Sources.Redhat.Com" <gdb@sources.redhat.com>
Subject: interesting solib-absolute-prefix problem
Date: Wed, 03 Dec 2003 19:47:00 -0000 [thread overview]
Message-ID: <064801c3b9d6$5de8e5b0$0202040a@catdog> (raw)
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. */
next reply other threads:[~2003-12-03 19:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-03 19:47 Kris Warkentin [this message]
2003-12-03 20:35 ` Kevin Buettner
2003-12-03 21:20 ` Kris Warkentin
2003-12-03 21:26 ` Daniel Jacobowitz
2003-12-03 21:30 ` Kris Warkentin
2003-12-03 22:33 Michael Elizabeth Chastain
2003-12-03 22:53 ` Kris Warkentin
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='064801c3b9d6$5de8e5b0$0202040a@catdog' \
--to=kewarken@qnx.com \
--cc=gdb@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