From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3246 invoked by alias); 8 Jan 2003 00:46:22 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 2216 invoked from network); 8 Jan 2003 00:45:05 -0000 Received: from unknown (HELO localhost.redhat.com) (216.138.202.10) by 209.249.29.67 with SMTP; 8 Jan 2003 00:45:05 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 45BD83D06; Tue, 7 Jan 2003 19:44:56 -0500 (EST) Message-ID: <3E1B7488.6090807@redhat.com> Date: Wed, 08 Jan 2003 00:46:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.1) Gecko/20021211 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Klee Dienes Cc: gdb-patches@sources.redhat.com Subject: Re: [PATCH] Compare contents when evaluating an array watchpoint References: <51EACEDC-D90C-11D6-9330-00039396EEB8@apple.com> Content-Type: multipart/mixed; boundary="------------000302030405040108050809" X-SW-Source: 2003-01/txt/msg00309.txt.bz2 This is a multi-part message in MIME format. --------------000302030405040108050809 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 139 Klee, Looking through this thread, the technical issues appear to have been resolved. You should probably ping the maintainers. Andrew --------------000302030405040108050809 Content-Type: message/rfc822; name="mailbox-message://ac131313@movemail/fsf/gdb/patches#2273668" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="mailbox-message://ac131313@movemail/fsf/gdb/patches#2273668" Content-length: 5042 X-Mozilla-Status2: 00000000 Return-Path: Delivered-To: ac131313@localhost.redhat.com Received: from localhost (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 736773ED6 for ; Mon, 14 Oct 2002 17:33:05 -0400 (EDT) Envelope-to: cagney@gnu.org Delivery-date: Sun, 06 Oct 2002 05:21:59 -0400 Received: from fencepost.gnu.org by localhost with IMAP (fetchmail-5.9.13) for ac131313@localhost (single-drop); Mon, 14 Oct 2002 17:33:05 -0400 (EDT) Received: from monty-python.gnu.org ([199.232.76.173]) by fencepost.gnu.org with esmtp (Exim 4.10) id 17y7br-0002SY-00 for cagney@gnu.org; Sun, 06 Oct 2002 05:21:59 -0400 Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17y7Wk-0007KM-00 for cagney@gnu.org; Sun, 06 Oct 2002 05:16:46 -0400 Received: from sources.redhat.com ([209.249.29.67]) by monty-python.gnu.org with smtp (Exim 4.10) id 17y7Wi-0007Ea-00 for cagney@gnu.org; Sun, 06 Oct 2002 05:16:40 -0400 Received: (qmail 30615 invoked by alias); 6 Oct 2002 09:16:36 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Delivered-To: mailing list gdb-patches@sources.redhat.com Received: (qmail 30605 invoked from network); 6 Oct 2002 09:16:35 -0000 Received: from unknown (HELO mail-out2.apple.com) (17.254.0.51) by sources.redhat.com with SMTP; 6 Oct 2002 09:16:35 -0000 Received: from mailgate2.apple.com (A17-129-100-225.apple.com [17.129.100.225]) by mail-out2.apple.com (8.11.3/8.11.3) with ESMTP id g969GYs24617 for ; Sun, 6 Oct 2002 02:16:34 -0700 (PDT) Received: from scv2.apple.com (scv2.apple.com) by mailgate2.apple.com (Content Technologies SMTPRS 4.2.1) with ESMTP id for ; Sun, 6 Oct 2002 02:16:34 -0700 Received: from molly.local. (vpn-scv-x1-10.apple.com [17.219.193.10]) by scv2.apple.com (8.11.3/8.11.3) with ESMTP id g969GXV17685 for ; Sun, 6 Oct 2002 02:16:34 -0700 (PDT) Date: Sun, 6 Oct 2002 05:16:39 -0400 Mime-Version: 1.0 (Apple Message framework v543) Content-Type: text/plain; charset=US-ASCII; format=flowed Subject: [PATCH] Compare contents when evaluating an array watchpoint From: Klee Dienes To: gdb-patches@sources.redhat.com Content-Transfer-Encoding: 7bit Message-Id: <51EACEDC-D90C-11D6-9330-00039396EEB8@apple.com> X-Spam-Status: No, hits=0.0 required=5.0 tests=PATCH_UNIFIED_DIFF,SPAM_PHRASE_00_01 version=2.41 X-Spam-Level: Content-length: 2030 The following patch allows one to set watchpoints on arrays, and have the watchpoint triggered if any element in the array changes. Without the patch, the C value_equal semantics causes the address of the array to be checked for change, not the contents --- resulting in a watchpoint that can never be hit. This is particularly useful if one wants to do commands like watch {char[80]} 0xfff0000, or similar, in order to watch an arbitrary region of memory. 2002-08-06 Klee Dienes * breakpoint.c (watchpoint_equal): New function. Like value_equal, but arrays only count as "equal" if they have the same contents. (watchpoint_check): Update to use watchpoint_equal. diff -u -r1.1.1.21 -r1.47 --- breakpoint.c 2002/09/26 20:56:41 1.1.1.21 +++ breakpoint.c 2002/10/06 09:07:23 1.47 @@ -2359,6 +2448,34 @@ return bs; } +/* Like value_equal, but two arrays are only considered equal if their + contents are equal. */ + +static int +watchpoint_equal (struct value *arg1, struct value *arg2) +{ + register int len; + register char *p1, *p2; + + if ((TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_ARRAY) + && (TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_ARRAY)) + { + int len = TYPE_LENGTH (VALUE_TYPE (arg1)); + if (TYPE_LENGTH (VALUE_TYPE (arg1)) != TYPE_LENGTH (VALUE_TYPE (arg2))) + return 0; + p1 = VALUE_CONTENTS (arg1); + p2 = VALUE_CONTENTS (arg2); + while (--len >= 0) + { + if (*p1++ != *p2++) + break; + } + return len < 0; + } + + return value_equal (arg1, arg2); +} + /* Possible return values for watchpoint_check (this can't be an enum because of check_errors). */ /* The watchpoint has been deleted. */ @@ -2417,7 +2535,7 @@ struct value *mark = value_mark (); struct value *new_val = evaluate_expression (bs->breakpoint_at->exp); - if (!value_equal (b->val, new_val)) + if (!watchpoint_equal (b->val, new_val)) { release_value (new_val); --------------000302030405040108050809--