Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* watchpoint on variable in function scope
@ 2011-06-01 21:22 Niko Sams
  2011-06-02 17:22 ` Tom Tromey
  0 siblings, 1 reply; 6+ messages in thread
From: Niko Sams @ 2011-06-01 21:22 UTC (permalink / raw)
  To: gdb

Hi again,

please have a look at the example code below.
How can i set a watchpoint on i before starting the appliaction?
it used to work with
"watch foo::i"


thanks,
Niko

------------------
void foo() {
    static int i=0;
    ++i;
}
int main(int argc, char **argv) {
    foo();
    return 0;
}


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

* Re: watchpoint on variable in function scope
  2011-06-01 21:22 watchpoint on variable in function scope Niko Sams
@ 2011-06-02 17:22 ` Tom Tromey
  2011-06-02 17:48   ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2011-06-02 17:22 UTC (permalink / raw)
  To: Niko Sams; +Cc: gdb

>>>>> "Niko" == Niko Sams <niko.sams@gmail.com> writes:

Niko> please have a look at the example code below.
Niko> How can i set a watchpoint on i before starting the appliaction?
Niko> it used to work with
Niko> "watch foo::i"

When did this work?
I tried 6.8 and 7.1 and neither worked.

Tom


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

* Re: watchpoint on variable in function scope
  2011-06-02 17:22 ` Tom Tromey
@ 2011-06-02 17:48   ` Eli Zaretskii
  2011-06-02 18:07     ` Niko Sams
  2011-06-02 18:43     ` Sterling Augustine
  0 siblings, 2 replies; 6+ messages in thread
From: Eli Zaretskii @ 2011-06-02 17:48 UTC (permalink / raw)
  To: Tom Tromey; +Cc: niko.sams, gdb

> From: Tom Tromey <tromey@redhat.com>
> Cc: gdb <gdb@sourceware.org>
> Date: Thu, 02 Jun 2011 11:22:03 -0600
> 
> >>>>> "Niko" == Niko Sams <niko.sams@gmail.com> writes:
> 
> Niko> please have a look at the example code below.
> Niko> How can i set a watchpoint on i before starting the appliaction?
> Niko> it used to work with
> Niko> "watch foo::i"
> 
> When did this work?
> I tried 6.8 and 7.1 and neither worked.

I also think that it never worked.  You need to have the variable in
scope to be able to watch it.


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

* Re: watchpoint on variable in function scope
  2011-06-02 17:48   ` Eli Zaretskii
@ 2011-06-02 18:07     ` Niko Sams
  2011-06-02 18:43     ` Sterling Augustine
  1 sibling, 0 replies; 6+ messages in thread
From: Niko Sams @ 2011-06-02 18:07 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Tom Tromey, gdb

> I also think that it never worked.  You need to have the variable in
> scope to be able to watch it.
ok, then it must have been by stupidity.

thanks :D


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

* Re: watchpoint on variable in function scope
  2011-06-02 17:48   ` Eli Zaretskii
  2011-06-02 18:07     ` Niko Sams
@ 2011-06-02 18:43     ` Sterling Augustine
  2011-06-13 17:43       ` Tom Tromey
  1 sibling, 1 reply; 6+ messages in thread
From: Sterling Augustine @ 2011-06-02 18:43 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Tom Tromey, niko.sams, gdb

Tom's test case works fine for me if I compile it as a C program.
However, it fails if I compile it as a C++ program. (Using gcc 4.4.3.)

Looking at the assembly, the C code names the static "i.1591", but the
C++ code uses "_ZZ3foovE1i".

So this seems to be a C++ name look up failure. Not sure it how should work.

$ gcc ~/bar.c -g
$ ./gdb ./a.out
GNU gdb (GDB) 7.2.90.20110513-cvs
...
(gdb) watch foo::i
Watchpoint 1: foo::i
(gdb) run
Starting program: ./a.out
Hardware watchpoint 1: foo::i

Old value = 0
New value = 1
foo () at /home/saugustine/bar.c:4
4	}


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

* Re: watchpoint on variable in function scope
  2011-06-02 18:43     ` Sterling Augustine
@ 2011-06-13 17:43       ` Tom Tromey
  0 siblings, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2011-06-13 17:43 UTC (permalink / raw)
  To: Sterling Augustine; +Cc: Eli Zaretskii, niko.sams, gdb

>>>>> "Sterling" == Sterling Augustine <saugustine@google.com> writes:

Sterling> Tom's test case works fine for me if I compile it as a C program.
Sterling> However, it fails if I compile it as a C++ program. (Using gcc 4.4.3.)

Sterling> Looking at the assembly, the C code names the static "i.1591", but the
Sterling> C++ code uses "_ZZ3foovE1i".

Sterling> So this seems to be a C++ name look up failure. Not sure it
Sterling> how should work.

Could you file this in bugzilla?

Tom


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

end of thread, other threads:[~2011-06-13 17:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-01 21:22 watchpoint on variable in function scope Niko Sams
2011-06-02 17:22 ` Tom Tromey
2011-06-02 17:48   ` Eli Zaretskii
2011-06-02 18:07     ` Niko Sams
2011-06-02 18:43     ` Sterling Augustine
2011-06-13 17:43       ` Tom Tromey

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