Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Re: Static variables incorrect address
@ 2002-03-21 17:11 Salman Khilji
  0 siblings, 0 replies; 4+ messages in thread
From: Salman Khilji @ 2002-03-21 17:11 UTC (permalink / raw)
  To: gdb

I would tend to agree with Mike.  I have used this feature with lots of 
different cases.  It works very nicely with both C and C++.  plus, you dont' 
even have to issue the run command.  You can lookup the address right after 
the startup.

There was once a problem with static member variables like these inside C++ 
namepsaces.  But that was fixed in 5.1


Salman


>From: Michael Snyder <msnyder@redhat.com>
>To: Kiranmaye Gannabathula <kiranmaye.gannabathula@powervr.com>
>CC: "'gdb@sources.redhat.com'" <gdb@sources.redhat.com>
>Subject: Re: Static variables incorrect address
>Date: Thu, 21 Mar 2002 16:12:53 -0800
>
>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".



_________________________________________________________________
Join the worldÂ’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


^ permalink raw reply	[flat|nested] 4+ messages in thread
* Static variables incorrect address
@ 2002-03-21  9:18 Kiranmaye Gannabathula
  2002-03-21 11:34 ` Eli Zaretskii
  2002-03-21 16:23 ` Michael Snyder
  0 siblings, 2 replies; 4+ messages in thread
From: Kiranmaye Gannabathula @ 2002-03-21  9:18 UTC (permalink / raw)
  To: 'gdb@sources.redhat.com'

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.

Can anyone please help me with this

Thanks Kiran.



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

end of thread, other threads:[~2002-03-22  1:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-21 17:11 Static variables incorrect address Salman Khilji
  -- strict thread matches above, loose matches on Subject: below --
2002-03-21  9:18 Kiranmaye Gannabathula
2002-03-21 11:34 ` Eli Zaretskii
2002-03-21 16:23 ` Michael Snyder

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