This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: Still cannot print variable
- From: "Eli Zaretskii" <eliz at gnu dot org>
- To: fedevaps at yahoo dot dk
- Cc: gdb at sources dot redhat dot com
- Date: Fri, 15 Apr 2005 12:25:47 +0300
- Subject: Re: Still cannot print variable
- References: <d3o02u$t10$1@sea.gmane.org>
- Reply-to: Eli Zaretskii <eliz at gnu dot org>
> 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.