From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22009 invoked by alias); 22 Mar 2008 12:36:21 -0000 Received: (qmail 21999 invoked by uid 22791); 22 Mar 2008 12:36:20 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 22 Mar 2008 12:36:00 +0000 Received: (qmail 14532 invoked from network); 22 Mar 2008 12:35:58 -0000 Received: from unknown (HELO localhost) (vladimir@127.0.0.2) by mail.codesourcery.com with ESMTPA; 22 Mar 2008 12:35:58 -0000 From: Vladimir Prus To: Eli Zaretskii Subject: Re: [RFA] Fix breakpoint condition that use member variables. Date: Sat, 22 Mar 2008 12:36:00 -0000 User-Agent: KMail/1.9.6 (enterprise 0.20070907.709405) References: <200803221240.16230.vladimir@codesourcery.com> In-Reply-To: Cc: gdb-patches@sources.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200803221536.07586.vladimir@codesourcery.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-03/txt/msg00331.txt.bz2 On Saturday 22 March 2008 15:06:35 Eli Zaretskii wrote: > > From: Vladimir Prus > > Date: Sat, 22 Mar 2008 12:40:15 +0300 > > > > Suppose that foo.cpp:10 is a location inside member function of a > > class, and that said class has member variable i_, and that we've > > just started a program and are in main. Then: > > > > break foo.cpp:10 if i_ == 10 > > > > will not work, claiming that i_ does not exist. The problem is that > > lookup_symbol_aux uses value_of_this, which uses value_of_local and > > that totally ignores the block that is passed to parse_exp_1 by > > the breakpoint code and uses the block of the selected frame. Of > > course, that either does not have "this", or has wrong "this". > > > > This patch fixes the problem by looking in the right block > > directly, and also by looking for the field in the type of "this", > > without trying to get the value. > > What will happen after your patch if there's also a variable i_ in > the selected frame? The i_ in the breakpoint condition will be associated with the member variable, not with the variable with selected frame. FWIW, it's exactly as happens with local variables -- say, with gdb 6.6, if I have ordinary local variable i in selected frame, and set breakpoint at whatever.cpp:10, and there's local variable i there, then breakpoint condition using 'i' will evaluate i at the breakpoint location, not from the currently selected frame. When lookup_symbol_aux is asked to find a symbol in a block, it will carefully look in that block, not using selected frame in any way. It's only the lookup for "this" that relied on selected frame. I have modified my testcase to include a local variable called i_, to make sure this does not confuse anything. - Volodya