This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Question regarding missing local variables in gdb
- To: gdb at sources dot redhat dot com, dsw at mbay dot net
- Subject: Question regarding missing local variables in gdb
- From: Donna S Womble <dsw at mbay dot net>
- Date: Wed, 30 May 2001 14:44:32 -0700
Hello,
Please forgive my naivete... I have generated a very simple C++ program
to outline my question/problem. When I "run" the following with gdb,
and have a breakpoint at line 11 (cout << ...), it shows that I have
absolutely no local variables when I use "info locals".
#include <iostream>
int main()
{
for (int i(0); i < 10; i++)
{
double foo(100.);
for (int j(10); j < 20; j++)
{
double goo(i*1000.);
double hoo(j*500.);
cout << i << "\t" << j << "\t" << goo << "\t" << hoo << endl;
}
}
return 0;
}
Shouldn't one be able to *see* the variable "i" as a local from within
the scope of the i-loop (e.g. at line 6 = double foo(100.); )???
Likewise for "j", "goo", and "hoo" inside the j-loop.
Strangely enough, if I define foo, goo, and hoo as doubles before the
"i" loop, then I can *see* ALL the variables (including i and j) with a
breakpoint at line 13 (same "cout << ...") as in the code (modified)
below:
#include <iostream>
int main()
{
double foo, goo, hoo;
for (int i(0); i < 10; i++)
{
foo = 100.;
int j;
for ( j = 10 ; j < 20; j++)
{
goo = i*1000.;
hoo = j*500.;
cout << i << "\t" << j << "\t" << goo << "\t" << hoo << endl;
}
}
return 0;
}
I am compiling it with NO optimization using:
g++ -g -O0 -o test_program test_program.cpp
Am I missing something really simple here??? Please help.
Thanks, Donna Womble.
P.S. I am using GNU gdb version 5.0 with gcc version 2.96 (20000731) on
RedHat Linux 7.0