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 Thu, Jan 26, 2006 at 06:30:56PM -0500, Igor Khavkine wrote:
> On 1/26/06, Daniel Jacobowitz <drow@false.org> wrote:
> > On Thu, Jan 26, 2006 at 08:41:46AM -0500, Igor Khavkine wrote:
> 
> > > I'm using GDB to debug some code that uses local variable length
> > > arrays. This feature is available for C as of the C99 standard. GCC
> > > has support for it.
> > >
> > > Sadly, GDB doesn't seem to be smart enough to figure out the size of
> > > the arrays at run time. This leads to things like 'print array[1][2]'
> > > at the GDB prompt not printing the same value as would 'printf("%g\n",
> > > array[1][2])' in the code. This is a problem for multidimensional
> > > arrays especially. Needless to say, this makes the code more difficult
> > > to debug.
> >
> > 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.

-- 
Daniel Jacobowitz
CodeSourcery


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