Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Debian User (http://www.linux-archive.org/debian-user/)
-   -   How to use -dbg packages (and specifically libncurses5-dbg) ? (http://www.linux-archive.org/debian-user/427320-how-use-dbg-packages-specifically-libncurses5-dbg.html)

Frédéric Boiteux 09-15-2010 10:23 AM

How to use -dbg packages (and specifically libncurses5-dbg) ?
 
Hello,

I'm trying to debug an own C program which dumps a core, inside libncurses5 library.
I'd like to use gdb to debug my program, and so I've installed -dbg packages :
libc6-dbg, libncurses5-dbg, libstdc++-6.4.3-dbg (on a Debian Lenny system), but if the libc6's
debug package is used by gdb, the libncurses5-dbg seems to be skipped :

> > gdb ecran core.ecran
>
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html> This is free software: you are free
to change and redistribute it. There is NO WARRANTY, to the extent
permitted by law. Type "show copying" and "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...

warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/libncurses.so.5...done.
Loaded symbols for /lib/libncurses.so.5
Reading symbols from /usr/lib/libefence.so.0...done.
Loaded symbols for /usr/lib/libefence.so.0
Reading symbols from /usr/lib/libstdc++.so.6...done.
Loaded symbols for /usr/lib/libstdc++.so.6
Reading symbols from /lib/i686/cmov/libm.so.6...Reading symbols
from /usr/lib/debug/lib/i686/cmov/libm-2.7.so...done. done.
Loaded symbols for /lib/i686/cmov/libm.so.6
Reading symbols from /lib/libgcc_s.so.1...done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /lib/i686/cmov/libc.so.6...Reading symbols
from /usr/lib/debug/lib/i686/cmov/libc-2.7.so...done. done.
Loaded symbols for /lib/i686/cmov/libc.so.6
Reading symbols from /lib/i686/cmov/libdl.so.2...Reading symbols
from /usr/lib/debug/lib/i686/cmov/libdl-2.7.so...done. done.
Loaded symbols for /lib/i686/cmov/libdl.so.2
Reading symbols from /lib/i686/cmov/libpthread.so.0...Reading symbols
from /usr/lib/debug/lib/i686/cmov/libpthread-2.7.so...done. done.
Loaded symbols for /lib/i686/cmov/libpthread.so.0
Reading symbols from /lib/ld-linux.so.2...Reading symbols
from /usr/lib/debug/lib/ld-2.7.so...done. done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /lib/i686/cmov/libnss_files.so.2...Reading symbols
from /usr/lib/debug/lib/i686/cmov/libnss_files-2.7.so...done. done.
Loaded symbols for /lib/i686/cmov/libnss_files.so.2
Reading symbols from /lib/i686/cmov/libnss_dns.so.2...Reading symbols
from /usr/lib/debug/lib/i686/cmov/libnss_dns-2.7.so...done. done.
Loaded symbols for /lib/i686/cmov/libnss_dns.so.2
Reading symbols from /lib/i686/cmov/libresolv.so.2...Reading symbols
from /usr/lib/debug/lib/i686/cmov/libresolv-2.7.so...done. done.
Loaded symbols for /lib/i686/cmov/libresolv.so.2
Core was generated by `ecran -m 8192'.
Program terminated with signal 11, Segmentation fault.
[New process 13064]
#0 0xb76df975 in _nc_freewin () from /lib/libncurses.so.5
(gdb)

Does I have to redo the compilation before to test my program with libncurses5-dbg debug library ?
Or is there something I forgot ?

thanks for any help,
Fred.



--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4C909EB8.7070103@calistel.com">http://lists.debian.org/4C909EB8.7070103@calistel.com

Timo Juhani Lindfors 09-15-2010 10:52 AM

How to use -dbg packages (and specifically libncurses5-dbg) ?
 
Frédéric Boiteux <fboiteux@calistel.com> writes:
> Does I have to redo the compilation before to test my program with
> libncurses5-dbg debug library ?

No. libncurses5-dbg is not a library, it does not even contain
code. It only contains the debugging symbols that were removed from
libncurses5.

At least the following works for me:

0) sudo aptitude install libncursesw5-dbg
1) start nano
2) start gdb
3) shell pidof nano
4) attach <that pid>
5) bt

#0 0x00007f0d65f47ea0 in __read_nocancel () at ../sysdeps/unix/syscall-template.S:82
#1 0x00007f0d6620283a in fifo_push (win=0x8f1f90, result=<value optimized out>, use_meta=<value optimized out>) at /home/csmall/debian/ncurses/ncurses/ncurses/base/lib_getch.c:275
#2 kgetch (win=0x8f1f90, result=<value optimized out>, use_meta=<value optimized out>) at /home/csmall/debian/ncurses/ncurses/ncurses/base/lib_getch.c:669
#3 _nc_wgetch (win=0x8f1f90, result=<value optimized out>, use_meta=<value optimized out>) at /home/csmall/debian/ncurses/ncurses/ncurses/base/lib_getch.c:500
#4 0x00007f0d66202fe7 in wgetch (win=0x8f1f90) at /home/csmall/debian/ncurses/ncurses/ncurses/base/lib_getch.c:630
#5 0x0000000000421f40 in ?? ()
#6 0x0000000000422115 in ?? ()
#7 0x00000000004223ed in ?? ()
#8 0x0000000000422a96 in ?? ()
#9 0x000000000041217d in ?? ()
#10 0x0000000000412d5c in ?? ()
#11 0x00007f0d65ea3c4d in __libc_start_main (main=<value optimized out>, argc=<value optimized out>, ubp_av=<value optimized out>, init=<value optimized out>, fini=<value optimized out>,
rtld_fini=<value optimized out>, stack_end=0x7fff819c90a8) at libc-start.c:228
#12 0x0000000000403789 in ?? ()
#13 0x00007fff819c90a8 in ?? ()
#14 0x000000000000001c in ?? ()
#15 0x0000000000000001 in ?? ()
#16 0x00007fff819ca7f8 in ?? ()
#17 0x0000000000000000 in ?? ()


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 84tylr6zyn.fsf@sauna.l.org">http://lists.debian.org/84tylr6zyn.fsf@sauna.l.org

Frédéric Boiteux 09-15-2010 11:48 AM

How to use -dbg packages (and specifically libncurses5-dbg) ?
 
Hello Timo,

Le 15/09/2010 12:52, Timo Juhani Lindfors a écrit :
> Frédéric Boiteux <fboiteux@calistel.com> writes:
>
>> Does I have to redo the compilation before to test my program with
>> libncurses5-dbg debug library ?
>>
> No. libncurses5-dbg is not a library, it does not even contain
> code. It only contains the debugging symbols that were removed from
> libncurses5.
>
Yes, I'd like to use these debugging symbols, but don't have them
available in my gdb session.

> At least the following works for me:
>
> 0) sudo aptitude install libncursesw5-dbg
> 1) start nano
> 2) start gdb
> 3) shell pidof nano
> 4) attach <that pid>
> 5) bt
>
> #0 0x00007f0d65f47ea0 in __read_nocancel () at ../sysdeps/unix/syscall-template.S:82
> #1 0x00007f0d6620283a in fifo_push (win=0x8f1f90, result=<value optimized out>, use_meta=<value optimized out>) at /home/csmall/debian/ncurses/ncurses/ncurses/base/lib_getch.c:275
> #2 kgetch (win=0x8f1f90, result=<value optimized out>, use_meta=<value optimized out>) at /home/csmall/debian/ncurses/ncurses/ncurses/base/lib_getch.c:669
> #3 _nc_wgetch (win=0x8f1f90, result=<value optimized out>, use_meta=<value optimized out>) at /home/csmall/debian/ncurses/ncurses/ncurses/base/lib_getch.c:500
> #4 0x00007f0d66202fe7 in wgetch (win=0x8f1f90) at /home/csmall/debian/ncurses/ncurses/ncurses/base/lib_getch.c:630
> #5 0x0000000000421f40 in ?? ()
> #6 0x0000000000422115 in ?? ()
> #7 0x00000000004223ed in ?? ()
> #8 0x0000000000422a96 in ?? ()
> #9 0x000000000041217d in ?? ()
> #10 0x0000000000412d5c in ?? ()
> #11 0x00007f0d65ea3c4d in __libc_start_main (main=<value optimized out>, argc=<value optimized out>, ubp_av=<value optimized out>, init=<value optimized out>, fini=<value optimized out>,
> rtld_fini=<value optimized out>, stack_end=0x7fff819c90a8) at libc-start.c:228
> #12 0x0000000000403789 in ?? ()
> #13 0x00007fff819c90a8 in ?? ()
> #14 0x000000000000001c in ?? ()
> #15 0x0000000000000001 in ?? ()
> #16 0x00007fff819ca7f8 in ?? ()
> #17 0x0000000000000000 in ?? ()
>
>
It's what I would like to have, but in my gdb session, the symbols /
data aren't available. When you start your gdb, do you have some info
about gdb loading libncurses5 debugging symbols ?

regards,
Fred.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4C90B291.5060506@calistel.com">http://lists.debian.org/4C90B291.5060506@calistel.com

Timo Juhani Lindfors 09-15-2010 11:55 AM

How to use -dbg packages (and specifically libncurses5-dbg) ?
 
Frédéric Boiteux <fboiteux@calistel.com> writes:
> It's what I would like to have, but in my gdb session, the symbols /
> data aren't available. When you start your gdb, do you have some info
> about gdb loading libncurses5 debugging symbols ?


(gdb) shell pidof nano
23506
(gdb) attach 23506
Attaching to process 23506
Reading symbols from /bin/nano...(no debugging symbols found)...done.
Reading symbols from /lib/libncursesw.so.5...Reading symbols from /usr/lib/debug/lib/libncursesw.so.5.7...done.
(no debugging symbols found)...done.
Loaded symbols for /lib/libncursesw.so.5
Reading symbols from /lib/libc.so.6...Reading symbols from /usr/lib/debug/lib/libc-2.11.2.so...done.
(no debugging symbols found)...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/libdl.so.2...Reading symbols from /usr/lib/debug/lib/libdl-2.11.2.so...done.
(no debugging symbols found)...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib64/ld-linux-x86-64.so.2...Reading symbols from /usr/lib/debug/lib/ld-2.11.2.so...done.
(no debugging symbols found)...done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
0x00007f0d65f47ea0 in __read_nocancel () at ../sysdeps/unix/syscall-template.S:82
82 ../sysdeps/unix/syscall-template.S: No such file or directory.
in ../sysdeps/unix/syscall-template.S
Current language: auto
The current source language is "auto; currently asm".


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 84pqwf6x17.fsf@sauna.l.org">http://lists.debian.org/84pqwf6x17.fsf@sauna.l.org

Sven Joachim 09-15-2010 11:55 AM

How to use -dbg packages (and specifically libncurses5-dbg) ?
 
On 2010-09-15 12:23 +0200, Frédéric Boiteux wrote:

> I'm trying to debug an own C program which dumps a core, inside libncurses5 library.
> I'd like to use gdb to debug my program, and so I've installed -dbg packages :
> libc6-dbg, libncurses5-dbg, libstdc++-6.4.3-dbg (on a Debian Lenny system), but if the libc6's
> debug package is used by gdb, the libncurses5-dbg seems to be skipped :
> [...]
>
> Does I have to redo the compilation before to test my program with libncurses5-dbg debug library ?

No, but you have to set LD_LIBRARY_PATH=/usr/lib/debug so that the
debug version of libncurses5 is picked up.

> Or is there something I forgot ?

Not really, the problem is that libncurses5-dbg ships a special debug
version of the library and no detached debugging symbols, unlike other
-dbg packages. This is fixed in Squeeze, though.

Sven


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 87fwxbmd9u.fsf@turtle.gmx.de">http://lists.debian.org/87fwxbmd9u.fsf@turtle.gmx.de

Sven Joachim 09-15-2010 12:03 PM

How to use -dbg packages (and specifically libncurses5-dbg) ?
 
On 2010-09-15 12:52 +0200, Timo Juhani Lindfors wrote:

> Frédéric Boiteux <fboiteux@calistel.com> writes:
>> Does I have to redo the compilation before to test my program with
>> libncurses5-dbg debug library ?
>
> No. libncurses5-dbg is not a library, it does not even contain
> code.

This is wrong.

> It only contains the debugging symbols that were removed from
> libncurses5.

Again wrong, in Lenny it does _not_ contain debugging symbols (but it
does in Squeeze). In both Lenny and Squeeze it contains a special
version of the library built with features that help debugging
(i.e. it's configured with "--with-trace").

> At least the following works for me:
>
> 0) sudo aptitude install libncursesw5-dbg
> 1) start nano
> 2) start gdb
> 3) shell pidof nano
> 4) attach <that pid>
> 5) bt

Will only work in Squeeze, in Lenny you need to set
LD_LIBRARY_PATH=/usr/lib/debug for that to be useful.

Sven


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 877hinmcxs.fsf@turtle.gmx.de">http://lists.debian.org/877hinmcxs.fsf@turtle.gmx.de

Frédéric Boiteux 09-15-2010 12:06 PM

How to use -dbg packages (and specifically libncurses5-dbg) ?
 
Le 15/09/2010 13:55, Timo Juhani Lindfors a écrit :
> (gdb) shell pidof nano
> 23506
> (gdb) attach 23506
> Attaching to process 23506
> Reading symbols from /bin/nano...(no debugging symbols found)...done.
> Reading symbols from /lib/libncursesw.so.5...Reading symbols from /usr/lib/debug/lib/libncursesw.so.5.7...done.
> (no debugging symbols found)...done.
> Loaded symbols for /lib/libncursesw.so.5
> Reading symbols from /lib/libc.so.6...Reading symbols from /usr/lib/debug/lib/libc-2.11.2.so...done.
> (no debugging symbols found)...done.
> Loaded symbols for /lib/libc.so.6
> Reading symbols from /lib/libdl.so.2...Reading symbols from /usr/lib/debug/lib/libdl-2.11.2.so...done.
> (no debugging symbols found)...done.
> Loaded symbols for /lib/libdl.so.2
> Reading symbols from /lib64/ld-linux-x86-64.so.2...Reading symbols from /usr/lib/debug/lib/ld-2.11.2.so...done.
> (no debugging symbols found)...done.
> Loaded symbols for /lib64/ld-linux-x86-64.so.2
> 0x00007f0d65f47ea0 in __read_nocancel () at ../sysdeps/unix/syscall-template.S:82
> 82 ../sysdeps/unix/syscall-template.S: No such file or directory.
> in ../sysdeps/unix/syscall-template.S
> Current language: auto
> The current source language is "auto; currently asm".
>

Here is what I get with similar commands :

> gdb
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
(gdb) shell pidof nano
22973
(gdb) attach 22973
Attaching to process 22973
Reading symbols from /bin/nano...(no debugging symbols found)...done.
Reading symbols from /lib/libncursesw.so.5...(no debugging symbols
found)...done.
Loaded symbols for /lib/libncursesw.so.5
Reading symbols from /lib/libc.so.6...Reading symbols from
/usr/lib/debug/lib/libc-2.7.so...
(no debugging symbols found)...done.
(no debugging symbols found)...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/libdl.so.2...Reading symbols from
/usr/lib/debug/lib/libdl-2.7.so...
(no debugging symbols found)...done.
(no debugging symbols found)...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/ld-linux-x86-64.so.2...Reading symbols from
/usr/lib/debug/lib/ld-2.7.so...
(no debugging symbols found)...done.
(no debugging symbols found)...done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2

(no debugging symbols found)
0x00007fe6fa4819e0 in __read_nocancel () from /lib/libc.so.6
(gdb)

And I checked that I really have the -dbg packages :

> env COLUMNS=120 dpkg -l |grep curses
ii lib32ncurses5 5.7+20081213-1 shared libraries
for terminal handling (32-bit)
ii libncurses5 5.7+20081213-1 shared libraries
for terminal handling
ii libncurses5-dbg 5.7+20081213-1
debugging/profiling libraries for ncurses
ii libncurses5-dev 5.7+20081213-1 developer's
libraries and docs for ncurses
ii libncursesw5 5.7+20081213-1 shared libraries
for terminal handling (wide character support)
ii libncursesw5-dbg 5.7+20081213-1
debugging/profiling libraries for ncurses
ii libncursesw5-dev 5.7+20081213-1 developer's
libraries for ncursesw
ii mtr 0.73-1 Full screen
ncurses and X11 traceroute tool
ii ncurses-base 5.7+20081213-1 basic terminal
type definitions
ii ncurses-bin 5.7+20081213-1 terminal-related
programs and man pages
ii ncurses-term 5.7+20081213-1 additional
terminal type definitions
ii pinentry-curses 0.7.5-2.1 curses-based PIN
or pass-phrase entry dialog for GnuPG


I tested this on a Debian Lenny system, with amd64 architecture.


Thanks for your help,
Fred.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4C90B6B7.2080000@calistel.com">http://lists.debian.org/4C90B6B7.2080000@calistel.com

Timo Juhani Lindfors 09-15-2010 12:08 PM

How to use -dbg packages (and specifically libncurses5-dbg) ?
 
Sven Joachim <svenjoac@gmx.de> writes:
>> Or is there something I forgot ?
>
> Not really, the problem is that libncurses5-dbg ships a special debug
> version of the library and no detached debugging symbols, unlike other
> -dbg packages. This is fixed in Squeeze, though.

Ah, that explains why it worked for me. I was using squeeze.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 84lj736wfr.fsf@sauna.l.org">http://lists.debian.org/84lj736wfr.fsf@sauna.l.org

Frédéric Boiteux 09-15-2010 12:17 PM

How to use -dbg packages (and specifically libncurses5-dbg) ?
 
Le 15/09/2010 13:55, Sven Joachim a écrit :
> On 2010-09-15 12:23 +0200, Frédéric Boiteux wrote:
>
>
>> I'm trying to debug an own C program which dumps a core, inside libncurses5 library.
>> I'd like to use gdb to debug my program, and so I've installed -dbg packages :
>> libc6-dbg, libncurses5-dbg, libstdc++-6.4.3-dbg (on a Debian Lenny system), but if the libc6's
>> debug package is used by gdb, the libncurses5-dbg seems to be skipped :
>> [...]
>>
>> Does I have to redo the compilation before to test my program with libncurses5-dbg debug library ?
>>
> No, but you have to set LD_LIBRARY_PATH=/usr/lib/debug so that the
> debug version of libncurses5 is picked up.
>
>
Hello Sven,

I've tried :

env LD_LIBRARY_PATH=/usr/lib/debug gdb ecran core.ecran
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu"...

warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/libncurses.so.5...done.
Loaded symbols for /lib/libncurses.so.5
Reading symbols from /usr/lib/libstdc++.so.6...done.
Loaded symbols for /usr/lib/libstdc++.so.6
Reading symbols from /lib/libm.so.6...Reading symbols from
/usr/lib/debug/lib/libm-2.7.so...done.
done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libgcc_s.so.1...Reading symbols from
/usr/lib/debug/lib/libgcc_s.so.1...done.
done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /lib/libc.so.6...Reading symbols from
/usr/lib/debug/lib/libc-2.7.so...done.
done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/libdl.so.2...Reading symbols from
/usr/lib/debug/lib/libdl-2.7.so...done.
done.
…
Core was generated by `ecran -m 8192'.
Program terminated with signal 11, Segmentation fault.
[New process 3025]
#0 0xb7711975 in _nc_freewin () from /lib/libncurses.so.5
(gdb)

And I don't have access to debug symbols .

Do I have to use the LD_LIBRARY_PATH during my program's linking process
(with ld), or do I have to use it with gdb ?

regards,
Fred.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4C90B956.7020407@calistel.com">http://lists.debian.org/4C90B956.7020407@calistel.com

Sven Joachim 09-15-2010 12:52 PM

How to use -dbg packages (and specifically libncurses5-dbg) ?
 
On 2010-09-15 14:17 +0200, Frédéric Boiteux wrote:

> I've tried :
>
> env LD_LIBRARY_PATH=/usr/lib/debug gdb ecran core.ecran

I'm afraid this cannot work because the crashed process that left the
core file around had used the non-debug version of the library for which
no symbols are available anywhere.

> Do I have to use the LD_LIBRARY_PATH during my program's linking process
> (with ld), or do I have to use it with gdb ?

You have to use it before you start your program, e.g.

$ env LD_LIBRARY_PATH=/usr/lib/debug gdb ecran

Specifying it at link time would also be possible, e.g. by linking with
"-rpath=/usr/lib/debug", but don't do this for binaries that you give to
others.

Sven


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 87zkvjkw2j.fsf@turtle.gmx.de">http://lists.debian.org/87zkvjkw2j.fsf@turtle.gmx.de


All times are GMT. The time now is 02:56 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.