This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
RE: Print variable with gdb??
- From: "Dave Korn" <dave dot korn at artimi dot com>
- To: "'JS'" <fedevaps at yahoo dot dk>
- Cc: <gdb at sources dot redhat dot com>
- Date: Wed, 30 Mar 2005 11:21:25 +0100
- Subject: RE: Print variable with 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....