This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[rfc] [06/18] Cell multi-arch: Temporary breakpoint insertion failures


Hello,

another minor infrastructure enhancement: the Cell target needs to prevent
breakpoint from being inserted during initial startup of a SPU stand-alone
executable.

The problem here is that while no target is running, the user is able to
insert breakpoints on symbols defined in the main SPU executable.  Those
will at this point have addresses in the SPU local store range (0 ... 256KB).

While the application is running, the SPU executable is relocated to a
combined address encoding SPU ID and local store address -- at this point
the breakpoint will be likewise relocated and can be inserted fine.

However, there is a point in-between, where the target has already started,
but has not yet created the SPU context for the main executable (so that
its ID and thus combined address range is not known yet).  During this
phase, the main breakpoint logic would attempt and fail to insert breakpoints
at the original LS addresses.

This patch allows for the target to return an indication from the
target_insert_breakpoint and related routines that it is currently not
possible to insert a breakpoint, but this is just a temporary condition,
so no error should be reported and the breakpoint should be re-inserted
the next time something changes (i.e. breakpoint_re_set is called).

I've chosen to extend the existing return value (which is supposed to be
0 on success and (positive) errno value on failure) of target_insert_breakpoint
by interpreting *negative* values as "temporary failures".

A couple of existing implementations (i386-nat, remote) unfortunatley
already used negative return values to indicate failure, so the patch
changes those to use positive values instead.

Bye,
Ulrich


ChangeLog:

	* breakpoint.c (insert_breakpoint): Treat negative return values
	from target_insert_breakpoint or target_insert_hw_breakpoint as
	temporary issues; do not throw an error.
	(remove_breakpoint): Likewise for target_remove_breakpoint and
	target_remove_hw_breakpoint.

	* i386-nat.c (i386_remove_hw_breakpoint): Return positive value
	on failure.
	* remote.c (remote_insert_breakpoint): Likewise.
	(remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Likewise.


Index: src/gdb/breakpoint.c
===================================================================
--- src.orig/gdb/breakpoint.c
+++ src/gdb/breakpoint.c
@@ -1162,7 +1162,7 @@ Note: automatically using hardware break
 		  bpt->overlay_target_info = bpt->target_info;
 		  bpt->overlay_target_info.placed_address = addr;
 		  val = target_insert_breakpoint (&bpt->overlay_target_info);
-		  if (val != 0)
+		  if (val > 0)
 		    fprintf_unfiltered (tmp_error_stream, 
 					"Overlay breakpoint %d failed: in ROM?", 
 					bpt->owner->number);
@@ -1185,6 +1185,14 @@ Note: automatically using hardware break
 	    }
 	}
 
+      if (val < 0)
+	{
+	  /* The target could not insert the breakpoint right away due
+	     to a temporary issue.  No error, but do not mark the bp
+	     as 'inserted'.  */
+	  return 0;
+	}
+
       if (val)
 	{
 	  /* Can't set the breakpoint.  */
@@ -1666,6 +1674,14 @@ remove_breakpoint (struct bp_location *b
 	    }
 	}
 
+      if (val < 0)
+	{
+	  /* The target could not remove the breakpoint right away due
+	     to a temporary issue.  No error, but keep the bp marked
+	     as 'inserted'.  */
+	  return 0;
+	}
+
       /* In some cases, we might not be able to remove a breakpoint
 	 in a shared library that has already been removed, but we
 	 have not yet processed the shlib unload event.  */
Index: src/gdb/i386-nat.c
===================================================================
--- src.orig/gdb/i386-nat.c
+++ src/gdb/i386-nat.c
@@ -640,14 +640,14 @@ i386_insert_hw_breakpoint (struct bp_tar
 }
 
 /* Remove a hardware-assisted breakpoint at BP_TGT->placed_address.
-   Return 0 on success, -1 on failure.  */
+   Return 0 on success, EBUSY on failure.  */
 
 int
 i386_remove_hw_breakpoint (struct bp_target_info *bp_tgt)
 {
   unsigned len_rw = i386_length_and_rw_bits (1, hw_execute);
   CORE_ADDR addr = bp_tgt->placed_address;
-  int retval = i386_remove_aligned_watchpoint (addr, len_rw);
+  int retval = i386_remove_aligned_watchpoint (addr, len_rw) ? EBUSY : 0;
 
   if (maint_show_dr)
     i386_show_dr ("remove_hwbp", addr, 1, hw_execute);
Index: src/gdb/remote.c
===================================================================
--- src.orig/gdb/remote.c
+++ src/gdb/remote.c
@@ -5396,7 +5396,7 @@ remote_insert_breakpoint (struct bp_targ
       switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_Z0]))
 	{
 	case PACKET_ERROR:
-	  return -1;
+	  return 1;
 	case PACKET_OK:
 	  bp_tgt->placed_address = addr;
 	  bp_tgt->placed_size = bpsize;
@@ -5583,7 +5583,7 @@ remote_insert_hw_breakpoint (struct bp_t
     (target_gdbarch, &bp_tgt->placed_address, &bp_tgt->placed_size);
 
   if (remote_protocol_packets[PACKET_Z1].support == PACKET_DISABLE)
-    return -1;
+    return 1;
 
   rs = get_remote_state ();
   p = rs->buf;
@@ -5603,7 +5603,7 @@ remote_insert_hw_breakpoint (struct bp_t
     {
     case PACKET_ERROR:
     case PACKET_UNKNOWN:
-      return -1;
+      return 1;
     case PACKET_OK:
       return 0;
     }
@@ -5620,7 +5620,7 @@ remote_remove_hw_breakpoint (struct bp_t
   char *p = rs->buf;
 
   if (remote_protocol_packets[PACKET_Z1].support == PACKET_DISABLE)
-    return -1;
+    return 1;
 
   *(p++) = 'z';
   *(p++) = '1';
@@ -5637,7 +5637,7 @@ remote_remove_hw_breakpoint (struct bp_t
     {
     case PACKET_ERROR:
     case PACKET_UNKNOWN:
-      return -1;
+      return 1;
     case PACKET_OK:
       return 0;
     }
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]