This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Why does solib_open do what it does?


On Jun 19,  8:24am, Kris Warkentin wrote:

> > > In Linux it's the case for all searched-for objects, as far as I know -
> > > anything found via search paths, LD_LIBRARY_PATH, DT_RUNPATH, DT_RPATH,
> > > etc. will either be an absolute path or else contain slashes and be
> > > relative to the current directory.  If it's not true for dlopen'd
> > > objects, well, there's no way to know where the app had chdir'd to when
> > > it loaded them.
> > >
> > > Do you know offhand when it's not true for GNU/Linux?
> >
> > No, I just recall that, several years ago when I worked on this code,
> > it was not always true.
> 
> Okay gentlemen, all kidding aside, what do we do?  At the bare minimum I
> believe the test
> 
>   /* If not found, next search the inferior's $PATH environment variable. */
>   if (found_file < 0 && solib_search_path != NULL)
> 
> should be just:
> 
> if (found_file < 0).
> 
> We can always make a decision about removing the PATH and LD_LIBRARY_PATH
> checks later.

Okay, I've come to a decision.

It's still not clear to me if the PATH and LD_LIBRARY_PATH searches
are needed for natives.  Either they're not needed or nobody's noticed
that some previously available functionality (prior to Nov 21, 2000)
is now missing.  I do know, however, that we definitely don't want to
do these searches for (most) remote targets.  In light of Michael's
remarks, I'm now inclined to be more cautious about removing these
searches than I was originally.

Further, if you're debugging a remote target, you'd better have
solib-absolute-prefix set, or things will almost certainly go wrong. 
To the best of my knowledge, when you're debugging a native target,
you never set solib-absolute-prefix, so the fact that this is set or
not gives us a cheap, but effective way to determine whether the
intent is to run on a native target or not.

Actually, it's better than that.  Something that I occassionally do is
to run against a "native" rda or gdb server where I don't set
solib-absolute-prefix.  Doing things in this fashion will make search
algorithm for this kind of "remote" (which is really a native
disguised as a remote) target identical to running a native and that
is precisely what's desired.

So...  I'd like to see the checks preceding the PATH and LD_LIBRARY_PATH
searches changed from:

  if (found_file < 0 && solib_search_path != NULL)

to:

  if (found_file < 0 && solib_absolute_prefix == NULL)

Kris, I believe you volunteered to make the necessary changes.  Would
you like to do the honors?  BTW, your proposed comment changes look
good too.  Consider these changes preapproved, but do make sure you
post the patch that you end up committing.

Thanks,

Kevin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]