* gdb/remote.c (remote_insert_watchpoint): Return -1, rather than
	fatal error if packet is disabled.
	(remote_remove_watchpoint, remote_insert_hw_breakpoint,
	remote_remove_hw_breakpoint): Likewise.
	Revert my 2006-06-01  Nathan Sidwell  <nathan@codesourcery.com>
	change to breakpoint.c
diff --git a/ChangeLog.csl b/ChangeLog.csl
index 4272861..c7dfa9c 100644
--- a/ChangeLog.csl
+++ b/ChangeLog.csl
@@ -1,5 +1,12 @@
 2006-06-05  Nathan Sidwell  <nathan@codesourcery.com>
 
+	* gdb/remote.c (remote_insert_watchpoint): Return -1, rather than
+	fatal error if packet is disabled.
+	(remote_remove_watchpoint, remote_insert_hw_breakpoint,
+	remote_remove_hw_breakpoint): Likewise.
+	Revert my 2006-06-01  Nathan Sidwell  <nathan@codesourcery.com>
+	change to breakpoint.c
+
 	* gdb/testsuite/gdb.asm/m68k.inc (gdbasm_call): Use jsr.
 	* gdb/testsuite/gdb.base/fileio.c (stop): New.  Call it everywhere
 	the debugger should stop.
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 91eb563..472d8d0 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -129,8 +129,7 @@
   }
 insertion_state_t;
 
-static int remove_breakpoint (struct bp_location *, insertion_state_t,
-			      struct value *);
+static int remove_breakpoint (struct bp_location *, insertion_state_t);
 
 static enum print_stop_action print_it_typical (bpstat);
 
@@ -949,7 +948,6 @@
 
       if (within_current_scope)
 	{
-	  struct value *val_failed = NULL;
 	  free_valchain (bpt);
 
 	  /* Evaluate the expression and cut the chain of values
@@ -997,8 +995,13 @@
 		      val = target_insert_watchpoint (addr, len, type);
 		      if (val == -1)
 			{
-			  val_failed = v;
-			  break;
+			  /* Don't exit the loop, try to insert
+			     every value on the value chain.  That's
+			     because we will be removing all the
+			     watches below, and removing a
+			     watchpoint we didn't insert could have
+			     adverse effects.  */
+			  bpt->inserted = 0;
 			}
 		      val = 0;
 		    }
@@ -1006,10 +1009,9 @@
 	    }
 	  /* Failure to insert a watchpoint on any memory value in the
 	     value chain brings us here.  */
-	  if (val_failed)
+	  if (!bpt->inserted)
 	    {
-	      remove_breakpoint (bpt, mark_uninserted, val_failed);
-	      bpt->inserted = 0;
+	      remove_breakpoint (bpt, mark_uninserted);
 	      *hw_breakpoint_error = 1;
 	      fprintf_unfiltered (tmp_error_stream,
 				  "Could not insert hardware watchpoint %d.\n", 
@@ -1197,7 +1199,7 @@
   {
     if (b->inserted)
       {
-	val = remove_breakpoint (b, mark_uninserted, NULL);
+	val = remove_breakpoint (b, mark_uninserted);
 	if (val != 0)
 	  return val;
       }
@@ -1215,7 +1217,7 @@
   {
     if (b->inserted && b->loc_type == bp_loc_hardware_watchpoint)
       {
-	val = remove_breakpoint (b, mark_uninserted, NULL);
+	val = remove_breakpoint (b, mark_uninserted);
 	if (val != 0)
 	  return val;
       }
@@ -1236,7 +1238,7 @@
   {
     if (b->inserted)
       {
-	remove_breakpoint (b, mark_inserted, NULL);
+	remove_breakpoint (b, mark_inserted);
 	if (b->loc_type == bp_loc_hardware_breakpoint)
 	  val = target_insert_hw_breakpoint (b->address, b->shadow_contents);
 	else
@@ -1404,7 +1406,7 @@
   {
     if (b->inserted)
       {
-	val = remove_breakpoint (b, mark_inserted, NULL);
+	val = remove_breakpoint (b, mark_inserted);
 	if (val != 0)
 	  {
 	    do_cleanups (old_chain);
@@ -1416,13 +1418,8 @@
   return 0;
 }
 
-/* Remove the breakpoints for B.  FAILED_VAL, if non-null is the value
-   in the bpt->owner->val_chain that failed to be inserted.  We stop
-   at that point.  */
-
 static int
-remove_breakpoint (struct bp_location *b, insertion_state_t is,
-		   struct value *val_failed)
+remove_breakpoint (struct bp_location *b, insertion_state_t is)
 {
   int val;
 
@@ -1506,7 +1503,7 @@
 
       b->inserted = (is == mark_inserted);
       /* Walk down the saved value chain.  */
-      for (v = b->owner->val_chain; v != val_failed; v = value_next (v))
+      for (v = b->owner->val_chain; v; v = value_next (v))
 	{
 	  /* For each memory reference remove the watchpoint
 	     at that address.  */
@@ -6778,7 +6775,7 @@
   breakpoint_delete_event (bpt->number);
 
   if (bpt->loc->inserted)
-    remove_breakpoint (bpt->loc, mark_inserted, NULL);
+    remove_breakpoint (bpt->loc, mark_inserted);
 
   free_valchain (bpt->loc);
 
diff --git a/gdb/remote.c b/gdb/remote.c
index 4602635..599bb21 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -4670,9 +4670,7 @@
   enum Z_packet_type packet = watchpoint_to_Z_packet (type);
 
   if (remote_protocol_packets[PACKET_Z0 + packet].support == PACKET_DISABLE)
-    error (_("Can't set hardware watchpoints without the '%s' (%s) packet."),
-	   remote_protocol_packets[PACKET_Z0 + packet].name,
-	   remote_protocol_packets[PACKET_Z0 + packet].title);
+    return -1;
 
   sprintf (buf, "Z%x,", packet);
   p = strchr (buf, '\0');
@@ -4705,10 +4703,8 @@
   enum Z_packet_type packet = watchpoint_to_Z_packet (type);
 
   if (remote_protocol_packets[PACKET_Z0 + packet].support == PACKET_DISABLE)
-    error (_("Can't clear hardware watchpoints without the '%s' (%s) packet."),
-	   remote_protocol_packets[PACKET_Z0 + packet].name,
-	   remote_protocol_packets[PACKET_Z0 + packet].title);
-
+    return -1;
+  
   sprintf (buf, "z%x,", packet);
   p = strchr (buf, '\0');
   addr = remote_address_masked (addr);
@@ -4796,10 +4792,8 @@
   BREAKPOINT_FROM_PC (&addr, &len);
 
   if (remote_protocol_packets[PACKET_Z1].support == PACKET_DISABLE)
-    error (_("Can't set hardware breakpoint without the '%s' (%s) packet."),
-	   remote_protocol_packets[PACKET_Z1].name,
-	   remote_protocol_packets[PACKET_Z1].title);
-
+    return -1;
+  
   *(p++) = 'Z';
   *(p++) = '1';
   *(p++) = ',';
@@ -4838,9 +4832,7 @@
   BREAKPOINT_FROM_PC (&addr, &len);
 
   if (remote_protocol_packets[PACKET_Z1].support == PACKET_DISABLE)
-    error (_("Can't clear hardware breakpoint without the '%s' (%s) packet."),
-	   remote_protocol_packets[PACKET_Z1].name,
-	   remote_protocol_packets[PACKET_Z1].title);
+    return -1;
 
   *(p++) = 'z';
   *(p++) = '1';