Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Grace Sainsbury <graces@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: breakpoint error messages
Date: Wed, 21 Aug 2002 11:26:00 -0000	[thread overview]
Message-ID: <20020821142627.A10117@tomago.toronto.redhat.com> (raw)

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

I changed insert_breakpoints to collect all the warning messages from
failed inserts and print them with an error after trying the whole
queue. This changes the functionality slightly -- the old code stopped
after the first failed insert of a breakpoint. I also changed the
error messages to be more explicit about hardware breakpoints.

ok?

grace

2002-08-21  Grace Sainsbury  <graces@redhat.com>

	* infrun.c (normal_stop, proceed): Remove call to print_sys_errmsg
	when breakpoints fail. Move general breakpoint error messages to
	insert_breakpoints.	
	* breakpoint.c (insert_breakpoints): Change warnings when
	breakpoints are nto inserted to specify the type. Remove call to
	memory_error when breakpoints can't be inserted. Remove multiple
	calls to warning so all messages are sent to the user at once.
	(delete_breakpoints): Make insert error messsages more explicit.


[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 7007 bytes --]

Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.81
diff -u -r1.81 breakpoint.c
--- breakpoint.c	20 Aug 2002 20:03:35 -0000	1.81
+++ breakpoint.c	21 Aug 2002 18:16:45 -0000
@@ -715,10 +715,13 @@
   int return_val = 0;	/* return success code. */
   int val = 0;
   int disabled_breaks = 0;
-
+  int hw_breakpoint_error = 0;
+  
   static char message1[] = "Error inserting catchpoint %d:\n";
   static char message[sizeof (message1) + 30];
 
+  struct ui_file *tmp_error_stream = mem_fileopen ();
+  make_cleanup_ui_file_delete (tmp_error_stream);
 
   ALL_BREAKPOINTS_SAFE (b, temp)
   {
@@ -776,8 +779,9 @@
 		    /* Set a software (trap) breakpoint at the LMA.  */
 		    val = target_insert_breakpoint (addr, b->shadow_contents);
 		    if (val != 0)
-		      warning ("overlay breakpoint %d failed: in ROM?", 
-			       b->number);
+		      fprintf_unfiltered (tmp_error_stream, 
+					  "Overlay breakpoint %d failed: in ROM?", 
+					  b->number);
 		  }
 	      }
 	    /* Shall we set a breakpoint at the VMA? */
@@ -810,22 +814,29 @@
 		b->enable_state = bp_shlib_disabled;
 		if (!disabled_breaks)
 		  {
-		    target_terminal_ours_for_output ();
-		    warning ("Cannot insert breakpoint %d:", b->number);
-		    warning ("Temporarily disabling shared library breakpoints:");
+		    fprintf_unfiltered (tmp_error_stream, 
+					"Cannot insert breakpoint %d.\n", b->number);
+		    fprintf_unfiltered (tmp_error_stream, 
+					"Temporarily disabling shared library breakpoints:\n");
 		  }
 		disabled_breaks = 1;
-		warning ("breakpoint #%d ", b->number);
+		fprintf_unfiltered (tmp_error_stream, "breakpoint #%d\n", b->number);
 	      }
 	    else
 #endif
 	      {
-		target_terminal_ours_for_output ();
-		warning ("Cannot insert breakpoint %d:", b->number);
-#ifdef ONE_PROCESS_WRITETEXT
-		warning ("The same program may be running in another process.");
-#endif
-		memory_error (val, b->address);	   /* which bombs us out */
+		if (b->type == bp_hardware_breakpoint)
+		  {
+		    hw_breakpoint_error = 1;
+		    fprintf_unfiltered (tmp_error_stream, 
+					"Cannot insert hardware breakpoint %d.\n",
+					b->number);
+		  }
+		else
+		  {
+		    fprintf_unfiltered (tmp_error_stream, "Cannot insert breakpoint %d.\n", b->number);
+		  }
+
 	      }
 	  }
 	else
@@ -852,9 +863,9 @@
 	if (val)
 	  {
 	    /* Couldn't set breakpoint for some reason */
-	    target_terminal_ours_for_output ();
-	    warning ("Cannot insert catchpoint %d; disabling it.",
-		     b->number);
+	    fprintf_unfiltered (tmp_error_stream, 
+				"Cannot insert catchpoint %d; disabling it.\n",
+				b->number);
 	    b->enable_state = bp_disabled;
 	  }
 	else
@@ -876,9 +887,9 @@
 	    if (val == -1)
 	      {
 		/* something went wrong */
-		target_terminal_ours_for_output ();
-		warning ("Cannot insert catchpoint %d; disabling it.",
-			 b->number);
+		fprintf_unfiltered (tmp_error_stream, 
+				    "Cannot insert catchpoint %d; disabling it.\n",
+				    b->number);
 		b->enable_state = bp_disabled;
 	      }
 	  }
@@ -955,7 +966,7 @@
 
 			addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
 			len = TYPE_LENGTH (VALUE_TYPE (v));
-			type   = hw_write;
+			type = hw_write;
 			if (b->type == bp_read_watchpoint)
 			  type = hw_read;
 			else if (b->type == bp_access_watchpoint)
@@ -981,8 +992,9 @@
 	    if (!b->inserted)
 	      {
 		remove_breakpoint (b, mark_uninserted);
-		warning ("Could not insert hardware watchpoint %d.",
-			 b->number);
+		hw_breakpoint_error = 1;
+		fprintf_unfiltered (tmp_error_stream,
+				    "Cannot insert hardware watchpoint %d.\n", b->number);
 		val = -1;
 	      }               
 	  }
@@ -1029,8 +1041,7 @@
 	  }
 	if (val < 0)
 	  {
-	    target_terminal_ours_for_output ();
-	    warning ("Cannot insert catchpoint %d.", b->number);
+	    fprintf_unfiltered (tmp_error_stream, "Cannot insert catchpoint %d.", b->number);
 	  }
 	else
 	  b->inserted = 1;
@@ -1039,11 +1050,25 @@
 	  return_val = val;	/* remember failure */
       }
   }
-
+  
+  if (return_val) 
+    {
+      /* If a hardware breakpoint or watchpoint was inserted add a
+         message about possibly exhausted resources.  */
+      if (hw_breakpoint_error)  
+	{
+	  fprintf_unfiltered (tmp_error_stream, "Could not insert breakpoints:\n" 
+			      "You may have requested too many hardware breakpoints/watchpoints.");
+	}
+#ifdef ONE_PROCESS_WRITETEXT
+      fprintf_unfiltered (tmp_error_stream,"The same program may be running in another process.\n");
+#endif
+      target_terminal_ours_for_output ();
+      error_stream (tmp_error_stream);
+    }
   return return_val;
 }
 
-
 int
 remove_breakpoints (void)
 {
@@ -6681,11 +6706,24 @@
 	  else
 	    val = target_insert_breakpoint (b->address, b->shadow_contents);
 
+	  /* If there wat an error in the insert, print a pessage then stop execution.  */
 	  if (val != 0)
 	    {
+	      struct ui_file *tmp_error_stream = mem_fileopen ();
+	      make_cleanup_ui_file_delete (tmp_error_stream);
+	     
+	      if (b->type == bp_hardware_breakpoint)
+		{
+		  fprintf_unfiltered (tmp_error_stream, 
+				      "Cannot insert hardware breakpoint %d:", b->number);
+		}
+	      else
+		{
+		  fprintf_unfiltered (tmp_error_stream, 
+				      "Cannot insert breakpoint %d:", b->number);
+		}
 	      target_terminal_ours_for_output ();
-	      warning ("Cannot insert breakpoint %d:", b->number);
-	      memory_error (val, b->address);	/* which bombs us out */
+	      error_stream(tmp_error_stream); 
 	    }
 	  else
 	    b->inserted = 1;
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.68
diff -u -r1.68 infrun.c
--- infrun.c	20 Aug 2002 23:01:29 -0000	1.68
+++ infrun.c	21 Aug 2002 18:16:47 -0000
@@ -990,16 +990,9 @@
     trap_expected = 1;
   else
     {
-      int temp = insert_breakpoints ();
-      if (temp)
-	{
-	  print_sys_errmsg ("insert_breakpoints", temp);
-	  error ("Cannot insert breakpoints.\n\
-The same program may be running in another process,\n\
-or you may have requested too many hardware\n\
-breakpoints and/or watchpoints.\n");
-	}
-
+      insert_breakpoints ();
+      /* If we get here there was no call to error() in 
+	 insert breakpoints -- so they were inserted.  */
       breakpoints_inserted = 1;
     }
 
@@ -3378,16 +3371,6 @@
      DECR_PC_AFTER_BREAK */
   if (target_has_execution && get_current_frame ())
     (get_current_frame ())->pc = read_pc ();
-
-  if (breakpoints_failed)
-    {
-      target_terminal_ours_for_output ();
-      print_sys_errmsg ("While inserting breakpoints", breakpoints_failed);
-      printf_filtered ("Stopped; cannot insert breakpoints.\n\
-The same program may be running in another process,\n\
-or you may have requested too many hardware breakpoints\n\
-and/or watchpoints.\n");
-    }
 
   if (target_has_execution && breakpoints_inserted)
     {

             reply	other threads:[~2002-08-21 18:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-21 11:26 Grace Sainsbury [this message]
2002-08-22  0:59 ` Eli Zaretskii
2002-08-22 14:24 ` Michael Snyder
2002-08-22 14:38   ` Grace Sainsbury
2002-08-22 15:26     ` Michael Snyder
2002-08-23  9:27       ` Grace Sainsbury
2002-08-23 11:51         ` Michael Snyder
2002-08-24  2:18         ` 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=20020821142627.A10117@tomago.toronto.redhat.com \
    --to=graces@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