Add new_inferior, inferior_deleted, and new_thread events
[deliverable/binutils-gdb.git] / gdb / breakpoint.c
index eeaf02716a2d2ca398d45eb685557fd701b49018..123420c6ae859057422c96ccae7736ac55aff0ac 100644 (file)
@@ -82,6 +82,7 @@
 #include <algorithm>
 #include "progspace-and-thread.h"
 #include "common/array-view.h"
+#include "common/gdb_optional.h"
 
 /* Enums for exception-handling support.  */
 enum exception_event_kind
@@ -551,8 +552,6 @@ gdb_evaluates_breakpoint_condition_p (void)
   return (mode == condition_evaluation_host);
 }
 
-void _initialize_breakpoint (void);
-
 /* Are we executing breakpoint commands?  */
 static int executing_breakpoint_commands;
 
@@ -3358,16 +3357,12 @@ create_internal_breakpoint (struct gdbarch *gdbarch,
                            CORE_ADDR address, enum bptype type,
                            const struct breakpoint_ops *ops)
 {
-  struct symtab_and_line sal;
-  struct breakpoint *b;
-
-  init_sal (&sal);             /* Initialize to zeroes.  */
-
+  symtab_and_line sal;
   sal.pc = address;
   sal.section = find_pc_overlay (sal.pc);
   sal.pspace = current_program_space;
 
-  b = set_raw_breakpoint (gdbarch, sal, type, ops);
+  breakpoint *b = set_raw_breakpoint (gdbarch, sal, type, ops);
   b->number = internal_breakpoint_number--;
   b->disposition = disp_donttouch;
 
@@ -8525,9 +8520,7 @@ init_catchpoint (struct breakpoint *b,
                 const char *cond_string,
                 const struct breakpoint_ops *ops)
 {
-  struct symtab_and_line sal;
-
-  init_sal (&sal);
+  symtab_and_line sal;
   sal.pspace = current_program_space;
 
   init_raw_breakpoint (b, gdbarch, sal, bp_catchpoint, ops);
@@ -9379,18 +9372,14 @@ parse_breakpoint_sals (const struct event_location *location,
             breakpoint address.  */
          if (last_displayed_sal_is_valid ())
            {
-             struct symtab_and_line sal;
-             CORE_ADDR pc;
-
-             init_sal (&sal);          /* Initialize to zeroes.  */
-
              /* Set sal's pspace, pc, symtab, and line to the values
                 corresponding to the last call to print_frame_info.
                 Be sure to reinitialize LINE with NOTCURRENT == 0
                 as the breakpoint line number is inappropriate otherwise.
                 find_pc_line would adjust PC, re-set it back.  */
-             get_last_displayed_sal (&sal);
-             pc = sal.pc;
+             symtab_and_line sal = get_last_displayed_sal ();
+             CORE_ADDR pc = sal.pc;
+
              sal = find_pc_line (pc, 0);
 
              /* "break" without arguments is equivalent to "break *PC"
@@ -9600,10 +9589,7 @@ decode_static_tracepoint_spec (const char **arg_p)
 
       marker = VEC_index (static_tracepoint_marker_p, markers, i);
 
-      symtab_and_line sal;
-      init_sal (&sal);
-
-      sal = find_pc_line (marker->address, 0);
+      symtab_and_line sal = find_pc_line (marker->address, 0);
       sal.pc = marker->address;
       sals.push_back (sal);
 
@@ -10551,7 +10537,6 @@ works_in_software_mode_watchpoint (const struct breakpoint *b)
 static enum print_stop_action
 print_it_watchpoint (bpstat bs)
 {
-  struct cleanup *old_chain;
   struct breakpoint *b;
   enum print_stop_action result;
   struct watchpoint *w;
@@ -10562,13 +10547,12 @@ print_it_watchpoint (bpstat bs)
   b = bs->breakpoint_at;
   w = (struct watchpoint *) b;
 
-  old_chain = make_cleanup (null_cleanup, NULL);
-
   annotate_watchpoint (b->number);
   maybe_print_thread_hit_breakpoint (uiout);
 
   string_file stb;
 
+  gdb::optional<ui_out_emit_tuple> tuple_emitter;
   switch (b->type)
     {
     case bp_watchpoint:
@@ -10577,7 +10561,7 @@ print_it_watchpoint (bpstat bs)
        uiout->field_string
          ("reason", async_reason_lookup (EXEC_ASYNC_WATCHPOINT_TRIGGER));
       mention (b);
-      make_cleanup_ui_out_tuple_begin_end (uiout, "value");
+      tuple_emitter.emplace (uiout, "value");
       uiout->text ("\nOld value = ");
       watchpoint_value_print (bs->old_val, &stb);
       uiout->field_stream ("old", stb);
@@ -10594,7 +10578,7 @@ print_it_watchpoint (bpstat bs)
        uiout->field_string
          ("reason", async_reason_lookup (EXEC_ASYNC_READ_WATCHPOINT_TRIGGER));
       mention (b);
-      make_cleanup_ui_out_tuple_begin_end (uiout, "value");
+      tuple_emitter.emplace (uiout, "value");
       uiout->text ("\nValue = ");
       watchpoint_value_print (w->val, &stb);
       uiout->field_stream ("value", stb);
@@ -10610,7 +10594,7 @@ print_it_watchpoint (bpstat bs)
              ("reason",
               async_reason_lookup (EXEC_ASYNC_ACCESS_WATCHPOINT_TRIGGER));
          mention (b);
-         make_cleanup_ui_out_tuple_begin_end (uiout, "value");
+         tuple_emitter.emplace (uiout, "value");
          uiout->text ("\nOld value = ");
          watchpoint_value_print (bs->old_val, &stb);
          uiout->field_stream ("old", stb);
@@ -10623,7 +10607,7 @@ print_it_watchpoint (bpstat bs)
            uiout->field_string
              ("reason",
               async_reason_lookup (EXEC_ASYNC_ACCESS_WATCHPOINT_TRIGGER));
-         make_cleanup_ui_out_tuple_begin_end (uiout, "value");
+         tuple_emitter.emplace (uiout, "value");
          uiout->text ("\nValue = ");
        }
       watchpoint_value_print (w->val, &stb);
@@ -10635,7 +10619,6 @@ print_it_watchpoint (bpstat bs)
       result = PRINT_UNKNOWN;
     }
 
-  do_cleanups (old_chain);
   return result;
 }
 
@@ -11799,12 +11782,10 @@ clear_command (char *arg, int from_tty)
     }
   else
     {
-      init_sal (&last_sal);            /* Initialize to zeroes.  */
-
       /* 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 (&last_sal);
+      last_sal = get_last_displayed_sal ();
       if (last_sal.symtab == 0)
        error (_("No source file specified."));
 
@@ -13883,7 +13864,6 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal)
 
       if (!VEC_empty(static_tracepoint_marker_p, markers))
        {
-         struct symtab_and_line sal2;
          struct symbol *sym;
          struct static_tracepoint_marker *tpmarker;
          struct ui_out *uiout = current_uiout;
@@ -13898,11 +13878,7 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal)
                     "found at previous line number"),
                   b->number, tp->static_trace_marker_id);
 
-         init_sal (&sal2);
-
-         sal2.pc = tpmarker->address;
-
-         sal2 = find_pc_line (tpmarker->address, 0);
+         symtab_and_line sal2 = find_pc_line (tpmarker->address, 0);
          sym = find_pc_sect_function (tpmarker->address, NULL);
          uiout->text ("Now in ");
          if (sym)
This page took 0.029233 seconds and 4 git commands to generate.