Simplify MI breakpoint setting.
authorVladimir Prus <vladimir@codesourcery.com>
Tue, 16 Mar 2010 08:42:20 +0000 (08:42 +0000)
committerVladimir Prus <vladimir@codesourcery.com>
Tue, 16 Mar 2010 08:42:20 +0000 (08:42 +0000)
     * breakpoint.c (break_command_really): Make nonstatic and
     rename to...
     (create_breakpoint): ...this. Rename prior function by this name
     to...
     (create_breakpoint_sal): ...this.
     (create_breakpoints): Rename to...
     (create_breakpoints_sal): ...this.
     (set_breakpoint): Remove.
     * breakpoint.h: Adjust to above changes.
     * mi/mi-cmd-break.c (mi_cmd_break_insert): Simplify.

gdb/ChangeLog
gdb/breakpoint.c
gdb/breakpoint.h
gdb/mi/mi-cmd-break.c

index e77c2ba32ca1d22430ea43f21870d6e3e0004798..debc6e80ec7db4b38dac51eeb6e39f6f32144530 100644 (file)
@@ -1,3 +1,18 @@
+2010-03-16  Vladimir Prus  <vladimir@codesourcery.com>
+
+       Simplify MI breakpoint setting.
+
+       * breakpoint.c (break_command_really): Make nonstatic and
+       rename to...
+       (create_breakpoint): ...this. Rename prior function by this name
+       to...
+       (create_breakpoint_sal): ...this.
+       (create_breakpoints): Rename to...
+       (create_breakpoints_sal): ...this.
+       (set_breakpoint): Remove.
+       * breakpoint.h: Adjust to above changes.
+       * mi/mi-cmd-break.c (mi_cmd_break_insert): Simplify.
+
 2010-03-15 Stan Shebs  <stan@codesourcery.com>
 
        * ax-gdb.c: Include cp-support.h.
index 628f2f713271649c9791aa44a4685589065f3c97..1b4ab570250fb9af157383d459a1dc413cdd1b9e 100644 (file)
@@ -6461,12 +6461,12 @@ bp_loc_is_permanent (struct bp_location *loc)
    as condition expression.  */
 
 static void
-create_breakpoint (struct gdbarch *gdbarch,
-                  struct symtabs_and_lines sals, char *addr_string,
-                  char *cond_string,
-                  enum bptype type, enum bpdisp disposition,
-                  int thread, int task, int ignore_count, 
-                  struct breakpoint_ops *ops, int from_tty, int enabled)
+create_breakpoint_sal (struct gdbarch *gdbarch,
+                      struct symtabs_and_lines sals, char *addr_string,
+                      char *cond_string,
+                      enum bptype type, enum bpdisp disposition,
+                      int thread, int task, int ignore_count,
+                      struct breakpoint_ops *ops, int from_tty, int enabled)
 {
   struct breakpoint *b = NULL;
   int i;
@@ -6724,13 +6724,13 @@ expand_line_sal_maybe (struct symtab_and_line sal)
    COND and SALS arrays and each of those arrays contents. */
 
 static void
-create_breakpoints (struct gdbarch *gdbarch,
-                   struct symtabs_and_lines sals, char **addr_string,
-                   char *cond_string,
-                   enum bptype type, enum bpdisp disposition,
-                   int thread, int task, int ignore_count, 
-                   struct breakpoint_ops *ops, int from_tty,
-                   int enabled)
+create_breakpoints_sal (struct gdbarch *gdbarch,
+                       struct symtabs_and_lines sals, char **addr_string,
+                       char *cond_string,
+                       enum bptype type, enum bpdisp disposition,
+                       int thread, int task, int ignore_count,
+                       struct breakpoint_ops *ops, int from_tty,
+                       int enabled)
 {
   int i;
   for (i = 0; i < sals.nelts; ++i)
@@ -6738,9 +6738,9 @@ create_breakpoints (struct gdbarch *gdbarch,
       struct symtabs_and_lines expanded = 
        expand_line_sal_maybe (sals.sals[i]);
 
-      create_breakpoint (gdbarch, expanded, addr_string[i],
-                        cond_string, type, disposition,
-                        thread, task, ignore_count, ops, from_tty, enabled);
+      create_breakpoint_sal (gdbarch, expanded, addr_string[i],
+                            cond_string, type, disposition,
+                            thread, task, ignore_count, ops, from_tty, enabled);
     }
 }
 
@@ -6955,16 +6955,16 @@ find_condition_and_thread (char *tok, CORE_ADDR pc,
    COND_STRING and THREAD parameters.  Returns true if any breakpoint
    was created; false otherwise.  */
 
-static int
-break_command_really (struct gdbarch *gdbarch,
-                     char *arg, char *cond_string, int thread,
-                     int parse_condition_and_thread,
-                     int tempflag, int hardwareflag, int traceflag,
-                     int ignore_count,
-                     enum auto_boolean pending_break_support,
-                     struct breakpoint_ops *ops,
-                     int from_tty,
-                     int enabled)
+int
+create_breakpoint (struct gdbarch *gdbarch,
+                  char *arg, char *cond_string, int thread,
+                  int parse_condition_and_thread,
+                  int tempflag, int hardwareflag, int traceflag,
+                  int ignore_count,
+                  enum auto_boolean pending_break_support,
+                  struct breakpoint_ops *ops,
+                  int from_tty,
+                  int enabled)
 {
   struct gdb_exception e;
   struct symtabs_and_lines sals;
@@ -7103,9 +7103,10 @@ break_command_really (struct gdbarch *gdbarch,
                 make_cleanup (xfree, cond_string);
             }
         }
-      create_breakpoints (gdbarch, sals, addr_string, cond_string, type_wanted,
-                         tempflag ? disp_del : disp_donttouch,
-                         thread, task, ignore_count, ops, from_tty, enabled);
+      create_breakpoints_sal (gdbarch, sals, addr_string, cond_string,
+                             type_wanted, tempflag ? disp_del : disp_donttouch,
+                             thread, task, ignore_count, ops, from_tty,
+                             enabled);
     }
   else
     {
@@ -7163,34 +7164,18 @@ break_command_1 (char *arg, int flag, int from_tty)
   int hardwareflag = flag & BP_HARDWAREFLAG;
   int tempflag = flag & BP_TEMPFLAG;
 
-  break_command_really (get_current_arch (),
-                       arg,
-                       NULL, 0, 1 /* parse arg */,
-                       tempflag, hardwareflag, 0 /* traceflag */,
-                       0 /* Ignore count */,
-                       pending_break_support, 
-                       NULL /* breakpoint_ops */,
-                       from_tty,
-                       1 /* enabled */);
+  create_breakpoint (get_current_arch (),
+                    arg,
+                    NULL, 0, 1 /* parse arg */,
+                    tempflag, hardwareflag, 0 /* traceflag */,
+                    0 /* Ignore count */,
+                    pending_break_support,
+                    NULL /* breakpoint_ops */,
+                    from_tty,
+                    1 /* enabled */);
 }
 
 
-void
-set_breakpoint (struct gdbarch *gdbarch,
-               char *address, char *condition,
-               int hardwareflag, int tempflag,
-               int thread, int ignore_count,
-               int pending, int enabled)
-{
-  break_command_really (gdbarch,
-                       address, condition, thread,
-                       0 /* condition and thread are valid.  */,
-                       tempflag, hardwareflag, 0 /* traceflag */,
-                       ignore_count,
-                       pending 
-                       ? AUTO_BOOLEAN_TRUE : AUTO_BOOLEAN_FALSE,
-                       NULL, 0, enabled);
-}
 
 /* Adjust SAL to the first instruction past the function prologue.
    The end of the prologue is determined using the line table from
@@ -8054,14 +8039,14 @@ handle_gnu_v3_exceptions (int tempflag, char *cond_string,
   else
     trigger_func_name = "__cxa_throw";
 
-  break_command_really (get_current_arch (),
-                       trigger_func_name, cond_string, -1,
-                       0 /* condition and thread are valid.  */,
-                       tempflag, 0, 0,
-                       0,
-                       AUTO_BOOLEAN_TRUE /* pending */,
-                       &gnu_v3_exception_catchpoint_ops, from_tty,
-                       1 /* enabled */);
+  create_breakpoint (get_current_arch (),
+                    trigger_func_name, cond_string, -1,
+                    0 /* condition and thread are valid.  */,
+                    tempflag, 0, 0,
+                    0,
+                    AUTO_BOOLEAN_TRUE /* pending */,
+                    &gnu_v3_exception_catchpoint_ops, from_tty,
+                    1 /* enabled */);
 
   return 1;
 }
@@ -10026,32 +10011,32 @@ set_tracepoint_count (int num)
 void
 trace_command (char *arg, int from_tty)
 {
-  if (break_command_really (get_current_arch (),
-                           arg,
-                           NULL, 0, 1 /* parse arg */,
-                           0 /* tempflag */, 0 /* hardwareflag */,
-                           1 /* traceflag */,
-                           0 /* Ignore count */,
-                           pending_break_support,
-                           NULL,
-                           from_tty,
-                           1 /* enabled */))
+  if (create_breakpoint (get_current_arch (),
+                        arg,
+                        NULL, 0, 1 /* parse arg */,
+                        0 /* tempflag */, 0 /* hardwareflag */,
+                        1 /* traceflag */,
+                        0 /* Ignore count */,
+                        pending_break_support,
+                        NULL,
+                        from_tty,
+                        1 /* enabled */))
     set_tracepoint_count (breakpoint_count);
 }
 
 void
 ftrace_command (char *arg, int from_tty)
 {
-  if (break_command_really (get_current_arch (),
-                           arg,
-                           NULL, 0, 1 /* parse arg */,
-                           0 /* tempflag */, 1 /* hardwareflag */,
-                           1 /* traceflag */,
-                           0 /* Ignore count */,
-                           pending_break_support,
-                           NULL,
-                           from_tty,
-                           1 /* enabled */))
+  if (create_breakpoint (get_current_arch (),
+                        arg,
+                        NULL, 0, 1 /* parse arg */,
+                        0 /* tempflag */, 1 /* hardwareflag */,
+                        1 /* traceflag */,
+                        0 /* Ignore count */,
+                        pending_break_support,
+                        NULL,
+                        from_tty,
+                        1 /* enabled */))
     set_tracepoint_count (breakpoint_count);
 }
 
@@ -10070,17 +10055,17 @@ create_tracepoint_from_upload (struct uploaded_tp *utp)
   /* In the absence of a source location, fall back to raw address.  */
   sprintf (buf, "*%s", paddress (get_current_arch(), utp->addr));
 
-  if (!break_command_really (get_current_arch (),
-                            buf,
-                            NULL, 0, 1 /* parse arg */,
-                            0 /* tempflag */,
-                            (utp->type == bp_fast_tracepoint) /* hardwareflag */,
-                            1 /* traceflag */,
-                            0 /* Ignore count */,
-                            pending_break_support,
-                            NULL,
-                            0 /* from_tty */,
-                            utp->enabled /* enabled */))
+  if (!create_breakpoint (get_current_arch (),
+                         buf,
+                         NULL, 0, 1 /* parse arg */,
+                         0 /* tempflag */,
+                         (utp->type == bp_fast_tracepoint) /* hardwareflag */,
+                         1 /* traceflag */,
+                         0 /* Ignore count */,
+                         pending_break_support,
+                         NULL,
+                         0 /* from_tty */,
+                         utp->enabled /* enabled */))
     return NULL;
 
   set_tracepoint_count (breakpoint_count);
index 73e2223dcb99f9dc530bf03ddd4b48a70976b378..438cc6a3fb17676a03a7a18bd19f1e8f42b472e1 100644 (file)
@@ -792,12 +792,15 @@ extern void awatch_command_wrapper (char *, int);
 extern void rwatch_command_wrapper (char *, int);
 extern void tbreak_command (char *, int);
 
