Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Steve Kreyer <steve.kreyer@web.de>
To: gdb@sourceware.org
Subject: Using dlopen and remote debugging
Date: Mon, 25 Feb 2008 12:15:00 -0000	[thread overview]
Message-ID: <1015843957@web.de> (raw)

Hi,

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 libtest.so
  $ /opt/sh4-linux-uclibc/bin/sh4-linux-uclibc-gdb a.out
  (gdb) set solib-search-path /home/skreyer
  (gdb) target remote 192.168.1.201:1234
  Remote debugging using 192.168.1.201:1234
  (gdb) b main
  Breakpoint 1 at 0x400608: file test2.c, line 12.
  (gdb) c
  Continuing.

  Breakpoint 1, main () at test2.c:12
  12 lib_handle = dlopen("/libtest.so", 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:
test2.c:
  #include <dlfcn.h>
  #include <stdio.h>

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

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

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

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

    dlclose(lib_handle);

    return 0;
  }
libtest.c:
  #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?

TIA,
Steve
_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000066


             reply	other threads:[~2008-02-25 12:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-25 12:15 Steve Kreyer [this message]
2008-02-25 13:30 ` Dr. Rolf Jansen
2008-02-25 13:55   ` Daniel Jacobowitz
2008-02-25 14:23     ` Dr. Rolf Jansen
2008-02-25 13:32 ` Daniel Jacobowitz
2008-02-25 14:33 steve.kreyer
2008-02-25 16:33 ` Daniel Jacobowitz
2008-02-25 19:29 Steve Kreyer
2008-02-27  1:23 ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1015843957@web.de \
    --to=steve.kreyer@web.de \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox