From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31653 invoked by alias); 20 Apr 2006 18:40:47 -0000 Received: (qmail 31497 invoked by uid 22791); 20 Apr 2006 18:40:46 -0000 X-Spam-Check-By: sourceware.org Received: from romy.inter.net.il (HELO romy.inter.net.il) (192.114.186.66) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 20 Apr 2006 18:40:44 +0000 Received: from HOME-C4E4A596F7 (IGLD-80-230-9-6.inter.net.il [80.230.9.6]) by romy.inter.net.il (MOS 3.7.3-GA) with ESMTP id EAA41848 (AUTH halo1); Thu, 20 Apr 2006 21:40:40 +0300 (IDT) Date: Thu, 20 Apr 2006 19:03:00 -0000 Message-Id: From: Eli Zaretskii To: Vladimir Prus CC: gdb@sources.redhat.com In-reply-to: <200604201931.38519.ghost@cs.msu.su> (message from Vladimir Prus on Thu, 20 Apr 2006 19:31:37 +0400) Subject: Re: Checking if addess is on stack? Reply-to: Eli Zaretskii References: <200604201548.36899.ghost@cs.msu.su> <200604201931.38519.ghost@cs.msu.su> X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-04/txt/msg00282.txt.bz2 > From: Vladimir Prus > 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)