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] Fix error when gdb connect to a stub that tracepoint is running[2/2] add inserted to create_breakpoint


On 01/31/2012 02:05 AM, Hui Zhu wrote:
> Hi,
> 
> If we got a tracepoint from gdbstub part, we will create it.
> If the tracepoint is running and the gdbstub support tracepoint running insert, create_breakpoint will insert this tracepoint that get from gdbstub to gdbstub.
> This is an issue.
> So this patch add a flags to create_breakpoint to let this function know that this breakpoint already inserted.
> 
> 2012-01-31  Hui Zhu  <hui_zhu@mentor.com>
> 
>     * breakpoint.h (CREATE_BREAKPOINT_FLAGS_INSERTED): New macro.
>     (create_breakpoint): Add new argument flags.
>     * breakpoint.c (create_breakpoint): Add new argument flags.
>     if flags include CREATE_BREAKPOINT_FLAGS_INSERTED, set breakpoint
>     to inserted.
>     (handle_gnu_v3_exceptions): Add new argument flags to
>     function create_breakpoint.
>     (trace_command): Ditto.
>     (ftrace_command): Ditto.
>     (strace_command): Ditto.
>     (create_tracepoint_from_upload): Ditto.
>     * mi/mi-cmd-break.c (mi_cmd_break_insert): Ditto.
>     * python/py-breakpoint.c (bppy_init): Ditto.
>     * python/py-finishbreakpoint.c (bpfinishpy_init): Ditto.
>     * spu-tdep.c (spu_catch_start): Ditto.

I think the idea is good, but the implementation didn't go far enough.

Particularly, I'd rather pass the flag further down, than doing this:

On 01/31/2012 02:05 AM, Hui Zhu wrote:
> @@ -8245,7 +8245,25 @@ create_breakpoint (struct gdbarch *gdbar
>
>        install_breakpoint (internal, b, 0);
>      }
> -
> +
> +  if (flags & CREATE_BREAKPOINT_FLAGS_INSERTED)
> +    {
> +      struct breakpoint *b = NULL;
> +
> +      ALL_BREAKPOINTS (b)
> +	{
> +	  if (b->number == breakpoint_count)
> +            break;
> +	}
> +      if (b)
> +	{
> +	  struct bp_location *bl;
> +
> +	  for (bl = b->loc; bl; bl = bl->next)
> +            bl->inserted = 1;
> +	}
> +    }
> +

I've also added comments explaining what are these flags, and what does
the new flag mean.

WDYT?

2012-03-01  Hui Zhu  <hui_zhu@mentor.com>
	    Pedro Alves  <palves@redhat.com>

	* breakpoint.c (init_breakpoint_sal): New flags parameter.  Handle
	CREATE_BREAKPOINT_FLAGS_INSERTED.
	(create_breakpoint_sal, create_breakpoints_sal)
	(base_breakpoint_create_breakpoints_sal)
	(tracepoint_create_breakpoints_sal)
	(strace_marker_create_breakpoints_sal): New flags parameter.  Pass
	down.
	(break_command_1, handle_gnu_v3_exceptions, trace_command)
	(ftrace_command, strace_command): Adjust.
	(create_tracepoint_from_upload): Pass
	CREATE_BREAKPOINT_FLAGS_INSERTED.
	* breakpoint.h (enum breakpoint_create_flags): New.
	(create_breakpoint): New flags parameter.
	* mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust.
	* python/py-breakpoint.c (bppy_init): Adjust.
	* python/py-finishbreakpoint.c (bpfinishpy_init): Adjust.
	* spu-tdep.c (spu_catch_start): Adjust.

---

 gdb/breakpoint.c                 |   58 +++++++++++++++++++++++---------------
 gdb/breakpoint.h                 |   14 ++++++++-
 gdb/mi/mi-cmd-break.c            |    2 +
 gdb/python/py-breakpoint.c       |    2 +
 gdb/python/py-finishbreakpoint.c |    2 +
 gdb/spu-tdep.c                   |    2 +
 6 files changed, 51 insertions(+), 29 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 311c451..3eb0039 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -112,7 +112,7 @@ static void create_breakpoints_sal_default (struct gdbarch *,
 					    enum bpdisp, int, int,
 					    int,
 					    const struct breakpoint_ops *,
-					    int, int, int);
+					    int, int, int, unsigned);

 static void decode_linespec_default (struct breakpoint *, char **,
 				     struct symtabs_and_lines *);
@@ -8205,7 +8205,8 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch,
 		     enum bptype type, enum bpdisp disposition,
 		     int thread, int task, int ignore_count,
 		     const struct breakpoint_ops *ops, int from_tty,
-		     int enabled, int internal, int display_canonical)
+		     int enabled, int internal, unsigned flags,
+		     int display_canonical)
 {
   int i;

@@ -8251,6 +8252,9 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch,
 	  b->enable_state = enabled ? bp_enabled : bp_disabled;
 	  b->disposition = disposition;

+	  if ((flags & CREATE_BREAKPOINT_FLAGS_INSERTED) != 0)
+	    b->loc->inserted = 1;
+
 	  if (type == bp_static_tracepoint)
 	    {
 	      struct tracepoint *t = (struct tracepoint *) b;
@@ -8294,6 +8298,8 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch,
       else
 	{
 	  loc = add_location_to_breakpoint (b, &sal);
+	  if ((flags & CREATE_BREAKPOINT_FLAGS_INSERTED) != 0)
+	    loc->inserted = 1;
 	}

       if (bp_loc_is_permanent (loc))
@@ -8326,7 +8332,8 @@ create_breakpoint_sal (struct gdbarch *gdbarch,
 		       enum bptype type, enum bpdisp disposition,
 		       int thread, int task, int ignore_count,
 		       const struct breakpoint_ops *ops, int from_tty,
-		       int enabled, int internal, int display_canonical)
+		       int enabled, int internal, unsigned flags,
+		       int display_canonical)
 {
   struct breakpoint *b;
   struct cleanup *old_chain;
@@ -8349,7 +8356,8 @@ create_breakpoint_sal (struct gdbarch *gdbarch,
 		       type, disposition,
 		       thread, task, ignore_count,
 		       ops, from_tty,
-		       enabled, internal, display_canonical);
+		       enabled, internal, flags,
+		       display_canonical);
   discard_cleanups (old_chain);

   install_breakpoint (internal, b, 0);
@@ -8377,7 +8385,7 @@ create_breakpoints_sal (struct gdbarch *gdbarch,
 			enum bptype type, enum bpdisp disposition,
 			int thread, int task, int ignore_count,
 			const struct breakpoint_ops *ops, int from_tty,
-			int enabled, int internal)
+			int enabled, int internal, unsigned flags)
 {
   int i;
   struct linespec_sals *lsal;
@@ -8401,7 +8409,7 @@ create_breakpoints_sal (struct gdbarch *gdbarch,
 			     filter_string,
 			     cond_string, type, disposition,
 			     thread, task, ignore_count, ops,
-			     from_tty, enabled, internal,
+			     from_tty, enabled, internal, flags,
 			     canonical->special_display);
       discard_cleanups (inner);
     }
@@ -8661,7 +8669,8 @@ create_breakpoint (struct gdbarch *gdbarch,
 		   int ignore_count,
 		   enum auto_boolean pending_break_support,
 		   const struct breakpoint_ops *ops,
-		   int from_tty, int enabled, int internal)
+		   int from_tty, int enabled, int internal,
+		   unsigned flags)
 {
   volatile struct gdb_exception e;
   char *copy_arg = NULL;
@@ -8801,7 +8810,7 @@ create_breakpoint (struct gdbarch *gdbarch,
 				   cond_string, type_wanted,
 				   tempflag ? disp_del : disp_donttouch,
 				   thread, task, ignore_count, ops,
-				   from_tty, enabled, internal);
+				   from_tty, enabled, internal, flags);
     }
   else
     {
@@ -8877,7 +8886,8 @@ break_command_1 (char *arg, int flag, int from_tty)
 		     &bkpt_breakpoint_ops,
 		     from_tty,
 		     1 /* enabled */,
-		     0 /* internal */);
+		     0 /* internal */,
+		     0);
 }

 /* Helper function for break_command_1 and disassemble_command.  */
@@ -10752,7 +10762,8 @@ handle_gnu_v3_exceptions (int tempflag, char *cond_string,
 		     AUTO_BOOLEAN_TRUE /* pending */,
 		     &gnu_v3_exception_catchpoint_ops, from_tty,
 		     1 /* enabled */,
-		     0 /* internal */);
+		     0 /* internal */,
+		     0);

   return 1;
 }
@@ -11979,7 +11990,7 @@ base_breakpoint_create_breakpoints_sal (struct gdbarch *gdbarch,
 					int task, int ignore_count,
 					const struct breakpoint_ops *o,
 					int from_tty, int enabled,
-					int internal)
+					int internal, unsigned flags)
 {
   internal_error_pure_virtual_called ();
 }
@@ -12181,13 +12192,13 @@ bkpt_create_breakpoints_sal (struct gdbarch *gdbarch,
 			     int task, int ignore_count,
 			     const struct breakpoint_ops *ops,
 			     int from_tty, int enabled,
-			     int internal)
+			     int internal, unsigned flags)
 {
   create_breakpoints_sal_default (gdbarch, canonical, lsal,
 				  cond_string, type_wanted,
 				  disposition, thread, task,
 				  ignore_count, ops, from_tty,
-				  enabled, internal);
+				  enabled, internal, flags);
 }

 static void
@@ -12451,13 +12462,13 @@ tracepoint_create_breakpoints_sal (struct gdbarch *gdbarch,
 				   int task, int ignore_count,
 				   const struct breakpoint_ops *ops,
 				   int from_tty, int enabled,
-				   int internal)
+				   int internal, unsigned flags)
 {
   create_breakpoints_sal_default (gdbarch, canonical, lsal,
 				  cond_string, type_wanted,
 				  disposition, thread, task,
 				  ignore_count, ops, from_tty,
-				  enabled, internal);
+				  enabled, internal, flags);
 }

 static void
@@ -12500,7 +12511,7 @@ strace_marker_create_breakpoints_sal (struct gdbarch *gdbarch,
 				      int task, int ignore_count,
 				      const struct breakpoint_ops *ops,
 				      int from_tty, int enabled,
-				      int internal)
+				      int internal, unsigned flags)
 {
   int i;

@@ -12529,7 +12540,7 @@ strace_marker_create_breakpoints_sal (struct gdbarch *gdbarch,
 			   addr_string, NULL,
 			   cond_string, type_wanted, disposition,
 			   thread, task, ignore_count, ops,
-			   from_tty, enabled, internal,
+			   from_tty, enabled, internal, flags,
 			   canonical->special_display);
       /* Given that its possible to have multiple markers with
 	 the same string id, if the user is creating a static
@@ -13234,12 +13245,12 @@ create_breakpoints_sal_default (struct gdbarch *gdbarch,
 				int task, int ignore_count,
 				const struct breakpoint_ops *ops,
 				int from_tty, int enabled,
-				int internal)
+				int internal, unsigned flags)
 {
   create_breakpoints_sal (gdbarch, canonical, cond_string,
 			  type_wanted, disposition,
 			  thread, task, ignore_count, ops, from_tty,
-			  enabled, internal);
+			  enabled, internal, flags);
 }

 /* Decode the line represented by S by calling decode_line_full.  This is the
@@ -14109,7 +14120,7 @@ trace_command (char *arg, int from_tty)
 			 &tracepoint_breakpoint_ops,
 			 from_tty,
 			 1 /* enabled */,
-			 0 /* internal */))
+			 0 /* internal */, 0))
     set_tracepoint_count (breakpoint_count);
 }

@@ -14126,7 +14137,7 @@ ftrace_command (char *arg, int from_tty)
 			 &tracepoint_breakpoint_ops,
 			 from_tty,
 			 1 /* enabled */,
-			 0 /* internal */))
+			 0 /* internal */, 0))
     set_tracepoint_count (breakpoint_count);
 }

@@ -14154,7 +14165,7 @@ strace_command (char *arg, int from_tty)
 			 ops,
 			 from_tty,
 			 1 /* enabled */,
-			 0 /* internal */))
+			 0 /* internal */, 0))
     set_tracepoint_count (breakpoint_count);
 }

@@ -14219,7 +14230,8 @@ create_tracepoint_from_upload (struct uploaded_tp *utp)
 			  &tracepoint_breakpoint_ops,
 			  0 /* from_tty */,
 			  utp->enabled /* enabled */,
-			  0 /* internal */))
+			  0 /* internal */,
+			  CREATE_BREAKPOINT_FLAGS_INSERTED))
     return NULL;

   set_tracepoint_count (breakpoint_count);
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 7e8c597..eea1aa9 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -550,7 +550,7 @@ struct breakpoint_ops
 				  struct linespec_sals *, char *,
 				  enum bptype, enum bpdisp, int, int,
 				  int, const struct breakpoint_ops *,
-				  int, int, int);
+				  int, int, int, unsigned);

   /* Given the address string (second parameter), this method decodes it
      and provides the SAL locations related to it.  For ordinary breakpoints,
@@ -1193,6 +1193,16 @@ extern void
 extern void install_breakpoint (int internal, struct breakpoint *b,
 				int update_gll);

+/* Flags that can be passed down to create_breakpoint, etc., to affect
+   breakpoint creation in several ways.  */
+
+enum breakpoint_create_flags
+  {
+    /* We're adding a breakpoint to our tables that is already
+       inserted in the target.  */
+    CREATE_BREAKPOINT_FLAGS_INSERTED = 1 << 0
+  };
+
 extern int create_breakpoint (struct gdbarch *gdbarch, char *arg,
 			      char *cond_string, int thread,
 			      int parse_condition_and_thread,
@@ -1202,7 +1212,7 @@ extern int create_breakpoint (struct gdbarch *gdbarch, char *arg,
 			      const struct breakpoint_ops *ops,
 			      int from_tty,
 			      int enabled,
-			      int internal);
+			      int internal, unsigned flags);

 extern void insert_breakpoints (void);

diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c
index 7c89a3f..0069e26 100644
--- a/gdb/mi/mi-cmd-break.c
+++ b/gdb/mi/mi-cmd-break.c
@@ -168,7 +168,7 @@ mi_cmd_break_insert (char *command, char **argv, int argc)
 		     temp_p, type_wanted,
 		     ignore_count,
 		     pending ? AUTO_BOOLEAN_TRUE : AUTO_BOOLEAN_FALSE,
-		     &bkpt_breakpoint_ops, 0, enabled, 0);
+		     &bkpt_breakpoint_ops, 0, enabled, 0, 0);
   do_cleanups (back_to);

 }
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index 195ed2b..0c84d03 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -627,7 +627,7 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
 			       0,
 			       AUTO_BOOLEAN_TRUE,
 			       &bkpt_breakpoint_ops,
-			       0, 1, internal_bp);
+			       0, 1, internal_bp, 0);
 	    break;
 	  }
         case bp_watchpoint:
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
index bfbf9c3..b67b163 100644
--- a/gdb/python/py-finishbreakpoint.c
+++ b/gdb/python/py-finishbreakpoint.c
@@ -288,7 +288,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
                          0,
                          AUTO_BOOLEAN_TRUE,
                          &bkpt_breakpoint_ops,
-                         0, 1, internal_bp);
+                         0, 1, internal_bp, 0);
     }
   GDB_PY_SET_HANDLE_EXCEPTION (except);

diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c
index 17dae90..78ba007 100644
--- a/gdb/spu-tdep.c
+++ b/gdb/spu-tdep.c
@@ -1947,7 +1947,7 @@ spu_catch_start (struct objfile *objfile)
 		     0 /* ignore_count */,
 		     AUTO_BOOLEAN_FALSE /* pending_break_support */,
 		     &bkpt_breakpoint_ops /* ops */, 0 /* from_tty */,
-		     1 /* enabled */, 0 /* internal  */);
+		     1 /* enabled */, 0 /* internal  */, 0);
 }



-- 
Pedro Alves


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