Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Re: interesting solib-absolute-prefix problem
@ 2003-12-03 22:33 Michael Elizabeth Chastain
  2003-12-03 22:53 ` Kris Warkentin
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Elizabeth Chastain @ 2003-12-03 22:33 UTC (permalink / raw)
  To: gdb, kevinb, kewarken

Ummm, hit me with a clue-stick if I am missing the point,
but it looks like Kris's desire is to have solib-absolute-prefix=""
be a meaningful value, but gdb already uses that for something else.
And we don't want to get those semantics by accident.

Can you kludge it by setting solib-absolute-prefix="/."?

I agree with Kevin, I don't like kludges where gdb says
"might as well try this".  The risk is that it will bogusly
succeed on some other system.

Michael C


^ permalink raw reply	[flat|nested] 7+ messages in thread
* interesting solib-absolute-prefix problem
@ 2003-12-03 19:47 Kris Warkentin
  2003-12-03 20:35 ` Kevin Buettner
  0 siblings, 1 reply; 7+ messages in thread
From: Kris Warkentin @ 2003-12-03 19:47 UTC (permalink / raw)
  To: Gdb@Sources.Redhat.Com

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.  */



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-12-03 22:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-03 22:33 interesting solib-absolute-prefix problem Michael Elizabeth Chastain
2003-12-03 22:53 ` Kris Warkentin
  -- strict thread matches above, loose matches on Subject: below --
2003-12-03 19:47 Kris Warkentin
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox