2011-10-06 Justin Lebar <justin.lebar@gmail.com>
[deliverable/binutils-gdb.git] / gdb / breakpoint.c
index 00fe74823634fca3079c03bd9e5afdd1b08b955a..8c98bef3bc25c40d7885eb605d448852c2f2f29f 100644 (file)
@@ -65,6 +65,8 @@
 #include "parser-defs.h"
 #include "cli/cli-utils.h"
 #include "continuations.h"
+#include "stack.h"
+#include "skip.h"
 
 /* readline include files */
 #include "readline/readline.h"
@@ -176,7 +178,11 @@ static void maintenance_info_breakpoints (char *, int);
 
 static int hw_breakpoint_used_count (void);
 
-static int hw_watchpoint_used_count (enum bptype, int *);
+static int hw_watchpoint_use_count (struct breakpoint *);
+
+static int hw_watchpoint_used_count_others (struct breakpoint *except,
+                                           enum bptype type,
+                                           int *other_type_used);
 
 static void hbreak_command (char *, int);
 
@@ -568,19 +574,6 @@ make_cleanup_decref_counted_command_line (struct counted_command_line **cmdp)
   return make_cleanup (do_cleanup_counted_command_line, cmdp);
 }
 
-/* Default address, symtab and line to put a breakpoint at
-   for "break" command with no arg.
-   If default_breakpoint_valid is zero, the other three are
-   not valid, and "break" with no arg is an error.
-
-   This set by print_stack_frame, which calls set_default_breakpoint.  */
-
-int default_breakpoint_valid;
-CORE_ADDR default_breakpoint_address;
-struct symtab *default_breakpoint_symtab;
-int default_breakpoint_line;
-struct program_space *default_breakpoint_pspace;
-
 \f
 /* Return the breakpoint with the specified number, or NULL
    if the number does not refer to an existing breakpoint.  */
@@ -1458,6 +1451,7 @@ update_watchpoint (struct watchpoint *b, int reparse)
          if (reg_cnt)
            {
              int i, target_resources_ok, other_type_used;
+             enum bptype type;
 
              /* Use an exact watchpoint when there's only one memory region to be
                 watched, and only one debug register is needed to watch it.  */
@@ -1466,16 +1460,29 @@ update_watchpoint (struct watchpoint *b, int reparse)
              /* We need to determine how many resources are already
                 used for all other hardware watchpoints plus this one
                 to see if we still have enough resources to also fit
-                this watchpoint in as well.  To guarantee the
-                hw_watchpoint_used_count call below counts this
-                watchpoint, make sure that it is marked as a hardware
-                watchpoint.  */
-             if (b->base.type == bp_watchpoint)
-               b->base.type = bp_hardware_watchpoint;
-
-             i = hw_watchpoint_used_count (b->base.type, &other_type_used);
-             target_resources_ok = target_can_use_hardware_watchpoint
-                   (b->base.type, i, other_type_used);
+                this watchpoint in as well.  */
+
+             /* If this is a software watchpoint, we try to turn it
+                to a hardware one -- count resources as if B was of
+                hardware watchpoint type.  */
+             type = b->base.type;
+             if (type == bp_watchpoint)
+               type = bp_hardware_watchpoint;
+
+             /* This watchpoint may or may not have been placed on
+                the list yet at this point (it won't be in the list
+                if we're trying to create it for the first time,
+                through watch_command), so always account for it
+                manually.  */
+
+             /* Count resources used by all watchpoints except B.  */
+             i = hw_watchpoint_used_count_others (&b->base, type, &other_type_used);
+
+             /* Add in the resources needed for B.  */
+             i += hw_watchpoint_use_count (&b->base);
+
+             target_resources_ok
+               = target_can_use_hardware_watchpoint (type, i, other_type_used);
              if (target_resources_ok <= 0)
                {
                  int sw_mode = b->base.ops->works_in_software_mode (&b->base);
@@ -1486,8 +1493,17 @@ update_watchpoint (struct watchpoint *b, int reparse)
                  else if (target_resources_ok < 0 && !sw_mode)
                    error (_("There are not enough available hardware "
                             "resources for this watchpoint."));
-                 else
-                   b->base.type = bp_watchpoint;
+
+                 /* Downgrade to software watchpoint.  */
+                 b->base.type = bp_watchpoint;
+               }
+             else
+               {
+                 /* If this was a software watchpoint, we've just
+                    found we have enough resources to turn it to a
+                    hardware watchpoint.  Otherwise, this is a
+                    nop.  */
+                 b->base.type = type;
                }
            }
          else if (!b->base.ops->works_in_software_mode (&b->base))
@@ -1571,9 +1587,26 @@ should_be_inserted (struct bp_location *bl)
   return 1;
 }
 
+/* Same as should_be_inserted but does the check assuming
+   that the location is not duplicated.  */
+
+static int
+unduplicated_should_be_inserted (struct bp_location *bl)
+{
+  int result;
+  const int save_duplicate = bl->duplicate;
+
+  bl->duplicate = 0;
+  result = should_be_inserted (bl);
+  bl->duplicate = save_duplicate;
+  return result;
+}
+
 /* Insert a low-level "breakpoint" of some type.  BL is the breakpoint
    location.  Any error messages are printed to TMP_ERROR_STREAM; and
    DISABLED_BREAKS, and HW_BREAKPOINT_ERROR are used to report problems.
+   Returns 0 for success, 1 if the bp_location type is not supported or
+   -1 for failure.
 
    NOTE drow/2003-09-09: This routine could be broken down to an
    object-style method for each breakpoint or catchpoint type.  */
@@ -1902,10 +1935,7 @@ insert_breakpoints (void)
     insert_breakpoint_locations ();
 }
 
-/* insert_breakpoints is used when starting or continuing the program.
-   remove_breakpoints is used when the program stops.
-   Both return zero if successful,
-   or an `errno' value if could not write the inferior.  */
+/* Used when starting or continuing the program.  */
 
 static void
 insert_breakpoint_locations (void)
@@ -2007,6 +2037,10 @@ You may have requested too many hardware breakpoints/watchpoints.\n");
   do_cleanups (cleanups);
 }
 
+/* Used when the program stops.
+   Returns zero if successful, or non-zero if there was a problem
+   removing a breakpoint location.  */
+
 int
 remove_breakpoints (void)
 {
@@ -3168,15 +3202,25 @@ bpstat_num (bpstat *bsp, int *num)
   return 1;
 }
 
-/* Modify BS so that the actions will not be performed.  */
+/* See breakpoint.h.  */
 
 void
