[opensuse] Odd behavior when printing a local variable in gdb
I use gdb 6.8.50.20081120-cvs in openSUSE 11.1 x86 in order to debug a C++ program. When entering into a member function (of some C++ class) I cannot print a local variable with the following syntax: (gdb) p n No symbol "n" in current context. using (gdb) p 'n' $1 = 110 'n' seems to work. However, debugging in Eclipse Galileo CDT local variables are no longer displayed (when pointing the mouse to one variable in the source code). Thus, it seems that Eclipse is not aware of the new syntax for print function used in gdb. Is there a reason for this behavior of gdb ? -- Dr. Bogdan Cristea http://cristeab.googlepages.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Wednesday 19 August 2009 14:09:30 Bogdan Cristea wrote:
I use gdb 6.8.50.20081120-cvs in openSUSE 11.1 x86 in order to debug a C++ program. When entering into a member function (of some C++ class) I cannot print a local variable with the following syntax:
(gdb) p n No symbol "n" in current context.
using
(gdb) p 'n' $1 = 110 'n'
110 is the ASCII value of the character 'n'. You are not printing a variable here, just a character
seems to work. However, debugging in Eclipse Galileo CDT local variables are no longer displayed (when pointing the mouse to one variable in the source code). Thus, it seems that Eclipse is not aware of the new syntax for print function used in gdb.
Is there a reason for this behavior of gdb ?
Most likely, the variables you are looking at have been optimised out by gcc, so that they really aren't in the current context Anders -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Wednesday 19 August 2009 14:09:30 you wrote:
I use gdb 6.8.50.20081120-cvs in openSUSE 11.1 x86 in order to debug a C++ program. When entering into a member function (of some C++ class) I cannot print a local variable with the following syntax:
(gdb) p n No symbol "n" in current context.
using
(gdb) p 'n' $1 = 110 'n'
seems to work. However, debugging in Eclipse Galileo CDT local variables are no longer displayed (when pointing the mouse to one variable in the source code). Thus, it seems that Eclipse is not aware of the new syntax for print function used in gdb.
Is there a reason for this behavior of gdb ?
Replying to myself: there is no new syntax for print function in gdb. Actually there seems to be a bug in gcc4.3 compiler not allowing to print local variables from C++ constructors -- Dr. Bogdan Cristea http://cristeab.googlepages.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Wed, 19 Aug 2009 14:52:18 +0200, you wrote:
Actually there seems to be a bug in gcc4.3 compiler not allowing to print local variables from C++ constructors
To rule out that the compiler has simply optimized out the variable compile the code with -O0 which will disable all optimizations. If the variable is still invisible to gdb you should file a bug for gcc (see the opensuse wiki for how to report gcc bugs). Philipp -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Thursday 20 August 2009 00:35:51 Philipp Thomas wrote:
On Wed, 19 Aug 2009 14:52:18 +0200, you wrote:
Actually there seems to be a bug in gcc4.3 compiler not allowing to print local variables from C++ constructors
To rule out that the compiler has simply optimized out the variable compile the code with -O0 which will disable all optimizations. If the variable is still invisible to gdb you should file a bug for gcc (see the opensuse wiki for how to report gcc bugs).
Philipp
This bug has already been signaled to the gcc team and it seems to be corrected in g++4.4 Bogdan -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (3)
-
Anders Johansson
-
Bogdan Cristea
-
Philipp Thomas