Make sym-file.exp work with remote targets and hosts.
authorPedro Alves <palves@redhat.com>
Mon, 14 Apr 2014 16:23:55 +0000 (17:23 +0100)
committerPedro Alves <palves@redhat.com>
Tue, 15 Apr 2014 11:59:12 +0000 (12:59 +0100)
commit2d1baf521e08bc390d604aaf1326347cc130ce1f
treeded0acfed3bbb5d062867e12eec6767536d297f2
parent7dd6df0171796757f404a549c76f0d9b9192c849
Make sym-file.exp work with remote targets and hosts.

The main issue here is that this test passes the host's absolute path
to the library to load to the "dlopen"-like routine, which doesn't
work when either the target or the host are remote, unless a shared
filesystem has been set up.

Tests that dynamically load a library solve this by dlopen'ing by
basename, and setting rpath to $ORIGIN.  See gdb_compile.

This test doesn't use dlopen, but instead uses its own simple elf
loader.  The fix is to pass this loader the library basename, and
teach it to look up the library by basename in the executable's
directory as well, i.e., assuming/emulating RPATH=$ORIGIN.

Tested on x86_64 Fedora 17, native and gdbserver.

I looked around in the web to figure out Linux's /proc/self/exe
equivalents in other ELF OSs.  I think I covered all relevant, but if
not, I think it'll be simple enough to add more.  (Note the test is
skipped on non-ELF targets.)

Tested on x86_64 Fedora 17, native and gdbserver.

gdb/testsuite/
2014-04-15  Pedro Alves  <palves@redhat.com>

* gdb.base/sym-file-loader.c: Include <limits.h>.
(SELF_LINK): New define.
(get_origin): New function.
(load_shlib): Use it.
* gdb.base/sym-file.exp: Don't early return if the target is
remote.  Use runto_main, and issue fail is that fails.  Use
gdb_load_shlibs.
(shlib_name): Delete.
(lib_so, lib_syms, lib_dlopen): New globals.  Use them throughout.
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/sym-file-loader.c
gdb/testsuite/gdb.base/sym-file.exp