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]

Re: [PATCH] Let gdbserver doesn't tell GDB it support target-side breakpoint conditions and commands if it doesn't support 'Z' packet


On 12/07/13 03:29, Pedro Alves wrote:
Please analyze the insert_bp_location's error handling carefully:

- if solib_name_from_address is true (the dprintf is set in a
   shared library), we won't see this new error message, while
   we should.

I change all this part to:
First, output error message.
Second, if it is solib breakpoint, disable breakpoint.

- 'hw_bp_err_string' ends up misnamed after this patch.

Change it to "bp_err_string".



Post a new patch according to your comments.
This patch is tested and pass the regression test in x86_64 linux.

Please help me review it.

Thanks,
Hui

2013-12-08  Hui Zhu  <hui@codesourcery.com>

	PR gdb/16101
	* breakpoint.c (insert_bp_location): Change hw_bp_err_string to
	bp_err_string.
	Output error message of software breakpoints.
	Make solib error message output use same code with hardware
	breakpoints and software breakpoints.
	* remote.c (remote_insert_breakpoint): If this breakpoint has
	target-side commands but this stub doesn't support Z0 packets,
	throw error.

--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2396,7 +2396,7 @@ insert_bp_location (struct bp_location *
 		    int *hw_bp_error_explained_already)
 {
   int val = 0;
-  char *hw_bp_err_string = NULL;
+  char *bp_err_string = NULL;
   struct gdb_exception e;
if (!should_be_inserted (bl) || (bl->inserted && !bl->needs_update))
@@ -2501,7 +2501,7 @@ insert_bp_location (struct bp_location *
 	  if (e.reason < 0)
 	    {
 	      val = 1;
-	      hw_bp_err_string = (char *) e.message;
+	      bp_err_string = (char *) e.message;
 	    }
 	}
       else
@@ -2543,7 +2543,7 @@ insert_bp_location (struct bp_location *
 	      if (e.reason < 0)
 	        {
 	          val = 1;
-	          hw_bp_err_string = (char *) e.message;
+	          bp_err_string = (char *) e.message;
 	        }
 	    }
 	  else
@@ -2557,6 +2557,36 @@ insert_bp_location (struct bp_location *
       if (val)
 	{
 	  /* Can't set the breakpoint.  */
+	  if (bl->loc_type == bp_loc_hardware_breakpoint)
+	    {
+	      *hw_breakpoint_error = 1;
+	      *hw_bp_error_explained_already = bp_err_string != NULL;
+	      fprintf_unfiltered (tmp_error_stream,
+				  "Cannot insert hardware breakpoint %d%s",
+				  bl->owner->number, bp_err_string ? ":" : ".\n");
+	      if (bp_err_string)
+		fprintf_unfiltered (tmp_error_stream, "%s.\n", bp_err_string);
+	    }
+	  else if (bp_err_string != NULL)
+	    {
+	      fprintf_unfiltered (tmp_error_stream,
+				  "Cannot insert breakpoint %d:%s\n",
+				  bl->owner->number, bp_err_string);
+	    }
+	  else
+	    {
+	      char *message = memory_error_message (TARGET_XFER_E_IO,
+						    bl->gdbarch, bl->address);
+	      struct cleanup *old_chain = make_cleanup (xfree, message);
+
+	      fprintf_unfiltered (tmp_error_stream,
+				  "Cannot insert breakpoint %d.\n"
+				  "%s\n",
+				  bl->owner->number, message);
+
+	      do_cleanups (old_chain);
+	    }
+
 	  if (solib_name_from_address (bl->pspace, bl->address))
 	    {
 	      /* See also: disable_breakpoints_in_shlibs.  */
@@ -2564,45 +2594,13 @@ insert_bp_location (struct bp_location *
 	      bl->shlib_disabled = 1;
 	      observer_notify_breakpoint_modified (bl->owner);
 	      if (!*disabled_breaks)
-		{
-		  fprintf_unfiltered (tmp_error_stream,
-				      "Cannot insert breakpoint %d.\n",
-				      bl->owner->number);
-		  fprintf_unfiltered (tmp_error_stream,
-				      "Temporarily disabling shared "
-				      "library breakpoints:\n");
-		}
+		fprintf_unfiltered (tmp_error_stream,
+				    "Temporarily disabling shared "
+				    "library breakpoints:\n");
 	      *disabled_breaks = 1;
 	      fprintf_unfiltered (tmp_error_stream,
 				  "breakpoint #%d\n", bl->owner->number);
 	    }
-	  else
-	    {
-	      if (bl->loc_type == bp_loc_hardware_breakpoint)
-		{
-                  *hw_breakpoint_error = 1;
-                  *hw_bp_error_explained_already = hw_bp_err_string != NULL;
-                  fprintf_unfiltered (tmp_error_stream,
-                                      "Cannot insert hardware breakpoint %d%s",
-                                      bl->owner->number, hw_bp_err_string ? ":" : ".\n");
-                  if (hw_bp_err_string)
-                    fprintf_unfiltered (tmp_error_stream, "%s.\n", hw_bp_err_string);
-		}
-	      else
-		{
-		  char *message = memory_error_message (TARGET_XFER_E_IO,
-							bl->gdbarch, bl->address);
-		  struct cleanup *old_chain = make_cleanup (xfree, message);
-
-		  fprintf_unfiltered (tmp_error_stream,
-				      "Cannot insert breakpoint %d.\n"
-				      "%s\n",
-				      bl->owner->number, message);
-
-		  do_cleanups (old_chain);
-		}
-
-	    }
 	}
       else
 	bl->inserted = 1;
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -8260,6 +8260,12 @@ remote_insert_breakpoint (struct gdbarch
 	}
     }
+ /* If this breakpoint has target-side commands but this stub doesn't
+     support Z0 packets, throw error.  */
+  if (!VEC_empty (agent_expr_p, bp_tgt->tcommands))
+    error (_("\
+Target doesn't support breakpoints that have target side commands."));
+
   return memory_insert_breakpoint (gdbarch, bp_tgt);
 }

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