Revert debugging change
[deliverable/binutils-gdb.git] / gdb / breakpoint.c
index 2998671bbf197ecf69700c09672d9ca01fba83cd..d575b53ec64ffe013c47da5579bb365070b410d2 100644 (file)
 #include "annotate.h"
 #include "symfile.h"
 #include "objfiles.h"
+#include "source.h"
 #include "linespec.h"
 #include "completer.h"
 #include "gdb.h"
 #include "ui-out.h"
 #include "cli/cli-script.h"
+#include "gdb_assert.h"
 
 #include "gdb-events.h"
 
@@ -950,8 +952,8 @@ insert_breakpoints (void)
 
        /* Save the current frame and level so we can restore it after
           evaluating the watchpoint expression on its own frame.  */
-       saved_frame = selected_frame;
-       saved_level = frame_relative_level (selected_frame);
+       saved_frame = deprecated_selected_frame;
+       saved_level = frame_relative_level (deprecated_selected_frame);
 
        /* Determine if the watchpoint is within scope.  */
        if (b->exp_valid_block == NULL)
@@ -1047,8 +1049,8 @@ insert_breakpoints (void)
          }
 
        /* Restore the frame and level.  */
-       if ((saved_frame != selected_frame) ||
-           (saved_level != frame_relative_level (selected_frame)))
+       if ((saved_frame != deprecated_selected_frame) ||
+           (saved_level != frame_relative_level (deprecated_selected_frame)))
          select_frame (saved_frame);
 
        if (val)
@@ -1681,32 +1683,34 @@ breakpoint_inserted_here_p (CORE_ADDR pc)
 }
 
 /* Return nonzero if FRAME is a dummy frame.  We can't use
-   PC_IN_CALL_DUMMY because figuring out the saved SP would take too
-   much time, at least using get_saved_register on the 68k.  This
-   means that for this function to work right a port must use the
+   DEPRECATED_PC_IN_CALL_DUMMY because figuring out the saved SP would
+   take too much time, at least using get_saved_register on the 68k.
+   This means that for this function to work right a port must use the
    bp_call_dummy breakpoint.  */
 
 int
-frame_in_dummy (struct frame_info *frame)
+deprecated_frame_in_dummy (struct frame_info *frame)
 {
   struct breakpoint *b;
 
   if (!CALL_DUMMY_P)
     return 0;
 
-  if (USE_GENERIC_DUMMY_FRAMES)
-    return generic_pc_in_call_dummy (frame->pc, frame->frame, frame->frame);
+  /* This function is used by two files: get_frame_type(), after first
+     checking that !DEPRECATED_USE_GENERIC_DUMMY_FRAMES; and
+     sparc-tdep.c, which doesn't yet use generic dummy frames anyway.  */
+  gdb_assert (!DEPRECATED_USE_GENERIC_DUMMY_FRAMES);
 
   ALL_BREAKPOINTS (b)
   {
     if (b->type == bp_call_dummy
-       && b->frame == frame->frame
+       && frame_id_eq (b->frame_id, get_frame_id (frame))
     /* We need to check the PC as well as the frame on the sparc,
        for signals.exp in the testsuite.  */
-       && (frame->pc
+       && (get_frame_pc (frame)
            >= (b->address
-             - SIZEOF_CALL_DUMMY_WORDS / sizeof (LONGEST) * REGISTER_SIZE))
-       && frame->pc <= b->address)
+               - SIZEOF_CALL_DUMMY_WORDS / sizeof (LONGEST) * REGISTER_SIZE))
+       && get_frame_pc (frame) <= b->address)
       return 1;
   }
   return 0;
@@ -2569,17 +2573,17 @@ bpstat_stop_status (CORE_ADDR *pc, int not_a_sw_breakpoint)
       continue;
 
     if ((b->type == bp_catch_fork)
-       && !target_has_forked (PIDGET (inferior_ptid),
-                              &b->forked_inferior_pid))
+       && !inferior_has_forked (PIDGET (inferior_ptid),
+                                &b->forked_inferior_pid))
       continue;
 
     if ((b->type == bp_catch_vfork)
-       && !target_has_vforked (PIDGET (inferior_ptid),
-                               &b->forked_inferior_pid))
+       && !inferior_has_vforked (PIDGET (inferior_ptid),
+                                 &b->forked_inferior_pid))
       continue;
 
     if ((b->type == bp_catch_exec)
-       && !target_has_execd (PIDGET (inferior_ptid), &b->exec_pathname))
+       && !inferior_has_execd (PIDGET (inferior_ptid), &b->exec_pathname))
       continue;
 
     if (ep_is_exception_catchpoint (b) &&
@@ -2723,8 +2727,8 @@ bpstat_stop_status (CORE_ADDR *pc, int not_a_sw_breakpoint)
        real_breakpoint = 1;
       }
 
