Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Debugging a shared library through gdbserver
@ 2006-03-15  3:44 Nai-Hsien
  2006-03-15  4:16 ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Nai-Hsien @ 2006-03-15  3:44 UTC (permalink / raw)
  To: gdb

I am debugging a shared library made by myself through gdbserver. After
searching the mail list,
I think the gdb can be used to debug a shared library. However, when I debug
my shared library by
following steps, I got error to step through the source code
(user_str_to_id()) in my shared library.
Could anybody instruct me to do it?

Thank you very much
Dennis

# load my executable file
(gdb) add-symbol-file console
add symbol table from file "console" at
# load my shared library
(gdb) add-symbol-file lib/libmylib.so.1.0.1
add symbol table from file "lib/libmylib.so.1.0.1" at
(gdb) b clih_login
Breakpoint 1 at 0x10016238: file sysui.c, line 289.
(gdb) c

Breakpoint 1, clih_login (handle=268700768, argc=2, argv=0x10041840) at
sysui.c:289
(gdb) next
# set a breakpoint in my shared library
(gdb) b user_str_to_id
Breakpoint 2 at 0xb05c: file utility.c, line 418.
# then I got trouble here!!!
(gdb) step
Warning:
Cannot insert breakpoint 2.
Error accessing memory address 0xb05c: Input/output error.

(gdb)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Debugging a shared library through gdbserver
  2006-03-15  3:44 Debugging a shared library through gdbserver Nai-Hsien
@ 2006-03-15  4:16 ` Daniel Jacobowitz
  2006-03-15 12:25   ` Nai-Hsien
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2006-03-15  4:16 UTC (permalink / raw)
  To: Nai-Hsien; +Cc: gdb

On Wed, Mar 15, 2006 at 11:44:01AM +0800, Nai-Hsien wrote:
> # load my executable file
> (gdb) add-symbol-file console
> add symbol table from file "console" at
> # load my shared library
> (gdb) add-symbol-file lib/libmylib.so.1.0.1
> add symbol table from file "lib/libmylib.so.1.0.1" at
> (gdb) b clih_login
> Breakpoint 1 at 0x10016238: file sysui.c, line 289.
> (gdb) c

Why are you doing any of this?  Please tell us where you saw
suggestions to use add-symbol-file in this way, so that we can correct
them.

Please take a look at "set solib-absolute-prefix".  Use that, and
the "file" command, before connecting to gdbserver and everything
should work automatically.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Debugging a shared library through gdbserver
  2006-03-15  4:16 ` Daniel Jacobowitz
@ 2006-03-15 12:25   ` Nai-Hsien
  2006-03-15 16:17     ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Nai-Hsien @ 2006-03-15 12:25 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb

>
> Why are you doing any of this?  Please tell us where you saw
> suggestions to use add-symbol-file in this way, so that we can correct
> them.
>
> Please take a look at "set solib-absolute-prefix".  Use that, and
> the "file" command, before connecting to gdbserver and everything
> should work automatically.
>
> -- 
> Daniel Jacobowitz
> CodeSourcery
>
>
Hi Daniel

Nobody told me to do this. I just learned add-symbol-file from u-boot
document to relocate
program base. I tried some commands in gdb user's manual then I think this
command has result most
close to my expectation. Anyway, this is totally my fault.

I tried to follow your hint, shown as blow. Now, I can set a breakpoint in
the shared library and make
the program stop there. However, I still can not see the source code. (I am
using DDD with gdb.)
Am I still doing something wrong?

Thank you
Dennis

# my shared library is in lib/
(gdb) set solib-absolute-prefix lib
(gdb) file console
(gdb) target remote 10.0.2.3:2001
0x0fd39fac in ?? ()
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
(gdb) b user_str_to_id
Breakpoint 1 at 0x10040040
(gdb) c

