Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Print variable with gdb??
@ 2005-03-30  9:19 JS
  2005-03-30  9:28 ` Russell Shaw
  0 siblings, 1 reply; 3+ messages in thread
From: JS @ 2005-03-30  9:19 UTC (permalink / raw)
  To: gdb

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Print variable with gdb??
  2005-03-30  9:19 Print variable with gdb?? JS
@ 2005-03-30  9:28 ` Russell Shaw
  2005-03-30 10:22   ` Dave Korn
  0 siblings, 1 reply; 3+ messages in thread
From: Russell Shaw @ 2005-03-30  9:28 UTC (permalink / raw)
  Cc: gdb

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

Type "start" so it runs to main(). print p should work if
p is in scope.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: Print variable with gdb??
  2005-03-30  9:28 ` Russell Shaw
@ 2005-03-30 10:22   ` Dave Korn
  0 siblings, 0 replies; 3+ messages in thread
From: Dave Korn @ 2005-03-30 10:22 UTC (permalink / raw)
  To: 'JS'; +Cc: gdb

----Original Message----
>From: Russell Shaw
>Sent: 30 March 2005 10:32

> 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
> 
> Type "start" so it runs to main(). print p should work if
> p is in scope.


  Or perhaps p has been optimised away by the compiler?  Be sure and compile
with -O0 so that what you're debugging bears the simplest and most direct
relationship to the source code.


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-03-30 10:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-30  9:19 Print variable with gdb?? JS
2005-03-30  9:28 ` Russell Shaw
2005-03-30 10:22   ` Dave Korn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox