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]

c++ member arrays with variable size


Hello,

I recently was doing some debugging, and came across
something new (to me). When debugging routines with
arrays that are declared with variable bounds i found
that GDB is not able to "see" them.

For example

#include <iostream>

void foo(unsigned int size);

int main()
{
	foo(3);
}

void foo(unsigned int size)
{
	char bar[size];
	int i=1;
	
	if(!size)
		return;

	std::cerr << bar[0] << std::endl;
}

upon placing a breakpoint on the std::cerr line, and
using "info locals" GDB wont show up the bar variable,
nor does trying to print bar work, it claims its not a
variable 'no symbol "bar" in current context'

Is it possible to identify these in GDB, or
alternatively how else can I view these arrays in the
debugger, short of rewriting it?

Thanks.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


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