This is the mail archive of the 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]

Re: Cross solib support; viable at all?

On Nov 7,  3:24pm, Orjan Friberg wrote:

> Sorry for repeating the question, but I thought it might be necessary to
> ask this question on a higher level.

I'm glad you did.  This higher level question is easier to answer.  :)

> My target is running Linux
> 2.4(.12), with shared libraries (glibc 2.2.3-ish), and debugging is done
> via a gdbserver.  I would like gdb to automatically load so-files when
> they are opened, and whatever else might happen when run in a host
> environment.
> Reading the lengthy comment preceding enable_break in solib-svr4.c, I
> understand that gdb must be able to put a breakpoint in the linker to
> intercept the loading and unloading of shared libraries.  This obviously
> becomes a problem when the linker isn't run native.

Actually, it's the dynamic linker that you put a breakpoint in.  This
isn't really too much of a problem since it's possible to set breakpoints
using the remote protocol.

> Besides that, I
> need to tell gdb where it should fetch the libraries from, since it's
> not from /lib.

Yes.  You've identified one of the key points to making it work.

GDB has a command called ``set solib-absolute-prefix'' which must be
set to the path by which GDB can find the libraries on the target.  So,
for example, if the target's shared libraries reside on the host in
/path/to/target/root/lib, you'd use the following GDB command in order
for GDB to properly locate your libraries:

    (gdb) set solib-absolute-prefix /path/to/target/root

Note that the ``lib'' portion of the path is not included in the prefix.

There's a related setting called ``solib-search-path'' which is used to
find libraries which use relative paths.  This setting may be useful
for dealing with dlopen()'d libraries.  (In the testing that I've been
doing, I've only found it necessary to set solib-search-path once.)

> And I'm sure there are more issues to be resolved. 
> Question is, is this viable at all?  I'm thinking the remote protocol
> would need extensions to deal with this.

Yes, it's viable and it works without remote protocol extensions.

> Is there any target that has this functionality yet?  I was thinking
> mips-linux did, but I can't tell for sure from the code (and I don't
> have a machine to try it on).

Yes, mips, sh, and i386 all work.

Another item key to making it work is to use solib-svr4.o and make
sure that your have a "link map offset fetcher" defined for your target.
See mips_linux_svr4_fetch_link_map_offsets() for an example.  Simply
put, this function is used to provide solib-svr4.c with certain key
offsets for your dynamic loader.


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