This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Still cannot print variable


> From: JS <fedevaps@yahoo.dk>
> Date: Fri, 15 Apr 2005 11:09:09 +0200
> 
> I am still have problems printing a variable. I have this code in a file
> called test.:
> 
> int main()
> {
> 
>         int d = 119;
> 
>         return(0);
> 
> }
> 
> I then compile it like this:
> 
>         gcc -g -Wall -o test test.c
> 
> (I have also tried with option -O0 but that changes nothing).
> 
> I run "gdb test" followed by "print d" and then I get this error:
> 
> No symbol "d" in current context.

You need to get to the main function, since "d" is a local variable.
After you do get to main, step one line to get past the assignment of
119 to "d", and then print its value.

When I do this, I get the value of "d" printed as I'd expect.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]