This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: Static variables incorrect address
- From: Michael Snyder <msnyder at redhat dot com>
- To: Kiranmaye Gannabathula <kiranmaye dot gannabathula at powervr dot com>
- Cc: "'gdb at sources dot redhat dot com'" <gdb at sources dot redhat dot com>
- Date: Thu, 21 Mar 2002 16:12:53 -0800
- Subject: Re: Static variables incorrect address
- Organization: Red Hat, Inc.
- References: <E821125BE8B4D5119E7E00A0C94BF0AD2158A6@smtp1.videologic.co.uk>
Kiranmaye Gannabathula wrote:
>
> Hello,
> I have a problem with the global static variables in gdb.
>
> For a C program as below
>
> static int Data = 9;
>
> int Func1(void)
> {
> return Data;
> }
>
> if i compile this with debug info and run it under gdb, when i breakpoint on
> the variable Data and try to print its value i get some value and
> if i look at the address
> p /x Data
> i get some invalid address.
I believe you want to say "p /x &Data".
Otherwise you will be looking at memory at an address
determined by the value of the variable "Data".