-    if (b->frame &&
-       b->frame != (get_current_frame ())->frame)
+    if (frame_id_p (b->frame_id)
+       && !frame_id_eq (b->frame_id, get_frame_id (get_current_frame ())))
       bs->stop = 0;
     else
       {
@@ -3413,11 +3417,13 @@ print_one_breakpoint (struct breakpoint *b,
   
   ui_out_text (uiout, "\n");
   
-  if (b->frame)
+  if (frame_id_p (b->frame_id))
     {
       annotate_field (6);
       ui_out_text (uiout, "\tstop only in stack frame at ");
-      ui_out_field_core_addr (uiout, "frame", b->frame);
+      /* FIXME: cagney/2002-12-01: Shouldn't be poeking around inside
+         the frame ID.  */
+      ui_out_field_core_addr (uiout, "frame", b->frame_id.base);
       ui_out_text (uiout, "\n");
     }
   
@@ -3838,7 +3844,7 @@ set_raw_breakpoint (struct symtab_and_line sal, enum bptype bptype)
   b->silent = 0;
   b->ignore_count = 0;
   b->commands = NULL;
-  b->frame = 0;
+  b->frame_id = null_frame_id;
   b->dll_pathname = NULL;
   b->triggered_dll_pathname = NULL;
   b->forked_inferior_pid = 0;
@@ -3883,7 +3889,7 @@ create_internal_breakpoint (CORE_ADDR address, enum bptype type)
   struct symtab_and_line sal;
   struct breakpoint *b;
 
-  INIT_SAL (&sal);             /* initialize to zeroes */
+  init_sal (&sal);             /* initialize to zeroes */
 
   sal.pc = address;
   sal.section = find_pc_overlay (sal.pc);
@@ -4006,14 +4012,12 @@ struct breakpoint *
 create_thread_event_breakpoint (CORE_ADDR address)
 {
   struct breakpoint *b;
-  char addr_string[80];                /* Surely an addr can't be longer than that. */
 
   b = create_internal_breakpoint (address, bp_thread_event);
   
   b->enable_state = bp_enabled;
   /* addr_string has to be used or breakpoint_re_set will delete me.  */
-  sprintf (addr_string, "*0x%s", paddr (b->address));
-  b->addr_string = xstrdup (addr_string);
+  xasprintf (&b->addr_string, "*0x%s", paddr (b->address));
 
   return b;
 }
@@ -4203,7 +4207,7 @@ create_fork_vfork_event_catchpoint (int tempflag, char *cond_string,
   struct breakpoint *b;
   int thread = -1;             /* All threads. */
 
-  INIT_SAL (&sal);
+  init_sal (&sal);
   sal.pc = 0;
   sal.symtab = NULL;
   sal.line = 0;
@@ -4242,7 +4246,7 @@ create_exec_event_catchpoint (int tempflag, char *cond_string)
   struct breakpoint *b;
   int thread = -1;             /* All threads. */
 
-  INIT_SAL (&sal);
+  init_sal (&sal);
   sal.pc = 0;
   sal.symtab = NULL;
   sal.line = 0;
@@ -4306,7 +4310,7 @@ hw_watchpoint_used_count (enum bptype type, int *other_type_used)
    that gets deleted automatically... */
 
 void
-set_longjmp_resume_breakpoint (CORE_ADDR pc, struct frame_info *frame)
+set_longjmp_resume_breakpoint (CORE_ADDR pc, struct frame_id frame_id)
 {
   register struct breakpoint *b;
 
@@ -4315,10 +4319,7 @@ set_longjmp_resume_breakpoint (CORE_ADDR pc, struct frame_info *frame)
     {
       b->address = pc;
       b->enable_state = bp_enabled;
-      if (frame != NULL)
-       b->frame = frame->frame;
-      else
-       b->frame = 0;
+      b->frame_id = frame_id;
       check_duplicates (b);
       return;
     }
@@ -4370,14 +4371,14 @@ enable_watchpoints_after_interactive_call_stop (void)
    Restrict it to frame FRAME if FRAME is nonzero.  */
 
 struct breakpoint *
-set_momentary_breakpoint (struct symtab_and_line sal, struct frame_info *frame,
+set_momentary_breakpoint (struct symtab_and_line sal, struct frame_id frame_id,
                          enum bptype type)
 {
   register struct breakpoint *b;
   b = set_raw_breakpoint (sal, type);
   b->enable_state = bp_enabled;
   b->disposition = disp_donttouch;
-  b->frame = (frame ? frame->frame : 0);
+  b->frame_id = frame_id;
 
   /* If we're debugging a multi-threaded program, then we
      want momentary breakpoints to be active in only a 
@@ -4569,7 +4570,12 @@ create_breakpoints (struct symtabs_and_lines sals, char **addr_string,
        b->number = breakpoint_count;
        b->cond = cond[i];
        b->thread = thread;
-       b->addr_string = addr_string[i];
+       if (addr_string[i])
+         b->addr_string = addr_string[i];
+       else
+         /* addr_string has to be used or breakpoint_re_set will delete
+            me.  */
+         xasprintf (&b->addr_string, "*0x%s", paddr (b->address));
        b->cond_string = cond_string[i];
        b->ignore_count = ignore_count;
        b->enable_state = bp_enabled;
@@ -4599,7 +4605,7 @@ parse_breakpoint_sals (char **address,
       if (default_breakpoint_valid)
        {
          struct symtab_and_line sal;
-         INIT_SAL (&sal);              /* initialize to zeroes */
+         init_sal (&sal);              /* initialize to zeroes */
          sals->sals = (struct symtab_and_line *)
            xmalloc (sizeof (struct symtab_and_line));
          sal.pc = default_breakpoint_address;
@@ -4617,10 +4623,16 @@ 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.  */
+         leaving default_breakpoint_* 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
-         && (!current_source_symtab
-             || (strchr ("+-", (*address)[0]) != NULL)))
+         && (!cursal.symtab
+             || ((strchr ("+-", (*address)[0]) != NULL)
+                 && ((*address)[1] != '['))))
        *sals = decode_line_1 (address, 1, default_breakpoint_symtab,
                               default_breakpoint_line, addr_string);
       else
@@ -4953,9 +4965,9 @@ break_at_finish_at_depth_command_1 (char *arg, int flag, int from_tty)
 
       if (default_breakpoint_valid)
        {
-         if (selected_frame)
+         if (deprecated_selected_frame)
            {
-             selected_pc = selected_frame->pc;
+             selected_pc = get_frame_pc (deprecated_selected_frame);
              if (arg)
                if_arg = 1;
            }
@@ -4984,7 +4996,7 @@ break_at_finish_at_depth_command_1 (char *arg, int flag, int from_tty)
 
       frame = parse_frame_specification (level_arg);
       if (frame)
-       selected_pc = frame->pc;
+       selected_pc = get_frame_pc (frame);
       else
        selected_pc = 0;
     }
@@ -5031,10 +5043,11 @@ break_at_finish_command_1 (char *arg, int flag, int from_tty)
     {
       if (default_breakpoint_valid)
        {
-         if (selected_frame)
+         if (deprecated_selected_frame)
            {
              addr_string = (char *) xmalloc (15);
-             sprintf (addr_string, "*0x%s", paddr_nz (selected_frame->pc));
+             sprintf (addr_string, "*0x%s",
+                      paddr_nz (get_frame_pc (deprecated_selected_frame)));
              if (arg)
                if_arg = 1;
            }
@@ -5289,7 +5302,7 @@ watch_command_1 (char *arg, int accessflag, int from_tty)
   enum bptype bp_type;
   int mem_cnt = 0;
 
-  INIT_SAL (&sal);             /* initialize to zeroes */
+  init_sal (&sal);             /* initialize to zeroes */
 
   /* Parse arguments.  */
   innermost_block = NULL;
@@ -5390,7 +5403,7 @@ watch_command_1 (char *arg, int accessflag, int from_tty)
   if (frame)
     {
       prev_frame = get_prev_frame (frame);
-      get_frame_id (frame, &b->watchpoint_frame);
+      b->watchpoint_frame = get_frame_id (frame);
     }
   else
     {
@@ -5414,7 +5427,7 @@ watch_command_1 (char *arg, int accessflag, int from_tty)
          scope_breakpoint->disposition = disp_del;
 
          /* Only break in the proper frame (help with recursion).  */
-         scope_breakpoint->frame = prev_frame->frame;
+         scope_breakpoint->frame_id = get_frame_id (prev_frame);
 
          /* Set the address at which we will stop.  */
          scope_breakpoint->address = get_frame_pc (prev_frame);
@@ -5573,7 +5586,7 @@ until_break_command (char *arg, int from_tty)
 {
   struct symtabs_and_lines sals;
   struct symtab_and_line sal;
-  struct frame_info *prev_frame = get_prev_frame (selected_frame);
+  struct frame_info *prev_frame = get_prev_frame (deprecated_selected_frame);
   struct breakpoint *breakpoint;
   struct cleanup *old_chain;
   struct continuation_arg *arg1;
@@ -5602,7 +5615,9 @@ until_break_command (char *arg, int from_tty)
 
   resolve_sal_pc (&sal);
 
-  breakpoint = set_momentary_breakpoint (sal, selected_frame, bp_until);
+  breakpoint = 
+    set_momentary_breakpoint (sal,get_frame_id (deprecated_selected_frame),
+                             bp_until);
 
   if (!event_loop_p || !target_can_async_p ())
     old_chain = make_cleanup_delete_breakpoint (breakpoint);
@@ -5636,7 +5651,8 @@ until_break_command (char *arg, int from_tty)
     {
       sal = find_pc_line (prev_frame->pc, 0);
       sal.pc = prev_frame->pc;
-      breakpoint = set_momentary_breakpoint (sal, prev_frame, bp_until);
+      breakpoint = set_momentary_breakpoint (sal, get_frame_id (prev_frame),
+                                            bp_until);
       if (!event_loop_p || !target_can_async_p ())
        make_cleanup_delete_breakpoint (breakpoint);
       else
@@ -5760,10 +5776,10 @@ get_catch_sals (int this_level_only)
 
   /* Not sure whether an error message is always the correct response,
      but it's better than a core dump.  */
-  if (selected_frame == NULL)
+  if (deprecated_selected_frame == NULL)
     error ("No selected frame.");
-  block = get_frame_block (selected_frame, 0);
-  pc = selected_frame->pc;
+  block = get_frame_block (deprecated_selected_frame, 0);
+  pc = get_frame_pc (deprecated_selected_frame);
 
   sals.nelts = 0;
   sals.sals = NULL;
@@ -6255,7 +6271,7 @@ handle_gnu_4_16_catch_command (char *arg, int tempflag, int from_tty)
   char *save_arg;
   int i;
 
-  INIT_SAL (&sal);             /* initialize to zeroes */
+  init_sal (&sal);             /* initialize to zeroes */
 
   /* If no arg given, or if first arg is 'if ', all active catch clauses
      are breakpointed. */
@@ -6526,7 +6542,7 @@ clear_command (char *arg, int from_tty)
       sals.sals = (struct symtab_and_line *)
        xmalloc (sizeof (struct symtab_and_line));
       make_cleanup (xfree, sals.sals);
-      INIT_SAL (&sal);         /* initialize to zeroes */
+      init_sal (&sal);         /* initialize to zeroes */
       sal.line = default_breakpoint_line;
       sal.symtab = default_breakpoint_symtab;
       sal.pc = default_breakpoint_address;
@@ -7358,8 +7374,8 @@ is valid is not currently in scope.\n", bpt->number);
              return;
            }
 
-         save_selected_frame = selected_frame;
-         save_selected_frame_level = frame_relative_level (selected_frame);
+         save_selected_frame = deprecated_selected_frame;
+         save_selected_frame_level = frame_relative_level (deprecated_selected_frame);
          select_frame (fr);
        }
 
This page took 0.038705 seconds and 4 git commands to generate.