-bpstat_clear_actions (bpstat bs)
+bpstat_clear_actions (void)
 {
-  for (; bs != NULL; bs = bs->next)
+  struct thread_info *tp;
+  bpstat bs;
+
+  if (ptid_equal (inferior_ptid, null_ptid))
+    return;
+
+  tp = find_thread_ptid (inferior_ptid);
+  if (tp == NULL)
+    return;
+
+  for (bs = tp->control.stop_bpstat; bs != NULL; bs = bs->next)
     {
       decref_counted_command_line (&bs->commands);
-      bs->commands_left = NULL;
+
       if (bs->old_val != NULL)
        {
          value_free (bs->old_val);
@@ -3213,6 +3257,16 @@ cleanup_executing_breakpoints (void *ignore)
   executing_breakpoint_commands = 0;
 }
 
+/* Return non-zero iff CMD as the first line of a command sequence is `silent'
+   or its equivalent.  */
+
+static int
+command_line_is_silent (struct command_line *cmd)
+{
+  return cmd && (strcmp ("silent", cmd->line) == 0
+                || (xdb_commands && strcmp ("Q", cmd->line) == 0));
+}
+
 /* Execute all the commands associated with all the breakpoints at
    this location.  Any of these commands could cause the process to
    proceed beyond this point, etc.  We look out for such changes by
@@ -3261,10 +3315,13 @@ bpstat_do_actions_1 (bpstat *bsp)
          the tree when we're done.  */
       ccmd = bs->commands;
       bs->commands = NULL;
-      this_cmd_tree_chain
-       = make_cleanup_decref_counted_command_line (&ccmd);
-      cmd = bs->commands_left;
-      bs->commands_left = NULL;
+      this_cmd_tree_chain = make_cleanup_decref_counted_command_line (&ccmd);
+      cmd = ccmd ? ccmd->commands : NULL;
+      if (command_line_is_silent (cmd))
+       {
+         /* The action has been already done by bpstat_stop_status.  */
+         cmd = cmd->next;
+       }
 
       while (cmd != NULL)
        {
@@ -3311,6 +3368,8 @@ bpstat_do_actions_1 (bpstat *bsp)
 void
 bpstat_do_actions (void)
 {
+  struct cleanup *cleanup_if_error = make_bpstat_clear_actions_cleanup ();
+
   /* Do any commands attached to breakpoint we are stopped at.  */
   while (!ptid_equal (inferior_ptid, null_ptid)
         && target_has_execution
@@ -3322,6 +3381,8 @@ bpstat_do_actions (void)
        indicate the inferior was not resumed.  */
     if (!bpstat_do_actions_1 (&inferior_thread ()->control.stop_bpstat))
       break;
+
+  discard_cleanups (cleanup_if_error);
 }
 
 /* Print out the (old or new) value associated with a watchpoint.  */
@@ -3456,7 +3517,6 @@ bpstat_alloc (struct bp_location *bl, bpstat **bs_link_pointer)
   incref_bp_location (bl);
   /* If the condition is false, etc., don't do the commands.  */
   bs->commands = NULL;
-  bs->commands_left = NULL;
   bs->old_val = NULL;
   bs->print_it = print_it_normal;
   return bs;
@@ -3667,6 +3727,8 @@ watchpoint_check (void *p)
     }
   else
     {
+      struct ui_out *uiout = current_uiout;
+
       /* This seems like the only logical thing to do because
          if we temporarily ignored the watchpoint, then when
          we reenter the block in which it is valid it contains
@@ -4131,16 +4193,9 @@ bpstat_stop_status (struct address_space *aspace,
                bs->print = 0;
              bs->commands = b->commands;
              incref_counted_command_line (bs->commands);
-             bs->commands_left = bs->commands ? bs->commands->commands : NULL;
-             if (bs->commands_left
-                 && (strcmp ("silent", bs->commands_left->line) == 0
-                     || (xdb_commands
-                         && strcmp ("Q",
-                                    bs->commands_left->line) == 0)))
-               {
-                 bs->commands_left = bs->commands_left->next;
-                 bs->print = 0;
-               }
+             if (command_line_is_silent (bs->commands
+                                         ? bs->commands->commands : NULL))
+               bs->print = 0;
            }
 
          /* Print nothing for this entry if we don't stop or don't print.  */
@@ -4480,6 +4535,7 @@ static void
 print_breakpoint_location (struct breakpoint *b,
                           struct bp_location *loc)
 {
+  struct ui_out *uiout = current_uiout;
   struct cleanup *old_chain = save_current_program_space ();
 
   if (loc != NULL && loc->shlib_disabled)
@@ -4598,6 +4654,7 @@ print_one_breakpoint_location (struct breakpoint *b,
   struct command_line *l;
   static char bpenables[] = "nynny";
 
+  struct ui_out *uiout = current_uiout;
   int header_of_multiple = 0;
   int part_of_multiple = (loc != NULL);
   struct value_print_options opts;
@@ -4888,6 +4945,7 @@ print_one_breakpoint (struct breakpoint *b,
                      int allflag)
 {
   struct cleanup *bkpt_chain;
+  struct ui_out *uiout = current_uiout;
 
   bkpt_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "bkpt");
 
@@ -5013,6 +5071,7 @@ breakpoint_1 (char *args, int allflag,
   struct value_print_options opts;
   int print_address_bits = 0;
   int print_type_col_width = 14;
+  struct ui_out *uiout = current_uiout;
 
   get_user_print_options (&opts);
 
@@ -5159,6 +5218,8 @@ breakpoint_1 (char *args, int allflag,
 static void
 default_collect_info (void)
 {
+  struct ui_out *uiout = current_uiout;
+
   /* If it has no value (which is frequently the case), say nothing; a
      message like "No default-collect." gets in user's face when it's
      not wanted.  */
@@ -5184,6 +5245,7 @@ static void
 watchpoints_info (char *args, int from_tty)
 {
   int num_printed = breakpoint_1 (args, 0, is_watchpoint);
+  struct ui_out *uiout = current_uiout;
 
   if (num_printed == 0)
     {
@@ -5219,7 +5281,7 @@ breakpoint_has_pc (struct breakpoint *b,
   return 0;
 }
 
-/* Print a message describing any breakpoints set at PC.  This
+/* Print a message describing any user-breakpoints set at PC.  This
    concerns with logical breakpoints, so we match program spaces, not
    address spaces.  */
 
@@ -5232,7 +5294,8 @@ describe_other_breakpoints (struct gdbarch *gdbarch,
   struct breakpoint *b;
 
   ALL_BREAKPOINTS (b)
-    others += breakpoint_has_pc (b, pspace, pc, section);
+    others += (user_breakpoint_p (b)
+               && breakpoint_has_pc (b, pspace, pc, section));
   if (others > 0)
     {
       if (others == 1)
@@ -5240,7 +5303,7 @@ describe_other_breakpoints (struct gdbarch *gdbarch,
       else /* if (others == ???) */
        printf_filtered (_("Note: breakpoints "));
       ALL_BREAKPOINTS (b)
-       if (breakpoint_has_pc (b, pspace, pc, section))
+       if (user_breakpoint_p (b) && breakpoint_has_pc (b, pspace, pc, section))
          {
            others--;
            printf_filtered ("%d", b->number);
@@ -5265,20 +5328,6 @@ describe_other_breakpoints (struct gdbarch *gdbarch,
     }
 }
 \f
-/* Set the default place to put a breakpoint
-   for the `break' command with no arguments.  */
-
-void
-set_default_breakpoint (int valid, struct program_space *pspace,
-                       CORE_ADDR addr, struct symtab *symtab,
-                       int line)
-{
-  default_breakpoint_valid = valid;
-  default_breakpoint_pspace = pspace;
-  default_breakpoint_address = addr;
-  default_breakpoint_symtab = symtab;
-  default_breakpoint_line = line;
-}
 
 /* Return true iff it is meaningful to use the address member of
    BPT.  For some breakpoint types, the address member is irrelevant
@@ -5690,7 +5739,7 @@ set_breakpoint_location_function (struct bp_location *loc, int explicit_loc)
 }
 
 /* Attempt to determine architecture of location identified by SAL.  */
-static struct gdbarch *
+struct gdbarch *
 get_sal_arch (struct symtab_and_line sal)
 {
   if (sal.section)
@@ -6147,6 +6196,7 @@ print_one_catch_fork (struct breakpoint *b, struct bp_location **last_loc)
 {
   struct fork_catchpoint *c = (struct fork_catchpoint *) b;
   struct value_print_options opts;
+  struct ui_out *uiout = current_uiout;
 
   get_user_print_options (&opts);
 
@@ -6242,6 +6292,7 @@ print_one_catch_vfork (struct breakpoint *b, struct bp_location **last_loc)
 {
   struct fork_catchpoint *c = (struct fork_catchpoint *) b;
   struct value_print_options opts;
+  struct ui_out *uiout = current_uiout;
 
   get_user_print_options (&opts);
   /* Field 4, the address, is omitted (which makes the columns not
@@ -6483,6 +6534,7 @@ print_one_catch_syscall (struct breakpoint *b,
 {
   struct syscall_catchpoint *c = (struct syscall_catchpoint *) b;
   struct value_print_options opts;
+  struct ui_out *uiout = current_uiout;
 
   get_user_print_options (&opts);
   /* Field 4, the address, is omitted (which makes the columns not
@@ -6725,6 +6777,7 @@ print_one_catch_exec (struct breakpoint *b, struct bp_location **last_loc)
 {
   struct exec_catchpoint *c = (struct exec_catchpoint *) b;
   struct value_print_options opts;
+  struct ui_out *uiout = current_uiout;
 
   get_user_print_options (&opts);
 
@@ -6796,28 +6849,52 @@ hw_breakpoint_used_count (void)
   return i;
 }
 
+/* Returns the resources B would use if it were a hardware
+   watchpoint.  */
+
 static int
-hw_watchpoint_used_count (enum bptype type, int *other_type_used)
+hw_watchpoint_use_count (struct breakpoint *b)
 {
   int i = 0;
-  struct breakpoint *b;
   struct bp_location *bl;
 
+  if (!breakpoint_enabled (b))
+    return 0;
+
+  for (bl = b->loc; bl; bl = bl->next)
+    {
+      /* Special types of hardware watchpoints may use more than
+        one register.  */
+      i += b->ops->resources_needed (bl);
+    }
+
+  return i;
+}
+
+/* Returns the sum the used resources of all hardware watchpoints of
+   type TYPE in the breakpoints list.  Also returns in OTHER_TYPE_USED
+   the sum of the used resources of all hardware watchpoints of other
+   types _not_ TYPE.  */
+
+static int
+hw_watchpoint_used_count_others (struct breakpoint *except,
+                                enum bptype type, int *other_type_used)
+{
+  int i = 0;
+  struct breakpoint *b;
+
   *other_type_used = 0;
   ALL_BREAKPOINTS (b)
     {
+      if (b == except)
+       continue;
       if (!breakpoint_enabled (b))
        continue;
 
-       if (b->type == type)
-         for (bl = b->loc; bl; bl = bl->next)
-           {
-             /* Special types of hardware watchpoints may use more than
-                one register.  */
-             i += b->ops->resources_needed (bl);
-           }
-       else if (is_hardware_watchpoint (b))
-         *other_type_used = 1;
+      if (b->type == type)
+       i += hw_watchpoint_use_count (b);
+      else if (is_hardware_watchpoint (b))
+       *other_type_used = 1;
     }
 
   return i;
@@ -7009,7 +7086,7 @@ static void
 mention (struct breakpoint *b)
 {
   b->ops->print_mention (b);
-  if (ui_out_is_mi_like_p (uiout))
+  if (ui_out_is_mi_like_p (current_uiout))
     return;
   printf_filtered ("\n");
 }
@@ -7441,24 +7518,26 @@ parse_breakpoint_sals (char **address,
   if ((*address) == NULL
       || (strncmp ((*address), "if", 2) == 0 && isspace ((*address)[2])))
     {
-      if (default_breakpoint_valid)
+      /* The last displayed codepoint, if it's valid, is our default breakpoint
+         address.  */
+      if (last_displayed_sal_is_valid ())
        {
          struct symtab_and_line sal;
 
          init_sal (&sal);              /* Initialize to zeroes.  */
          sals->sals = (struct symtab_and_line *)
            xmalloc (sizeof (struct symtab_and_line));
-         sal.pc = default_breakpoint_address;
-         sal.line = default_breakpoint_line;
-         sal.symtab = default_breakpoint_symtab;
-         sal.pspace = default_breakpoint_pspace;
-         sal.section = find_pc_overlay (sal.pc);
+
+         /* Set sal's pspace, pc, symtab, and line to the values
+            corresponding to the last call to print_frame_info.  */
+         get_last_displayed_sal (&sal);
+          sal.section = find_pc_overlay (sal.pc);
 
          /* "break" without arguments is equivalent to "break *PC"
-            where PC is the default_breakpoint_address.  So make sure
-            to set sal.explicit_pc to prevent GDB from trying to
-            expand the list of sals to include all other instances
-            with the same symtab and line.  */
+            where PC is the last displayed codepoint's address.  So
+            make sure to set sal.explicit_pc to prevent GDB from
+            trying to expand the list of sals to include all other
+            instances with the same symtab and line.  */
          sal.explicit_pc = 1;
 
          sals->sals[0] = sal;
@@ -7472,19 +7551,22 @@ parse_breakpoint_sals (char **address,
       /* Force almost all breakpoints to be in terms of the
          current_source_symtab (which is decode_line_1's default).
          This should produce the results we want almost all of the
-         time while leaving default_breakpoint_* alone.
+        time while leaving the last displayed codepoint pointers
+        alone.
 
          ObjC: However, don't match an Objective-C method name which
          may have a '+' or '-' succeeded by a '[' */
         
       struct symtab_and_line cursal = get_current_source_symtab_and_line ();
                        
-      if (default_breakpoint_valid
+      if (last_displayed_sal_is_valid ()
          && (!cursal.symtab
              || ((strchr ("+-", (*address)[0]) != NULL)
                  && ((*address)[1] != '['))))
-       *sals = decode_line_1 (address, 1, default_breakpoint_symtab,
-                              default_breakpoint_line, canonical);
+       *sals = decode_line_1 (address, 1,
+                              get_last_displayed_symtab (),
+                              get_last_displayed_line (),
+                              canonical);
       else
        *sals = decode_line_1 (address, 1, (struct symtab *) NULL, 0,
                               canonical);
@@ -8142,6 +8224,7 @@ print_it_ranged_breakpoint (bpstat bs)
 {
   struct breakpoint *b = bs->breakpoint_at;
   struct bp_location *bl = b->loc;
+  struct ui_out *uiout = current_uiout;
 
   gdb_assert (b->type == bp_hardware_breakpoint);
 
@@ -8174,6 +8257,7 @@ print_one_ranged_breakpoint (struct breakpoint *b,
 {
   struct bp_location *bl = b->loc;
   struct value_print_options opts;
+  struct ui_out *uiout = current_uiout;
 
   /* Ranged breakpoints have only one location.  */
   gdb_assert (bl && bl->next == NULL);
@@ -8223,6 +8307,7 @@ static void
 print_mention_ranged_breakpoint (struct breakpoint *b)
 {
   struct bp_location *bl = b->loc;
+  struct ui_out *uiout = current_uiout;
 
   gdb_assert (bl);
   gdb_assert (b->type == bp_hardware_breakpoint);
@@ -8650,6 +8735,7 @@ print_it_watchpoint (bpstat bs)
   struct ui_stream *stb;
   enum print_stop_action result;
   struct watchpoint *w;
+  struct ui_out *uiout = current_uiout;
 
   gdb_assert (bs->bp_location_at != NULL);
 
@@ -8742,6 +8828,7 @@ print_mention_watchpoint (struct breakpoint *b)
 {
   struct cleanup *ui_out_chain;
   struct watchpoint *w = (struct watchpoint *) b;
+  struct ui_out *uiout = current_uiout;
 
   switch (b->type)
     {
@@ -8856,6 +8943,7 @@ static enum print_stop_action
 print_it_masked_watchpoint (bpstat bs)
 {
   struct breakpoint *b = bs->breakpoint_at;
+  struct ui_out *uiout = current_uiout;
 
   /* Masked watchpoints have only one location.  */
   gdb_assert (b->loc && b->loc->next == NULL);
@@ -8922,6 +9010,7 @@ static void
 print_mention_masked_watchpoint (struct breakpoint *b)
 {
   struct watchpoint *w = (struct watchpoint *) b;
+  struct ui_out *uiout = current_uiout;
   struct cleanup *ui_out_chain;
 
   switch (b->type)
@@ -9502,9 +9591,11 @@ until_break_command (char *arg, int from_tty, int anywhere)
   /* Set a breakpoint where the user wants it and at return from
      this function.  */
 
-  if (default_breakpoint_valid)
-    sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
-                         default_breakpoint_line, NULL);
+  if (last_displayed_sal_is_valid ())
+    sals = decode_line_1 (&arg, 1,
+                         get_last_displayed_symtab (),
+                         get_last_displayed_line (),
+                         NULL);
   else
     sals = decode_line_1 (&arg, 1, (struct symtab *) NULL, 0, NULL);
 
@@ -9702,6 +9793,7 @@ catch_exec_command_1 (char *arg, int from_tty,
 static enum print_stop_action
 print_it_exception_catchpoint (bpstat bs)
 {
+  struct ui_out *uiout = current_uiout;
   struct breakpoint *b = bs->breakpoint_at;
   int bp_temp, bp_throw;
 
@@ -9736,6 +9828,7 @@ print_one_exception_catchpoint (struct breakpoint *b,
                                struct bp_location **last_loc)
 {
   struct value_print_options opts;
+  struct ui_out *uiout = current_uiout;
 
   get_user_print_options (&opts);
   if (opts.addressprint)
@@ -9759,6 +9852,7 @@ print_one_exception_catchpoint (struct breakpoint *b,
 static void
 print_mention_exception_catchpoint (struct breakpoint *b)
 {
+  struct ui_out *uiout = current_uiout;
   int bp_temp;
   int bp_throw;
 
@@ -9896,21 +9990,13 @@ init_ada_exception_breakpoint (struct breakpoint *b,
   b->language = language_ada;
 }
 
-/* Cleanup function for a syscall filter list.  */
-static void
-clean_up_filters (void *arg)
-{
-  VEC(int) *iter = *(VEC(int) **) arg;
-  VEC_free (int, iter);
-}
-
 /* Splits the argument using space as delimiter.  Returns an xmalloc'd
    filter list, or NULL if no filtering is required.  */
 static VEC(int) *
 catch_syscall_split_args (char *arg)
 {
   VEC(int) *result = NULL;
-  struct cleanup *cleanup = make_cleanup (clean_up_filters, &result);
+  struct cleanup *cleanup = make_cleanup (VEC_cleanup (int), &result);
 
   while (*arg != '\0')
     {
@@ -10031,10 +10117,11 @@ clear_command (char *arg, int from_tty)
        xmalloc (sizeof (struct symtab_and_line));
       make_cleanup (xfree, sals.sals);
       init_sal (&sal);         /* Initialize to zeroes.  */
-      sal.line = default_breakpoint_line;
-      sal.symtab = default_breakpoint_symtab;
-      sal.pc = default_breakpoint_address;
-      sal.pspace = default_breakpoint_pspace;
+
+      /* Set sal's line, symtab, pc, and pspace to the values
+        corresponding to the last call to print_frame_info.  If the
+        codepoint is not valid, this will set all the fields to 0.  */
+      get_last_displayed_sal (&sal);
       if (sal.symtab == 0)
        error (_("No source file specified."));
 
@@ -10238,6 +10325,23 @@ bp_location_target_extensions_update (void)
     }
 }
 
+/* Swap the insertion/duplication state between two locations.  */
+
+static void
+swap_insertion (struct bp_location *left, struct bp_location *right)
+{
+  const int left_inserted = left->inserted;
+  const int left_duplicate = left->duplicate;
+  const struct bp_target_info left_target_info = left->target_info;
+
+  left->inserted = right->inserted;
+  left->duplicate = right->duplicate;
+  left->target_info = right->target_info;
+  right->inserted = left_inserted;
+  right->duplicate = left_duplicate;
+  right->target_info = left_target_info;
+}
+
 /* If SHOULD_INSERT is false, do not insert any breakpoint locations
    into the inferior, only remove already-inserted locations that no
    longer should be inserted.  Functions that delete a breakpoint or
@@ -10374,11 +10478,6 @@ update_global_location_list (int should_insert)
 
                      if (breakpoint_locations_match (loc2, old_loc))
                        {
-                         /* For the sake of should_be_inserted.
-                            Duplicates check below will fix up this
-                            later.  */
-                         loc2->duplicate = 0;
-
                          /* Read watchpoint locations are switched to
                             access watchpoints, if the former are not
                             supported, but the latter are.  */
@@ -10388,10 +10487,13 @@ update_global_location_list (int should_insert)
                              loc2->watchpoint_type = old_loc->watchpoint_type;
                            }
 
-                         if (loc2 != old_loc && should_be_inserted (loc2))
+                         /* loc2 is a duplicated location. We need to check
+                            if it should be inserted in case it will be
+                            unduplicated.  */
+                         if (loc2 != old_loc
+                             && unduplicated_should_be_inserted (loc2))
                            {
-                             loc2->inserted = 1;
-                             loc2->target_info = old_loc->target_info;
+                             swap_insertion (old_loc, loc2);
                              keep_in_target = 1;
                              break;
                            }
@@ -10538,6 +10640,12 @@ update_global_location_list (int should_insert)
          continue;
        }
 
+
+      /* This and the above ensure the invariant that the first location
+        is not duplicated, and is the inserted one.
+        All following are marked as duplicated, and are not inserted.  */
+      if (loc->inserted)
+       swap_insertion (loc, *loc_first_p);
       loc->duplicate = 1;
 
       if ((*loc_first_p)->owner->enable_state == bp_permanent && loc->inserted
@@ -10611,6 +10719,7 @@ bpstat_remove_breakpoint_callback (struct thread_info *th, void *data)
 static void
 say_where (struct breakpoint *b)
 {
+  struct ui_out *uiout = current_uiout;
   struct value_print_options opts;
 
   get_user_print_options (&opts);
@@ -10849,6 +10958,7 @@ bkpt_print_it (bpstat bs)
   struct breakpoint *b;
   const struct bp_location *bl;
   int bp_temp;
+  struct ui_out *uiout = current_uiout;
 
   gdb_assert (bs->bp_location_at != NULL);
 
@@ -10880,7 +10990,7 @@ bkpt_print_it (bpstat bs)
 static void
 bkpt_print_mention (struct breakpoint *b)
 {
-  if (ui_out_is_mi_like_p (uiout))
+  if (ui_out_is_mi_like_p (current_uiout))
     return;
 
   switch (b->type)
@@ -10920,6 +11030,7 @@ bkpt_print_recreate (struct breakpoint *tp, struct ui_file *fp)
                    _("unhandled breakpoint type %d"), (int) tp->type);
 
   fprintf_unfiltered (fp, " %s", tp->addr_string);
+  print_recreate_thread (tp, fp);
 }
 
 /* Virtual table for internal breakpoints.  */
@@ -11030,6 +11141,8 @@ momentary_bkpt_check_status (bpstat bs)
 static enum print_stop_action
 momentary_bkpt_print_it (bpstat bs)
 {
+  struct ui_out *uiout = current_uiout;
+
   if (ui_out_is_mi_like_p (uiout))
     {
       struct breakpoint *b = bs->breakpoint_at;
@@ -11095,7 +11208,7 @@ tracepoint_print_one_detail (const struct breakpoint *self,
 static void
 tracepoint_print_mention (struct breakpoint *b)
 {
-  if (ui_out_is_mi_like_p (uiout))
+  if (ui_out_is_mi_like_p (current_uiout))
     return;
 
   switch (b->type)
@@ -11461,6 +11574,7 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal)
          struct symtab_and_line sal;
          struct symbol *sym;
          struct static_tracepoint_marker *marker;
+         struct ui_out *uiout = current_uiout;
 
          marker = VEC_index (static_tracepoint_marker_p, markers, 0);
 
@@ -11855,6 +11969,9 @@ breakpoint_re_set (void)
   create_longjmp_master_breakpoint ();
   create_std_terminate_master_breakpoint ();
   create_exception_master_breakpoint ();
+
+  /* While we're at it, reset the skip list too.  */
+  skip_re_set ();
 }
 \f
 /* Reset the thread number of this breakpoint:
@@ -12304,7 +12421,8 @@ invalidate_bp_value_on_memory_change (CORE_ADDR addr, int len,
       }
 }
 
-/* Use default_breakpoint_'s, or nothing if they aren't valid.  */
+/* Use the last displayed codepoint's values, or nothing
+   if they aren't valid.  */
 
 struct symtabs_and_lines
 decode_line_spec_1 (char *string, int funfirstline)
@@ -12313,10 +12431,10 @@ decode_line_spec_1 (char *string, int funfirstline)
 
   if (string == 0)
     error (_("Empty line specification."));
-  if (default_breakpoint_valid)
+  if (last_displayed_sal_is_valid ())
     sals = decode_line_1 (&string, funfirstline,
-                         default_breakpoint_symtab,
-                         default_breakpoint_line,
+                         get_last_displayed_symtab (),
+                         get_last_displayed_line (),
                          NULL);
   else
     sals = decode_line_1 (&string, funfirstline,
@@ -12726,6 +12844,7 @@ create_tracepoint_from_upload (struct uploaded_tp *utp)
 static void
 tracepoints_info (char *args, int from_tty)
 {
+  struct ui_out *uiout = current_uiout;
   int num_printed;
 
   num_printed = breakpoint_1 (args, 0, is_tracepoint);
@@ -13040,12 +13159,12 @@ save_breakpoints (char *filename, int from_tty,
 
        fprintf_unfiltered (fp, "  commands\n");
        
-       ui_out_redirect (uiout, fp);
+       ui_out_redirect (current_uiout, fp);
        TRY_CATCH (ex, RETURN_MASK_ALL)
          {
-           print_command_lines (uiout, tp->commands->commands, 2);
+           print_command_lines (current_uiout, tp->commands->commands, 2);
          }
-       ui_out_redirect (uiout, NULL);
+       ui_out_redirect (current_uiout, NULL);
 
        if (ex.reason < 0)
          throw_exception (ex);
@@ -13193,6 +13312,45 @@ iterate_over_breakpoints (int (*callback) (struct breakpoint *, void *),
   return NULL;
 }
 
+/* Zero if any of the breakpoint's locations could be a location where
+   functions have been inlined, nonzero otherwise.  */
+
+static int
+is_non_inline_function (struct breakpoint *b)
+{
+  /* The shared library event breakpoint is set on the address of a
+     non-inline function.  */
+  if (b->type == bp_shlib_event)
+    return 1;
+
+  return 0;
+}
+
+/* Nonzero if the specified PC cannot be a location where functions
+   have been inlined.  */
+
+int
+pc_at_non_inline_function (struct address_space *aspace, CORE_ADDR pc)
+{
+  struct breakpoint *b;
+  struct bp_location *bl;
+
+  ALL_BREAKPOINTS (b)
+    {
+      if (!is_non_inline_function (b))
+       continue;
+
+      for (bl = b->loc; bl != NULL; bl = bl->next)
+       {
+         if (!bl->shlib_disabled
+             && bpstat_check_location (bl, aspace, pc))
+           return 1;
+       }
+    }
+
+  return 0;
+}
+
 void
 initialize_breakpoint_ops (void)
 {
This page took 0.050623 seconds and 4 git commands to generate.