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/RFA] -break-insert -d


Presently, the -break-insert command always creates enabled breakpoint. Marc has noticed
that in Eclipse, with non-stop mode, this case lead to races. Specifically, if a breakpoint
is disabled in UI, then Eclipse first inserts a breakpoint, and then makes it disabled. So,
there's a window when the breakpoint is inserted in the target. One possible solution is
to modify Eclipse to never insert disabled breakpoint in GDB. However, this special-casing
has to be done in every frontend, and GDB-side solution is better. The below patch implements
new -d option to the -break-insert command, which causes the newly created breakpoints to be
disabled.

Is the breakpoint.c change OK. Any comments on MI changes?

Thanks,
Volodya

commit 32e2250c8755748d4a9d98343f9ba9b903d366a7
Author: Vladimir Prus <vladimir@codesourcery.com>
Date:   Mon Jan 26 16:10:17 2009 +0300

    Make it possible to create disabled breakpoint with -break-insert.
    
    	gdb/
    	* breakpoint.c (create_breakpoint, create_breakpoints)
    	(break_command_really, set_breakpoint): New parameter enabled.
    	(create_breakpoint, break_command_really): Make breakpoint
    	disabled if so requested.
    	* breakpoint.h (set_breakpoint): New parameter enabled.
    	* mi/mi-cmd-break.c (mi_cmd_break_insert): Handle the -d option.
    
    	gdb/doc/
    	* gdb.texinfo (GDB/MI Breakpoint Commands): Document the -d
    	option to -break-insert.
    
    	gdb/testsuite/
    	* gdb.mi/mi-break.exp (test_disabled_creation): New.
    	Call it.

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 65bbca9..1463bfb 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -5090,7 +5090,7 @@ create_breakpoint (struct symtabs_and_lines sals, char *addr_string,
 		   char *cond_string,
 		   enum bptype type, enum bpdisp disposition,
 		   int thread, int ignore_count, 
-		   struct breakpoint_ops *ops, int from_tty)
+		   struct breakpoint_ops *ops, int from_tty, int enabled)
 {
   struct breakpoint *b = NULL;
   int i;
@@ -5124,7 +5124,7 @@ create_breakpoint (struct symtabs_and_lines sals, char *addr_string,
   
 	  b->cond_string = cond_string;
 	  b->ignore_count = ignore_count;
-	  b->enable_state = bp_enabled;
+	  b->enable_state = enabled ? bp_enabled : bp_disabled;
 	  b->disposition = disposition;
 
 	  loc = b->loc;
@@ -5299,7 +5299,8 @@ create_breakpoints (struct symtabs_and_lines sals, char **addr_string,
 		    char *cond_string,
 		    enum bptype type, enum bpdisp disposition,
 		    int thread, int ignore_count, 
-		    struct breakpoint_ops *ops, int from_tty)
+		    struct breakpoint_ops *ops, int from_tty,
+		    int enabled)
 {
   int i;
   for (i = 0; i < sals.nelts; ++i)
@@ -5309,7 +5310,7 @@ create_breakpoints (struct symtabs_and_lines sals, char **addr_string,
 
       create_breakpoint (expanded, addr_string[i],
 			 cond_string, type, disposition,
-			 thread, ignore_count, ops, from_tty);
+			 thread, ignore_count, ops, from_tty, enabled);
     }
 
   update_global_location_list (1);
@@ -5481,7 +5482,8 @@ break_command_really (char *arg, char *cond_string, int thread,
 		      int ignore_count,
 		      enum auto_boolean pending_break_support,
 		      struct breakpoint_ops *ops,
-		      int from_tty)
+		      int from_tty,
+		      int enabled)
 {
   struct gdb_exception e;
   struct symtabs_and_lines sals;
@@ -5614,7 +5616,7 @@ break_command_really (char *arg, char *cond_string, int thread,
 			  hardwareflag ? bp_hardware_breakpoint 
 			  : bp_breakpoint,
 			  tempflag ? disp_del : disp_donttouch,
-			  thread, ignore_count, ops, from_tty);
+			  thread, ignore_count, ops, from_tty, enabled);
     }
   else
     {
@@ -5635,6 +5637,7 @@ break_command_really (char *arg, char *cond_string, int thread,
       b->disposition = tempflag ? disp_del : disp_donttouch;
       b->condition_not_parsed = 1;
       b->ops = ops;
+      b->enable_state = enabled ? bp_enabled : bp_disabled;
 
       update_global_location_list (1);
       mention (b);
@@ -5669,7 +5672,8 @@ break_command_1 (char *arg, int flag, int from_tty)
 			0 /* Ignore count */,
 			pending_break_support, 
 			NULL /* breakpoint_ops */,
-			from_tty);
+			from_tty,
+			1 /* enabled */);
 }
 
 
@@ -5677,7 +5681,7 @@ void
 set_breakpoint (char *address, char *condition,
 		int hardwareflag, int tempflag,
 		int thread, int ignore_count,
-		int pending)
+		int pending, int enabled)
 {
   break_command_really (address, condition, thread,
 			0 /* condition and thread are valid.  */,
@@ -5685,7 +5689,7 @@ set_breakpoint (char *address, char *condition,
 			ignore_count,
 			pending 
 			? AUTO_BOOLEAN_TRUE : AUTO_BOOLEAN_FALSE,
-			NULL, 0);
+			NULL, 0, enabled);
 }
 
 /* Adjust SAL to the first instruction past the function prologue.
@@ -6536,7 +6540,8 @@ handle_gnu_v3_exceptions (int tempflag, char *cond_string,
 			tempflag, 0,
 			0,
 			AUTO_BOOLEAN_TRUE /* pending */,
-			&gnu_v3_exception_catchpoint_ops, from_tty);
+			&gnu_v3_exception_catchpoint_ops, from_tty,
+			1 /* enabled */);
 
   return 1;
 }
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index b2db9eb..94287de 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -705,7 +705,8 @@ extern void tbreak_command (char *, int);
 extern void set_breakpoint (char *address, char *condition,
 			    int hardwareflag, int tempflag,
 			    int thread, int ignore_count,
-			    int pending);
+			    int pending,
+			    int enabled);
 
 extern void insert_breakpoints (void);
 
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 583d96c..18996e9 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -19911,7 +19911,7 @@ N.A.
 @subsubheading Synopsis
 
 @smallexample
- -break-insert [ -t ] [ -h ] [ -f ]
+ -break-insert [ -t ] [ -h ] [ -f ] [ -d ]
     [ -c @var{condition} ] [ -i @var{ignore-count} ]
     [ -p @var{thread} ] [ @var{location} ]
 @end smallexample
@@ -19946,6 +19946,8 @@ refers to unknown files or functions), create a pending
 breakpoint. Without this flag, @value{GDBN} will report
 an error, and won't create a breakpoint, if @var{location}
 cannot be parsed.
+@item -d
+Create a disabled breakpoint.
 @end table
 
 @subsubheading Result
diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c
index af14b0a..0de08ce 100644
--- a/gdb/mi/mi-cmd-break.c
+++ b/gdb/mi/mi-cmd-break.c
@@ -71,12 +71,14 @@ mi_cmd_break_insert (char *command, char **argv, int argc)
   int ignore_count = 0;
   char *condition = NULL;
   int pending = 0;
+  int enabled = 1;
+
   struct gdb_exception e;
   struct gdb_events *old_hooks;
   enum opt
     {
       HARDWARE_OPT, TEMP_OPT /*, REGEXP_OPT */ , CONDITION_OPT,
-      IGNORE_COUNT_OPT, THREAD_OPT, PENDING_OPT
+      IGNORE_COUNT_OPT, THREAD_OPT, PENDING_OPT, DISABLE_OPT
     };
   static struct mi_opt opts[] =
   {
@@ -86,6 +88,7 @@ mi_cmd_break_insert (char *command, char **argv, int argc)
     {"i", IGNORE_COUNT_OPT, 1},
     {"p", THREAD_OPT, 1},
     {"f", PENDING_OPT, 0},
+    {"d", DISABLE_OPT, 0},
     { 0, 0, 0 }
   };
 
@@ -123,6 +126,8 @@ mi_cmd_break_insert (char *command, char **argv, int argc)
 	case PENDING_OPT:
 	  pending = 1;
 	  break;
+	case DISABLE_OPT:
+	  enabled = 0;
 	}
     }
 
@@ -151,13 +156,13 @@ mi_cmd_break_insert (char *command, char **argv, int argc)
 	  set_breakpoint (address, condition,
 			  0 /*hardwareflag */ , temp_p,
 			  thread, ignore_count,
-			  pending);
+			  pending, enabled);
 	  break;
 	case HW_BP:
 	  set_breakpoint (address, condition,
 			  1 /*hardwareflag */ , temp_p,
 			  thread, ignore_count,
-			  pending);
+			  pending, enabled);
 	  break;
 #if 0
 	case REGEXP_BP:
diff --git a/gdb/testsuite/gdb.mi/mi-break.exp b/gdb/testsuite/gdb.mi/mi-break.exp
index 84dcf0a..6ea59fc 100644
--- a/gdb/testsuite/gdb.mi/mi-break.exp
+++ b/gdb/testsuite/gdb.mi/mi-break.exp
@@ -183,6 +183,20 @@ proc test_error {} {
         "update varobj for function call"    
 }
 
+proc test_disabled_creation {} {
+    global mi_gdb_prompt
+    global hex
+    global line_callee2_body
+
+    mi_gdb_test "-break-insert -d basics.c:callee2" \
+        "\\^done,bkpt=\{number=\"6\",type=\"breakpoint\",disp=\"keep\",enabled=\"n\",addr=\"$hex\",func=\"callee2\",file=\".*basics.c\",fullname=\".*\",line=\"$line_callee2_body\",times=\"0\",original-location=\".*\"\}" \
+        "test disabled creation"
+
+    mi_gdb_test "-break-delete" \
+	    "\\^done" \
+            "test disabled creation: cleanup"
+}
+
 test_tbreak_creation_and_listing
 test_rbreak_creation_and_listing
 
@@ -190,5 +204,7 @@ test_ignore_count
 
 test_error
 
+test_disabled_creation
+
 mi_gdb_exit
 return 0

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