Hi,

I came accross what I believe is a bug in GDB. I am a bit surprised that
noone seems to have reported it before though.

Here is our config:

OS: PC under Linux 2.2.16 SMP 4 i686 unknown, 
512 Mb of RAM in a NFS cluster

The dev tools were installed directly from Slackware 7.1 and not recompiled hereafter.

>gdb --version
GNU gdb 5.0
Copyright 2000 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 "i386-slackware-linux".

> gcc --version
egcs-2.91.66

I compile my program (a sort of huffman encoder) like this:
>gcc -ggdb3 -Wall codhuff.c -o codhuff


    
then here is a dump of my shell session

wms-lnx05b[3]/> gdb codhuff
GNU gdb 5.0
Copyright 2000 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 "i386-slackware-linux"...
(gdb) b 227
Breakpoint 1 at 0x8048a68: file codhuff.c, line 227.
(gdb) r
Starting program: /rhome/nja/codhuff
Searching for NFS backup files in your HOME directory ... please wait
PLEASE ACTIVATE OR RUN FREQUENTLY clean_nfs IN YOUR WORKING DIRECTORY
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
81 rows in ucs2 file.
Creating the Huffman codes...


Breakpoint 1, Build_Huffman_Tree () at codhuff.c:228
228       memset (weight, 0, 257*sizeof(unsigned int));
(gdb) p *Huff_tree[0]
$1 = {byte = 0, weight = 0, left_ptr = 0x0, right_ptr = 0x0}
(gdb) p *Huff_tree[1]
$2 = {byte = 1, weight = 0, left_ptr = 0x0, right_ptr = 0x0}
(gdb) p *Huff_tree[2]
$3 = {byte = 2, weight = 0, left_ptr = 0x0, right_ptr = 0x0}
(gdb) p *Huff_tree[3]
$4 = {byte = 3, weight = 0, left_ptr = 0x0, right_ptr = 0x0}
(gdb) p *Huff_tree[4]
$5 = {byte = 4, weight = 0, left_ptr = 0x0, right_ptr = 0x0}
(gdb) p *Huff_tree[5]
$6 = {byte = 5, weight = 0, left_ptr = 0x0, right_ptr = 0x0}
(gdb) p *Huff_tree[6]
$7 = {byte = 6, weight = 0, left_ptr = 0x0, right_ptr = 0x0}
(gdb) p *Huff_tree[0]@6
$8 = {{byte = 0, weight = 0, left_ptr = 0x0, right_ptr = 0x0}, {byte = 0,
    weight = 25, left_ptr = 0x1, right_ptr = 0x0}, {byte = 0, weight = 0,
    left_ptr = 0x0, right_ptr = 0x19}, {byte = 2, weight = 0, left_ptr = 0x0,
    right_ptr = 0x0}, {byte = 0, weight = 25, left_ptr = 0x3,
    right_ptr = 0x0}, {byte = 0, weight = 0, left_ptr = 0x0, right_ptr = 0x19}}



So when I display the dereferenced array of pointers element by element,
the result is correct (I initialized the structures).
Wen I display  the same memory area as an array slice, the result is different 
(garbage).
I suppose there is a bug in the display of array slices.

This bug also appears in gdb v 4.18

------------------------------------------------------------------------
Nicolas Janin                                                    Wavecom
Tel: 01 46 29 08 00, poste 781

codhuff.c

huffman.h

lookup.h

us2lite.16

Reply via email to