From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5469 invoked by alias); 21 May 2006 02:12:51 -0000 Received: (qmail 5461 invoked by uid 22791); 21 May 2006 02:12:50 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Sun, 21 May 2006 02:12:48 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1FhdQx-0002W6-64; Sat, 20 May 2006 22:12:43 -0400 Date: Sun, 21 May 2006 05:22:00 -0000 From: Daniel Jacobowitz To: Nick Roberts Cc: Vladimir Prus , gdb-patches@sources.redhat.com Subject: Re: [PATCH] -var-update Message-ID: <20060521021243.GB9432@nevyn.them.org> Mail-Followup-To: Nick Roberts , Vladimir Prus , gdb-patches@sources.redhat.com References: <17518.39336.538984.261434@kahikatea.snap.net.nz> <20060520144015.GA32035@nevyn.them.org> <17519.38740.887319.134411@kahikatea.snap.net.nz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <17519.38740.887319.134411@kahikatea.snap.net.nz> User-Agent: Mutt/1.5.11+cvs20060403 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-05/txt/msg00437.txt.bz2 On Sun, May 21, 2006 at 10:25:24AM +1200, Nick Roberts wrote: > Yes. Perhaps my summary isn't precise, but it didn't work. My patch uses > value_at while coerce_ref uses value_at_lazy. The comment says: > > Call value_at only if the data needs to be fetched immediately; > if we can be 'lazy' and defer the fetch, perhaps indefinately, call > ^^^^^^^^^^^^ > value_at_lazy instead. value_at_lazy simply records the address of > the data and sets the lazy-evaluation-required flag. The lazy flag > is tested in the value_contents macro, which is used if and when > the contents are actually required. > > value_contents is not a macro (VALUE_CONTENTS used to be one) but a function, > and doesn't test the lazy flag. No: const gdb_byte * value_contents (struct value *value) { return value_contents_writeable (value); } gdb_byte * value_contents_writeable (struct value *value) { if (value->lazy) value_fetch_lazy (value); return value_contents_raw (value); } If you take a look at the code you're patching, there should be a nearby call to value_fetch_lazy or gdb_value_fetch_lazy in each case. You want to be calling coerce_ref before you do that. Also, see the existing calls to release_value? If you change var->value after that, you're going to leak memory. Try calling coerce_ref in here: if (gdb_evaluate_expression (var->root->exp, &var->value)) { /* no error */ /* HERE */ release_value (var->value); if (value_lazy (var->value)) gdb_value_fetch_lazy (var->value); } else var->value = evaluate_type (var->root->exp); -- Daniel Jacobowitz CodeSourcery