bug v gdb?

Filip Krejci krejcif na gmail.com
Úterý Únor 27 08:56:40 CET 2007



 >> Hmm, tak to asi mam moc "stare" gdb.
 >
 > Můžu vás ubezpečit, že to funguje i s GDB 4.16 a GCC 2.7.2.1 (takovou
 > vykopávku jsem vyhledal!). Prostě hledejte chybu na svém přijímači.

Tak to ja jsem zase vyhledal cerstvou verzi gcc a ta uz to nedela


> To jsou divná hausnumera.
> 
> Co vypíše "p rec->id"? "p *rec"? "p rec" a "p &(rec->id)"?
> A co "x/3x rec"? (Tj. je to blbě v paměti, nebo to jen gdb blbě ukazuje?)

gdb to blbe ukazuje (imho se kouka na jine misto do pameti nez ma, proto 
ta hausnumera), program se chova spravne.

 > Jak vypadá zkompilovaný kód ("disassemble main")?

 >> $ gcc --version 

gcc (GCC) 3.3.5 (Debian 1:3.3.5-13)
 >> $ gcc -g test.c 
                            >> $ gdb a.out 
                                                      GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain 
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
Using host libthread_db library "/lib/tls/libthread_db.so.1".
(gdb) disassemble main
Dump of assembler code for function main:
0x08048384 <main+0>:    push   %ebp
0x08048385 <main+1>:    mov    %esp,%ebp
0x08048387 <main+3>:    sub    $0x18,%esp
0x0804838a <main+6>:    and    $0xfffffff0,%esp
0x0804838d <main+9>:    mov    $0x0,%eax
0x08048392 <main+14>:   sub    %eax,%esp
0x08048394 <main+16>:   movl   $0x1,0x4(%esp)
0x0804839c <main+24>:   movl   $0xc,(%esp)
0x080483a3 <main+31>:   call   0x80482b0 <calloc na plt>
0x080483a8 <main+36>:   mov    %eax,0xfffffffc(%ebp)
0x080483ab <main+39>:   mov    0xfffffffc(%ebp),%eax
0x080483ae <main+42>:   movl   $0x2710,0x4(%eax)
0x080483b5 <main+49>:   movl   $0x0,0x8(%eax)
0x080483bc <main+56>:   mov    $0x0,%eax
0x080483c1 <main+61>:   leave
0x080483c2 <main+62>:   ret
End of assembler dump.
(gdb)

 >> $ /usr/local/bin/gcc --version 

gcc (GCC) 4.1.2
 >> $ /usr/local/bin/gcc -g test.c 
                            >> $ gdb a.out 

GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain 
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
Using host libthread_db library "/lib/tls/libthread_db.so.1".
(gdb) disassemble main
Dump of assembler code for function main:
0x08048364 <main+0>:    lea    0x4(%esp),%ecx
0x08048368 <main+4>:    and    $0xfffffff0,%esp
0x0804836b <main+7>:    pushl  0xfffffffc(%ecx)
0x0804836e <main+10>:   push   %ebp
0x0804836f <main+11>:   mov    %esp,%ebp
0x08048371 <main+13>:   push   %ecx
0x08048372 <main+14>:   sub    $0x24,%esp
0x08048375 <main+17>:   movl   $0x1,0x4(%esp)
0x0804837d <main+25>:   movl   $0xc,(%esp)
0x08048384 <main+32>:   call   0x80482b0 <calloc na plt>
0x08048389 <main+37>:   mov    %eax,0xfffffff8(%ebp)
0x0804838c <main+40>:   mov    0xfffffff8(%ebp),%eax
0x0804838f <main+43>:   movl   $0x2710,0x4(%eax)
0x08048396 <main+50>:   movl   $0x0,0x8(%eax)
0x0804839d <main+57>:   mov    $0x0,%eax
0x080483a2 <main+62>:   add    $0x24,%esp
0x080483a5 <main+65>:   pop    %ecx
0x080483a6 <main+66>:   pop    %ebp
0x080483a7 <main+67>:   lea    0xfffffffc(%ecx),%esp
0x080483aa <main+70>:   ret
End of assembler dump.
(gdb)




  >> $ gcc --version 

gcc (GCC) 3.3.5 (Debian 1:3.3.5-13)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  >> $ gcc -gstabs test.c 

  >> $ objdump --stabs a.out | grep rec_t 

189    LSYM   0      0      00000000 5396 
rec_t:t(1,1)=(1,2)=s12d:(0,2),0,8;id:(0,7),32,64;;
  >> $ /usr/local/bin/gcc --version 

gcc (GCC) 4.1.2
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  >> $ /usr/local/bin/gcc -gstabs test.c 

  >> $ objdump --stabs a.out | grep rec_t 
                            158    LSYM   0      0      00000000 4912 
rec_t:t(0,16)=(0,17)=s12d:(0,2),0,8;id:(0,7),32,64;;



-- 
Filip Krejci <krejcif na gmail.com>

It's spelled Linux, but it's pronounced `Not Windows'
It's spelled Windows, but it's pronounced `Aieeeeeeee!'


Další informace o konferenci Linux