Breakpoint 1, 0x10040040 in ?? ()
# the program stop here without displaying source code on screen.
(gdb)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Debugging a shared library through gdbserver
  2006-03-15 12:25   ` Nai-Hsien
@ 2006-03-15 16:17     ` Daniel Jacobowitz
  2006-03-16  2:11       ` Nai-Hsien
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2006-03-15 16:17 UTC (permalink / raw)
  To: Nai-Hsien; +Cc: gdb

On Wed, Mar 15, 2006 at 02:18:06PM +0800, Nai-Hsien wrote:
> Nobody told me to do this. I just learned add-symbol-file from u-boot
> document to relocate
> program base. I tried some commands in gdb user's manual then I think this
> command has result most
> close to my expectation. Anyway, this is totally my fault.

You don't need to relocate the program by hand when you're debugging in
userspace.

> I tried to follow your hint, shown as blow. Now, I can set a breakpoint in
> the shared library and make
> the program stop there. However, I still can not see the source code. (I am
> using DDD with gdb.)
> Am I still doing something wrong?
> 
> Thank you
> Dennis
> 
> # my shared library is in lib/
> (gdb) set solib-absolute-prefix lib

That's not what solib-absolute-prefix is for.  You need to point it at
the root of a filesystem image that matches the one running on your
target, so that GDB can open <prefix>/lib/ld.so.1 and
<prefix>/usr/lib/libfoo.so.  I usually use NFS for this.  If you
do that...

> (gdb) file console
> (gdb) target remote 10.0.2.3:2001
> 0x0fd39fac in ?? ()
> warning: Unable to find dynamic linker breakpoint function.
> GDB will be unable to debug shared library initializers
> and track explicitly loaded dynamic code.

This message will go away.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Debugging a shared library through gdbserver
  2006-03-15 16:17     ` Daniel Jacobowitz
@ 2006-03-16  2:11       ` Nai-Hsien
  2006-03-16  3:00         ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Nai-Hsien @ 2006-03-16  2:11 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb

> > 
> > # my shared library is in lib/
> > (gdb) set solib-absolute-prefix lib
> 
> That's not what solib-absolute-prefix is for.  You need to point it at
> the root of a filesystem image that matches the one running on your
> target, so that GDB can open <prefix>/lib/ld.so.1 and
> <prefix>/usr/lib/libfoo.so.  I usually use NFS for this.  If you
> do that...
Unfornately, I am using TFTP to download a RAM disk image to my board and
run it. Is there any other solution for the case?

Thank you
Dennis


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Debugging a shared library through gdbserver
  2006-03-16  2:11       ` Nai-Hsien
@ 2006-03-16  3:00         ` Daniel Jacobowitz
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Jacobowitz @ 2006-03-16  3:00 UTC (permalink / raw)
  To: Nai-Hsien; +Cc: gdb

On Thu, Mar 16, 2006 at 08:52:54AM +0800, Nai-Hsien wrote:
> > > 
> > > # my shared library is in lib/
> > > (gdb) set solib-absolute-prefix lib
> > 
> > That's not what solib-absolute-prefix is for.  You need to point it at
> > the root of a filesystem image that matches the one running on your
> > target, so that GDB can open <prefix>/lib/ld.so.1 and
> > <prefix>/usr/lib/libfoo.so.  I usually use NFS for this.  If you
> > do that...
> Unfornately, I am using TFTP to download a RAM disk image to my board and
> run it. Is there any other solution for the case?

Set up a similar unpacked image on your host, possibly with more debug
symbols.  But use the same layout.

  <prefix>
  <prefix>/lib
  <prefix>/usr/lib

et cetera.


-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-03-16  2:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-15  3:44 Debugging a shared library through gdbserver Nai-Hsien
2006-03-15  4:16 ` Daniel Jacobowitz
2006-03-15 12:25   ` Nai-Hsien
2006-03-15 16:17     ` Daniel Jacobowitz
2006-03-16  2:11       ` Nai-Hsien
2006-03-16  3:00         ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox