Aurelien Jarno writes: > > Thomas Themel a écrit : > > Package: libc6-dbg > > Version: 2.11.2-2 > > Severity: important > > > > Hi, > > > > I'd like to point out that there is zero documentation telling you what l= > > ibc6-dbg > > is supposed to be useful for. The only thing that it installs in /usr/sha= [...] > > There is nothing to do, gdb use them by default, like the zillions of > -dbg packages that are already in the archive.
If that's what's supposed to happen, it's a long way from working. Let me show you what the reality looks like, using an actual typescript of an attempted debugging session, with added commentary in [brackets]: Script started on Wed Sep 1 18:50:32 2010 $ dpkg -l libc6-dbg Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad) ||/ Name Version Description +++-==============-==============-============================================ ii libc6-dbg 2.7-18lenny4 GNU C Library: Libraries with debugging symb [the following is a minimally interesting demo program] $ cat x.c #include <stdio.h> #include <unistd.h> #include <pwd.h> int main(void) { printf("%s %d\n", getpwuid(getuid())->pw_name, getuid()); return 0; } $ gcc -g x.c -o x [it was compiled and linked by a command with -g so it should be debuggable, right?] $ gdb x 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 "powerpc-linux-gnu"... (gdb) b getpwuid Breakpoint 1 at 0x100008a0 (gdb) r Breakpoint 1, 0x0ff27404 in getpwuid () from /lib/libc.so.6 [breakpoint was hit, libc6-dbg is installed, I should be able to use the debugger to poke around in getpwuid's guts from here. I'll start by listing it] (gdb) list 1 #include <stdio.h> 2 #include <unistd.h> 3 #include <pwd.h> 4 5 int main(void) 6 { 7 printf("%s %d\n", getpwuid(getuid())->pw_name, getuid()); 8 return 0; 9 } [silly debugger, I wanted getpwuid to be listed] (gdb) list getpwuid No line number known for getpwuid. [what? libc6-dbg was supposed to provide that information. I'll try to outsmart it by specifying an exact address] (gdb) list *0xff27404 No source file for address 0xff27404. [that didn't work either. oh well] (gdb) quit [look at this: LD_LIBRARY_PATH=/usr/lib/debug does help a little] $ LD_LIBRARY_PATH=/usr/lib/debug gdb x 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 "powerpc-linux-gnu"... (gdb) b getpwuid Breakpoint 1 at 0x100008a0 (gdb) r Breakpoint 1, getpwuid (uid=1000) at ../nss/getXXbyYY.c:98 98 ../nss/getXXbyYY.c: No such file or directory. in ../nss/getXXbyYY.c (gdb) list 93 in ../nss/getXXbyYY.c [it now knows what file and line number to look in, but it apparently expects me to have glibc source unpacked in the parent directory of the directory where I am debugging my own program. well I'll play along, maybe I can just symlink it] (gdb) quit $ ln -s /tmp/glibc-2.1/glibc-2.1/nss .. ln: creating symbolic link `../nss': Permission denied [oops, I'm doing this in my home directory, so ../nss would be /home/nss, and I don't have permission to create that.] [by the way, where you're supposed to put the source so that gdb can find it is one of those things that should be in the libc6-dbg documentation if anyone cared to write it. And expecting it to be found in .. is not really user-friendly] $ LD_LIBRARY_PATH=/usr/lib/debug gdb x 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 "powerpc-linux-gnu"... (gdb) b getpwuid Breakpoint 1 at 0x100008a0 (gdb) r Breakpoint 1, getpwuid (uid=1000) at ../nss/getXXbyYY.c:98 98 ../nss/getXXbyYY.c: No such file or directory. in ../nss/getXXbyYY.c [if the above failures didn't cause me to give up (and why wouldn't they?) then I might read enough gdb documentation to find out about the "directory" command] (gdb) directory /tmp/glibc-2.7/glibc-2.7 (gdb) list 93 ../nss/getXXbyYY.c: No such file or directory. in ../nss/getXXbyYY.c [nope, not good enough. I have to actually tell it where the nss directory is. I had already done cd /tmp;apt-get source glibc] (gdb) directory /tmp/glibc-2.7/glibc-2.7/nss [which means I'll have to repeat that command once for each subdirectory of the glibc source that contains a function I'm interested in. annoying!] (gdb) list 93 #ifdef NEED_H_ERRNO 94 int h_errno_tmp = 0; 95 #endif 96 97 /* Get lock. */ 98 __libc_lock_lock (lock); 99 100 if (buffer == NULL) 101 { 102 buffer_size = BUFLEN; [finally I got my listing. now if this was a real debugging situation I'd be looking for more than that. I'll try single-stepping through it] (gdb) f #0 getpwuid (uid=1000) at ../nss/getXXbyYY.c:98 98 __libc_lock_lock (lock); (gdb) n 89 { (gdb) 98 __libc_lock_lock (lock); (gdb) 89 { (gdb) 98 __libc_lock_lock (lock); (gdb) 100 if (buffer == NULL) (gdb) 102 buffer_size = BUFLEN; (gdb) 103 buffer = (char *) malloc (buffer_size); (gdb) 102 buffer_size = BUFLEN; (gdb) 103 buffer = (char *) malloc (buffer_size); (gdb) 116 while (buffer != NULL (gdb) 103 buffer = (char *) malloc (buffer_size); (gdb) quit [Line number sequence: 98,89,98,89,98,100,102,103,102,103,116,103. that's not a debuggable library, it's an optimized library. even after jumping through all the hoops, libc6-dbg is worthless for debugging] $ LD_LIBRARY_PATH=/usr/lib/debug gdb x 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 "powerpc-linux-gnu"... [just for completeness, here's what happened when I tried to examine the other libc functions called by my demo program] (gdb) b getuid Breakpoint 1 at 0x100008c0 (gdb) b printf Breakpoint 2 at 0x100008b0 (gdb) r Breakpoint 1, 0x0ff2a0c0 in getuid () from /usr/lib/debug/libc.so.6 (gdb) list 1 #include <stdio.h> 2 #include <unistd.h> 3 #include <pwd.h> 4 5 int main(void) 6 { 7 printf("%s %d\n", getpwuid(getuid())->pw_name, getuid()); 8 return 0; 9 } (gdb) list getuid No line number known for getuid. [as a bare syscall, getuid is inherently undebuggable. I don't know why I can't at least get a filename and line number, even if it only points to a magical __asm__()] (gdb) c Breakpoint 1, 0x0ff2a0c0 in getuid () from /usr/lib/debug/libc.so.6 (gdb) c Breakpoint 2, 0x100008b0 in printf () [judging by the address, gdb has decided to stop on the dynamic linker name-lookup stub for printf instead of passing through that and getting the real address like it did for getpwuid] Current language: auto; currently asm (gdb) list Line number 10 out of range; x.c has 9 lines. (gdb) list printf No line number known for printf. [argh.] (gdb) x/15i $pc 0x100008b0 <printf>: lis r11,4097 0x100008b4 <printf+4>: lwz r11,2756(r11) 0x100008b8 <printf+8>: mtctr r11 0x100008bc <printf+12>: bctr 0x100008c0 <getuid>: lis r11,4097 0x100008c4 <getuid+4>: lwz r11,2760(r11) 0x100008c8 <getuid+8>: mtctr r11 0x100008cc <getuid+12>: bctr 0x100008d0 <getuid+16>: nop 0x100008d4 <getuid+20>: nop 0x100008d8 <getuid+24>: nop 0x100008dc <getuid+28>: nop 0x100008e0 <getuid+32>: lis r12,4097 0x100008e4 <getuid+36>: addis r11,r11,-4096 0x100008e8 <getuid+40>: lwz r0,2736(r12) (gdb) stepi 0x100008b4 in printf () (gdb) 0x100008b8 in printf () [...several more stepi's snipped...] 0x48015114 in _dl_runtime_resolve () from /lib/ld.so.1 (gdb) 0x48015118 in _dl_runtime_resolve () from /lib/ld.so.1 [well, now it's resolving it. maybe if I let it continue it'll stop when it hits the actual entry point of printf] (gdb) c pacman 1000 Program exited normally. [sigh] (gdb) quit Script done on Wed Sep 1 18:56:39 2010 In summary, we've taken a lot of steps backward since the time when you could link with -lc_g and it would Just Work. Some of the above may be bugs in gdb. Some of the above may even be PPC-specific bugs in either gdb or glibc. But I have no idea how much of it is user error, since as a user I have zero documentation telling me how I'm supposed to use this great new form of "debugging" library. And seriously, the whole exercise is pointless if the "debugging" library is not compiled -O0. -- Alan Curry -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org