Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Cagney <ac131313@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: [rfa:breakpoint] Correctly count watchpoints
Date: Sun, 29 Sep 2002 20:34:00 -0000	[thread overview]
Message-ID: <3D97C64D.5060108@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 662 bytes --]

Hello,

The attached modifies breakpoint.c so that (I think) it correctly counts 
the number of watchpoint resources in use.

(per earlier post) An expression like:

	a + b

requires two watchpoint resources (&a and &b).  When first creating the 
watchpoint, gdb correctly counts this as two.  However,  when GDB goes 
back to compute the number of watchpoints already used, it does a 
re-count and treats the above (and any watchpoint expression) as only one.

The attached, I belive, fixes this by saving the mem_cnt that was computed.

One thing I wonder about though, should ``info breakpoints'' or ``maint 
info breakpoints'' display this info?

Ok?
Andrew

[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 2392 bytes --]

2002-09-29  Andrew Cagney  <ac131313@redhat.com>

	* breakpoint.c (watch_command_1): Save mem_cnt in watchpoint.
	(hw_watchpoint_used_count): Accumulate the mem_cnt's
	* breakpoint.h: Update copyright.
	(struct breakpoint): Add field mem_cnt;

Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.90
diff -u -r1.90 breakpoint.c
--- breakpoint.c	22 Sep 2002 20:29:52 -0000	1.90
+++ breakpoint.c	30 Sep 2002 03:09:42 -0000
@@ -4288,13 +4288,15 @@
   {
     if (b->enable_state == bp_enabled)
       {
-	if (b->type == type)
-	  i++;
-	else if ((b->type == bp_hardware_watchpoint ||
-		  b->type == bp_read_watchpoint ||
-		  b->type == bp_access_watchpoint)
-		 && b->enable_state == bp_enabled)
-	  *other_type_used = 1;
+	if (b->type == bp_hardware_watchpoint
+	    || b->type == bp_read_watchpoint
+	    || b->type == bp_access_watchpoint)
+	  {
+	    if (b->type == type)
+	      i += b->mem_cnt;
+	    else
+	      *other_type_used = 1;
+	  }
       }
   }
   return i;
@@ -5384,6 +5386,7 @@
   b->exp_valid_block = exp_valid_block;
   b->exp_string = savestring (exp_start, exp_end - exp_start);
   b->val = val;
+  b->mem_cnt = mem_cnt;
   b->cond = cond;
   if (cond_start)
     b->cond_string = savestring (cond_start, cond_end - cond_start);
Index: breakpoint.h
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.h,v
retrieving revision 1.13
diff -u -r1.13 breakpoint.h
--- breakpoint.h	16 Aug 2002 15:37:54 -0000	1.13
+++ breakpoint.h	30 Sep 2002 03:11:51 -0000
@@ -1,6 +1,7 @@
 /* Data structures associated with breakpoints in GDB.
-   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
-   Free Software Foundation, Inc.
+
+   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+   2002 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -260,6 +261,11 @@
     struct block *exp_valid_block;
     /* Value of the watchpoint the last time we checked it.  */
     struct value *val;
+
+    /* Count of memory watchpoint resources needed.  An expression can
+       refer to more than one location and hence may require more than
+       one memory watchpoint.  */
+    int mem_cnt;
 
     /* Holds the value chain for a hardware watchpoint expression.  */
     struct value *val_chain;

             reply	other threads:[~2002-09-30  3:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-29 20:34 Andrew Cagney [this message]
2002-09-29 22:40 ` Eli Zaretskii
2002-09-30  9:34   ` Andrew Cagney
2002-09-30 11:26     ` Eli Zaretskii
2002-09-30 12:42       ` Andrew Cagney
     [not found] <3D98A393.6010801@redhat.com>
2002-09-30 21:54 ` Eli Zaretskii
2002-09-30 23:00   ` Andrew Cagney
2002-10-01 11:23     ` Eli Zaretskii

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=3D97C64D.5060108@redhat.com \
    --to=ac131313@redhat.com \
    --cc=gdb-patches@sources.redhat.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