Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Vladimir Prus <ghost@cs.msu.su>
Cc: gdb@sources.redhat.com
Subject: Re: Checking if addess is on stack?
Date: Thu, 20 Apr 2006 19:03:00 -0000	[thread overview]
Message-ID: <uy7y0um34.fsf@gnu.org> (raw)
In-Reply-To: <200604201931.38519.ghost@cs.msu.su> (message from Vladimir Prus 	on Thu, 20 Apr 2006 19:31:37 +0400)

> From: Vladimir Prus <ghost@cs.msu.su>
> Date: Thu, 20 Apr 2006 19:31:37 +0400
> Cc: gdb@sources.redhat.com
> 
> (gdb) watch *ptr
> Hardware watchpoint 2: *ptr
> (gdb) c
> Continuing.
> Hardware watchpoint 2 deleted because the program has left the block
> in which its expression is valid.
> 
> Program exited normally.
> (gdb)
> 
> I don't watch watchpoint 2 to be deleted in this case.

You could put 2 watchpoints instead of one, as in the session attached
at the end of this message.  (Yes, I know that it triggers outside
`main', but that's what we have now.)

> I want to set breakpoint at address, and be it automatically removed when 
> leaving function, if and only if the address is on function stack.

Doing this in all cases would be a misfeature, for the reasons I tried
to explain: users normally expect us to stop the program when any one
of the variables which contribute to an expression's value are
modified.

> In current gdb, I can either:
> 1. Set watchpoint on expression, and it will be always deleted, like in above 
> case.
> 2. Set watchpoint on address, and it won't be ever deleted.

I suggested a possible enhancement to watchpoints to do better, but
someone will have to code it (assuming that people agree with my
suggestion).


D:\usr\eli\data>gdb ./dbw.exe
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-mingw32"...
(gdb) b set
Breakpoint 1 at 0x401293: file dbw.c, line 3.
(gdb) r
Starting program: D:\usr\eli\data/./dbw.exe

Breakpoint 1, set (ptr=0x22ff74) at dbw.c:3
3           *ptr = 10;
(gdb) watch *ptr
Hardware watchpoint 2: *ptr
(gdb) p/x ptr
$1 = 0x22ff74
(gdb) watch *(int *)$1
Hardware watchpoint 3: *(int *) $1
(gdb) c
Continuing.
Hardware watchpoint 2: *ptr

Old value = 2
New value = 10
Hardware watchpoint 4: *(int *) $1

Old value = 2
New value = 10
set (ptr=0x22ff74) at dbw.c:4
4       }
(gdb) c
Continuing.

Watchpoint 2 deleted because the program has left the block in
which its expression is valid.
main () at dbw.c:15
15          modify(&i);
(gdb) c
Continuing.
Hardware watchpoint 4: *(int *) $1

Old value = 10
New value = 15
modify (ptr=0x22ff74) at dbw.c:9
9       }
(gdb) c
Continuing.
Hardware watchpoint 4: *(int *) $1

Old value = 15
New value = 0
0x77c39ebb in msvcrt!_cexit ()
(gdb) c
Continuing.
Hardware watchpoint 4: *(int *) $1

Old value = 0
New value = -1
0x7c81caa9 in KERNEL32!ExitProcess () from C:\WINDOWS\system32\kernel32.dll
(gdb) c
Continuing.

Program exited normally.
(gdb)


      reply	other threads:[~2006-04-20 18:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-20 10:27 Vladimir Prus
2006-04-20 11:42 ` Eli Zaretskii
2006-04-20 11:48   ` Vladimir Prus
2006-04-20 12:21     ` Eli Zaretskii
2006-04-20 12:49       ` Vladimir Prus
2006-04-20 14:27         ` Eli Zaretskii
2006-04-20 14:39           ` Daniel Jacobowitz
2006-04-20 15:24             ` Eli Zaretskii
2006-04-20 15:32               ` Daniel Jacobowitz
2006-04-20 18:41                 ` Eli Zaretskii
2006-04-20 19:12                   ` Daniel Jacobowitz
2006-04-21 11:45                     ` Eli Zaretskii
2006-04-22  8:06                       ` Daniel Jacobowitz
2006-04-20 16:29           ` Vladimir Prus
2006-04-20 19:03             ` Eli Zaretskii [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=uy7y0um34.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=gdb@sources.redhat.com \
    --cc=ghost@cs.msu.su \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox