From: Andrew Cagney <ac131313@redhat.com>
To: Klee Dienes <klee@apple.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [PATCH] Compare contents when evaluating an array watchpoint
Date: Wed, 08 Jan 2003 00:46:00 -0000 [thread overview]
Message-ID: <3E1B7488.6090807@redhat.com> (raw)
In-Reply-To: <51EACEDC-D90C-11D6-9330-00039396EEB8@apple.com>
[-- Attachment #1: Type: text/plain, Size: 139 bytes --]
Klee,
Looking through this thread, the technical issues appear to have been
resolved. You should probably ping the maintainers.
Andrew
[-- Attachment #2: mailbox-message://ac131313@movemail/fsf/gdb/patches#2273668 --]
[-- Type: message/rfc822, Size: 5063 bytes --]
From: Klee Dienes <klee@apple.com>
To: gdb-patches@sources.redhat.com
Subject: [PATCH] Compare contents when evaluating an array watchpoint
Date: Sun, 6 Oct 2002 05:16:39 -0400
Message-ID: <51EACEDC-D90C-11D6-9330-00039396EEB8@apple.com>
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 <kdienes@bluegill.localnet>
* 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);
prev parent reply other threads:[~2003-01-08 0:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-06 2:16 Klee Dienes
2002-10-06 22:53 ` Eli Zaretskii
2002-10-06 23:12 ` Klee Dienes
2002-10-07 7:26 ` Eli Zaretskii
2002-10-07 11:50 ` Klee Dienes
2002-10-09 12:42 ` Eli Zaretskii
2002-10-21 17:44 ` Andrew Cagney
2002-11-04 18:27 ` [RFA] " Klee Dienes
2002-11-18 9:52 ` [PATCH] " Jim Blandy
2003-01-08 0:46 ` Andrew Cagney [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3E1B7488.6090807@redhat.com \
--to=ac131313@redhat.com \
--cc=gdb-patches@sources.redhat.com \
--cc=klee@apple.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox