Re: Print variable with gdb??

From: Mark P (not_at_my.real.email)
Date: 03/30/05


Date: Tue, 29 Mar 2005 23:43:06 GMT

JS wrote:
> I have:
>
> int p = 5;
>
> when I debug my code I would like to get a print of p's value therefore I
> start gdb and type:
>
> print p
>
> but then I get an error that the variable does not exists!
>
> Hope someone can help!
>
> JS

You should know that this is off topic and you will likely find more
help in a compiler specific newsgroup.

Two pieces of advice regarding your problem. 1) Make sure p is in scope
when you attempt to print its value, and 2) make sure that you compile
with the -g option to enable debugging.

Mark



Relevant Pages

  • Need help : -O2 flag and GDB
    ... But the problem is when I have to debug the core file, ... I use g++ 3.0.40 and gdb 5.2 on Radhat linux. ... What compiler and GDB version do you suggest? ...
    (comp.lang.cpp)
  • Re: debugging in release mode
    ... I have no doubt that it's a problem of mine and not of the compiler. ... I don't really need optimization ... for the sake of memory space or execution speed. ... shows the differences between the default debug mode and the default release ...
    (microsoft.public.vc.mfc)
  • Re: Whats more important optimisations or debugging?
    ... aiming to make high level debugging as accurate and complete as ... oriented debug chain is appropriate. ... But in either case, barring chip and compiler bugs, the bugs ...
    (comp.arch.embedded)
  • Re: If Statement Variations
    ... You can also get to the help files for the conditional Const statement by typing #Const in any code window and, with the text cursor in or next to it, press F1. ... the & character forces the compiler to use a Long ... it simpler to switch to and from debug and testing and production ...
    (microsoft.public.excel.programming)
  • Re: Output dll bigger with VS 2005
    ... This is the first part of the map file of a debug dll compiled with VS2005 ... For a little more information on the .map files I recommend this article ... Microsoft Windows CE Compiler Team ...
    (microsoft.public.windowsce.embedded.vc)