This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C99 variable length arrays


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
void test (int x)
{
	int arr[x];
	arr[0] = 1;
}

int main (void)
{
	test (3);
	return 0;
}

Attachment: vla-bug.o.elf
Description: Binary data

Attachment: vla-bug.elf.gz
Description: GNU Zip compressed data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]