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]
Other format: [Raw text]

Using dlopen and remote debugging


I have the following problem: I would like to debug a program on a remote target. This program loads a shared library with the dlopen call, but if the library is loaded, gdb on host-side doesn't find the appropriate debugging symbols of this library.
I've also tried to make use of the solib-search-path and solib-absolute-path settings but without success. Both, the application and the library, which is loaded via dlopen, are compiled using the -g switch of gcc.
I've issued the following steps:

On target side:
  $ gdbserver foo:1234 a.out

On host side:
  $ sh4-linux-uclibc-gcc -g test2.c -ldl -Wall
  $ sh4-linux-uclibc-gcc -g -shared libtest.c -o
  $ /opt/sh4-linux-uclibc/bin/sh4-linux-uclibc-gdb a.out
  (gdb) set solib-search-path /home/skreyer
  (gdb) target remote
  Remote debugging using
  (gdb) b main
  Breakpoint 1 at 0x400608: file test2.c, line 12.
  (gdb) c

  Breakpoint 1, main () at test2.c:12
  12 lib_handle = dlopen("/", RTLD_NOW);
  (gdb) n
  13 foop = dlsym(lib_handle, "foo");
  (gdb) n
  15 erg = foop(1, 2);
  (gdb) p foo
  No symbol "foo" in current context.

The source code:
  #include <dlfcn.h>
  #include <stdio.h>

  typedef int (*funcp)(int, int);

  int main()
    void *lib_handle;
    funcp foop;
    int erg;

    lib_handle = dlopen("/", RTLD_NOW);
    foop = dlsym(lib_handle, "foo");

    erg = foop(1, 2);
    printf("%d\n", erg);


    return 0;
  #include <stdio.h>

  int foo(int a, int b)
    int erg;

    erg = a + b;
    return erg;

Can someone give me a hint on this issue?

Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!

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