From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29575 invoked by alias); 29 Dec 2008 05:14:02 -0000 Received: (qmail 29558 invoked by uid 22791); 29 Dec 2008 05:14:02 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 29 Dec 2008 05:13:27 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 5913F2A9659; Mon, 29 Dec 2008 00:13:25 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 0+G5voTBj8rz; Mon, 29 Dec 2008 00:13:25 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 7AAFF2A9650; Mon, 29 Dec 2008 00:13:24 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 17B29E7ACD; Mon, 29 Dec 2008 09:13:17 +0400 (RET) Date: Mon, 29 Dec 2008 05:14:00 -0000 From: Joel Brobecker To: Emi SUZUKI Cc: gdb@sourceware.org Subject: Re: Watchpoint on an unloaded shared library(2) Message-ID: <20081229051317.GB16483@adacore.com> References: <20081217.154039.01371590.emi-suzuki@tjsys.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20081217.154039.01371590.emi-suzuki@tjsys.co.jp> User-Agent: Mutt/1.4.2.2i Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-12/txt/msg00090.txt.bz2 > The cause of a crash is that print_one_breakpoint_location in breakpoint.c > doesn't care about whether the expression for the watchpoint is valid: > > case bp_watchpoint: > case bp_hardware_watchpoint: > case bp_read_watchpoint: > case bp_access_watchpoint: > /* Field 4, the address, is omitted (which makes the columns > not line up too nicely with the headers, but the effect > is relatively readable). */ > if (opts.addressprint) > ui_out_field_skip (uiout, "addr"); > annotate_field (5); > print_expression (b->exp, stb->stream); > ui_out_field_stream (uiout, "what", stb); > break; > > Here, b->exp for the watchpoints set on an unloaded shared library can > be NULL, because breakpoint_re_set_one has done it. However, what > should we do instead? > > I have considered two solutions: > > a) Print b->exp_string and b->cond_string. > We might make some effort to display it like as its expression is > valid for annotations... I have no idea whether it is worthwhile > to try. I think that this is the best we can do (print exp_string). I personally wouldn't worry about trying to massage the string into something that would look like we're printing an expression. I'm not even sure why we use "print_expression (b->exp) rather than printing exp_string directly - perhaps someone does? > b) Don't set b->exp to NULL in update_watchpoint (called by > breakpoint_re_set_one), do_enable_breakpoint and so on. > Maybe we should add some flags to `struct expression' to avoid > passing invalid symtabs to some interacting functions. I don't think we can do that. Otherwise, the expression could reference some symbols that no longer exist. > "Skip printing" is another possibility, but I'd ignore it: skipping > means that the user can't refer to the information about what they > were. Right, as long as the watchpoint is defined, albeit disabled, we need to show it in the list. Another alternative of your suggestion is to not print the "what". But I would find this confusing, since you would no longer know what the watchpoint entry is watching. -- Joel