From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12947 invoked by alias); 20 Apr 2006 11:48:56 -0000 Received: (qmail 12934 invoked by uid 22791); 20 Apr 2006 11:48:55 -0000 X-Spam-Check-By: sourceware.org Received: from zigzag.lvk.cs.msu.su (HELO zigzag.lvk.cs.msu.su) (158.250.17.23) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 20 Apr 2006 11:48:53 +0000 Received: from Debian-exim by zigzag.lvk.cs.msu.su with spam-scanned (Exim 4.50) id 1FWXeT-0004mx-Oy for gdb@sources.redhat.com; Thu, 20 Apr 2006 15:48:50 +0400 Received: from zigzag.lvk.cs.msu.su ([158.250.17.23]) by zigzag.lvk.cs.msu.su with esmtp (Exim 4.50) id 1FWXeH-0004hz-WA; Thu, 20 Apr 2006 15:48:38 +0400 From: Vladimir Prus To: Eli Zaretskii Subject: Re: Checking if addess is on stack? Date: Thu, 20 Apr 2006 12:49:00 -0000 User-Agent: KMail/1.7.2 Cc: gdb@sources.redhat.com References: <200604201426.59360.ghost@cs.msu.su> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200604201548.36899.ghost@cs.msu.su> 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/msg00270.txt.bz2 On Thursday 20 April 2006 15:42, Eli Zaretskii wrote: > > From: Vladimir Prus > > Date: Thu, 20 Apr 2006 14:26:58 +0400 > > Cc: gdb@sources.redhat.com > > > > I'm not sure that's exactly what I need. This way, watchpoint will be > > automatically inserted when I enter 'do_that', but as soon as I leave > > 'do_that', gdb will remove wathchpoint because 'ptr' has gone out of > > scope. This will prevent me from catching accesses to ptr->i made outside > > of the function where 'ptr' is valid. Am I missing something? > > Perhaps _I_ am missing something. Isn't `ptr' a variable that is > local to the function `do_that'? I thought it was; if so, then it > couldn't possibly be accessed after `do_that' returns, because all > locals are popped off the stack when `do_that' returns. These locals > will get entirely new values when `do_that' is entered the next time. > > (If you want to catch accesses to the address where `ptr' _was_ on the > stack, then you really need to set the wathchpoint on an absolute > address. Precisely, I want to catch accesses to a specific address, and I want that to be the only (or at least default) behaviour in KDevelop. That is, if user types in any expression, KDevelop will compute the address of that expression and set watchpoint on address. The rationale is that in the case I've given: void do_that(My_class* ptr) { ptr->i = .....; ........ } user most likely wants to catch all future accesses to variable 'i', and does not care if those accesses go via 'ptr' in 'do_that', or via some other pointer variable in some other function. > But watching addresses on the stack beyond the stack top is > a very unusual thing to do, so I don't think this is what your users > would need.) Exactly, so I want to detect the case where address in on the stack, and in that case disable the watchpoint when function exists. But there's no easy way to detect if address is on stack, and that's the problem. - Volodya