-extern void set_breakpoint (struct gdbarch *gdbarch,
-                           char *address, char *condition,
-                           int hardwareflag, int tempflag,
-                           int thread, int ignore_count,
-                           int pending,
-                           int enabled);
+extern int create_breakpoint (struct gdbarch *gdbarch, char *arg,
+                             char *cond_string, int thread,
+                             int parse_condition_and_thread,
+                             int tempflag, int hardwareflag, int traceflag,
+                             int ignore_count,
+                             enum auto_boolean pending_break_support,
+                             struct breakpoint_ops *ops,
+                             int from_tty,
+                             int enabled);
 
 extern void insert_breakpoints (void);
 
index 11644148c34d70fb524c8ec61c8a4a3500ee2b94..3ed652c769b4d0debec8013cd7ab7f3be21d5d08 100644 (file)
@@ -67,18 +67,20 @@ mi_cmd_break_insert (char *command, char **argv, int argc)
 {
   char *address = NULL;
   enum bp_type type = REG_BP;
+  int hardware = 0;
   int temp_p = 0;
   int thread = -1;
   int ignore_count = 0;
   char *condition = NULL;
   int pending = 0;
   int enabled = 1;
+  struct cleanup *back_to;
 
   struct gdb_exception e;
   struct gdb_events *old_hooks;
   enum opt
     {
-      HARDWARE_OPT, TEMP_OPT /*, REGEXP_OPT */ , CONDITION_OPT,
+      HARDWARE_OPT, TEMP_OPT, CONDITION_OPT,
       IGNORE_COUNT_OPT, THREAD_OPT, PENDING_OPT, DISABLE_OPT
     };
   static struct mi_opt opts[] =
@@ -108,13 +110,8 @@ mi_cmd_break_insert (char *command, char **argv, int argc)
          temp_p = 1;
          break;
        case HARDWARE_OPT:
-         type = HW_BP;
+         hardware = 1;
          break;
-#if 0
-       case REGEXP_OPT:
-         type = REGEXP_BP;
-         break;
-#endif
        case CONDITION_OPT:
          condition = optarg;
          break;
@@ -147,40 +144,16 @@ mi_cmd_break_insert (char *command, char **argv, int argc)
       mi_breakpoint_observers_installed = 1;
     }
 
+  back_to = make_cleanup_restore_integer (&mi_can_breakpoint_notify);
   mi_can_breakpoint_notify = 1;
-  /* Make sure we restore hooks even if exception is thrown.  */
-  TRY_CATCH (e, RETURN_MASK_ALL)
-    {
-      switch (type)
-       {
-       case REG_BP:
-         set_breakpoint (get_current_arch (), address, condition,
-                         0 /*hardwareflag */ , temp_p,
-                         thread, ignore_count,
-                         pending, enabled);
-         break;
-       case HW_BP:
-         set_breakpoint (get_current_arch (), address, condition,
-                         1 /*hardwareflag */ , temp_p,
-                         thread, ignore_count,
-                         pending, enabled);
-         break;
-#if 0
-       case REGEXP_BP:
-         if (temp_p)
-           error (_("mi_cmd_break_insert: Unsupported tempoary regexp breakpoint"));
-         else
-           rbreak_command_wrapper (address, FROM_TTY);
-         break;
-#endif
-       default:
-         internal_error (__FILE__, __LINE__,
-                         _("mi_cmd_break_insert: Bad switch."));
-       }
-    }
-  mi_can_breakpoint_notify = 0;
-  if (e.reason < 0)
-    throw_exception (e);
+  create_breakpoint (get_current_arch (), address, condition, thread,
+                    0 /* condition and thread are valid.  */,
+                    temp_p, hardware, 0 /* traceflag */,
+                    ignore_count,
+                    pending ? AUTO_BOOLEAN_TRUE : AUTO_BOOLEAN_FALSE,
+                    NULL, 0, enabled);
+  do_cleanups (back_to);
+
 }
 
 enum wp_type