C99 variable length arrays

Igor Khavkine igor.kh@gmail.com
Fri Jan 27 08:15:00 GMT 2006


On 1/26/06, Daniel Jacobowitz <drow@false.org> wrote:
> On Thu, Jan 26, 2006 at 06:30:56PM -0500, Igor Khavkine wrote:
> > On 1/26/06, Daniel Jacobowitz <drow@false.org> wrote:

> > > The first thing to do is to write a small testcase, and post the
> > > testcase along with the debugging output that your GCC generates
> > > for it.
> >
> > There is a test case already in the GDB bug database (PR 1796, as I
> > mentioned in my first message). What kind of debugging output should I
> > post? Is there an option to make gcc dump the debugging info in human
> > readable form?
>
> Not really - but you can run readelf -wi on the resulting object file.
> I recommend you do this after linking to make sure relocations are
> resolved.

OK. I'm attaching a small test case, vla-bug.c. I compiled the object
with `gcc -g -c vla-bug.c' and the executable with `gcc -g -o vla-bug
vla-bug.c'. I then ran `readelf -wi' on the .o and the executable. I'm
attaching all the relevant files.

Note that I call the function test() with argument 3. This means that
the local variable length array will have size 3. However, when run
under GDB, GDB will think the array is only of size 2 (that's the size
it always seems to assume for VLA's). Unfortunately, I can glimpse
next to nothing from the readelf output. Can you tell whether GCC puts
enough debugging info into the compiled code for GDB to get the size
right at runtime?

Thanks in advance.

Igor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vla-bug.c
Type: text/x-csrc
Size: 91 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb/attachments/20060127/39458874/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vla-bug.o.elf
Type: application/octet-stream
Size: 2334 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb/attachments/20060127/39458874/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vla-bug.elf.gz
Type: application/x-gzip
Size: 5196 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb/attachments/20060127/39458874/attachment-0001.bin>


More information about the Gdb mailing list