*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / breakpoint.c
index 7418c414843ec48ab52de9fbcace1ecfafd20fc3..4544ed54a63e5c4c55fcd296e4e92551ce37d1c8 100644 (file)
@@ -1,7 +1,7 @@
 /* Everything about breakpoints, for GDB.
 
    Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
-   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software
+   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
    Foundation, Inc.
 
    This file is part of GDB.
@@ -73,7 +73,7 @@ static void map_breakpoint_numbers (char *, void (*)(struct breakpoint *));
 
 static void ignore_command (char *, int);
 
-static int breakpoint_re_set_one (PTR);
+static int breakpoint_re_set_one (void *);
 
 static void clear_command (char *, int);
 
@@ -108,9 +108,9 @@ static void breakpoint_1 (int, int);
 
 static bpstat bpstat_alloc (struct breakpoint *, bpstat);
 
-static int breakpoint_cond_eval (PTR);
+static int breakpoint_cond_eval (void *);
 
-static void cleanup_executing_breakpoints (PTR);
+static void cleanup_executing_breakpoints (void *);
 
 static void commands_command (char *, int);
 
@@ -140,9 +140,9 @@ typedef struct
   }
 args_for_catchpoint_enable;
 
-static int watchpoint_check (PTR);
+static int watchpoint_check (void *);
 
-static int cover_target_enable_exception_callback (PTR);
+static int cover_target_enable_exception_callback (void *);
 
 static void maintenance_info_breakpoints (char *, int);
 
@@ -735,9 +735,11 @@ insert_breakpoints (void)
 
   ALL_BREAKPOINTS_SAFE (b, temp)
   {
-    if (b->enable_state == bp_permanent)
-      /* Permanent breakpoints cannot be inserted or removed.  */
+    /* Permanent breakpoints cannot be inserted or removed.  Disabled
+       breakpoints should not be inserted.  */
+    if (b->enable_state != bp_enabled)
       continue;
+
     if ((b->type == bp_watchpoint
         || b->type == bp_hardware_watchpoint
         || b->type == bp_read_watchpoint
@@ -759,9 +761,6 @@ insert_breakpoints (void)
        && b->type != bp_catch_exec
        && b->type != bp_catch_throw
        && b->type != bp_catch_catch
-       && b->enable_state != bp_disabled
-       && b->enable_state != bp_shlib_disabled
-       && b->enable_state != bp_call_disabled
        && !b->inserted
        && !b->duplicate)
       {
@@ -880,9 +879,6 @@ insert_breakpoints (void)
          return_val = val;     /* remember failure */
       }
     else if (ep_is_exception_catchpoint (b)
-            && b->enable_state != bp_disabled
-            && b->enable_state != bp_shlib_disabled
-            && b->enable_state != bp_call_disabled
             && !b->inserted
             && !b->duplicate)
 
@@ -940,7 +936,6 @@ insert_breakpoints (void)
     else if ((b->type == bp_hardware_watchpoint ||
              b->type == bp_read_watchpoint ||
              b->type == bp_access_watchpoint)
-            && b->enable_state == bp_enabled
             && b->disposition != disp_del_at_next_stop
             && !b->inserted
             && !b->duplicate)
@@ -1059,7 +1054,6 @@ insert_breakpoints (void)
     else if ((b->type == bp_catch_fork
              || b->type == bp_catch_vfork
              || b->type == bp_catch_exec)
-            && b->enable_state == bp_enabled
             && !b->inserted
             && !b->duplicate)
       {
@@ -1704,13 +1698,13 @@ deprecated_frame_in_dummy (struct frame_info *frame)
   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;
@@ -1922,7 +1916,7 @@ bpstat_clear_actions (bpstat bs)
 /* Stub for cleaning up our state if we error-out of a breakpoint command */
 /* ARGSUSED */
 static void
-cleanup_executing_breakpoints (PTR ignore)
+cleanup_executing_breakpoints (void *ignore)
 {
   executing_breakpoint_commands = 0;
 }
@@ -2337,7 +2331,7 @@ bpstat_print (bpstat bs)
    make it pass through catch_errors.  */
 
 static int
-breakpoint_cond_eval (PTR exp)
+breakpoint_cond_eval (void *exp)
 {
   struct value *mark = value_mark ();
   int i = !value_true (evaluate_expression ((struct expression *) exp));
@@ -2377,7 +2371,7 @@ bpstat_alloc (struct breakpoint *b, bpstat cbs /* Current "bs" value */ )
 /* Check watchpoint condition.  */
 
 static int
-watchpoint_check (PTR p)
+watchpoint_check (void *p)
 {
   bpstat bs = (bpstat) p;
   struct breakpoint *b;
@@ -2727,8 +2721,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
       {
@@ -3417,11 +3411,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");
     }
   
@@ -3842,7 +3838,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;
@@ -4010,14 +4006,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;
 }
@@ -4310,7 +4304,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;
 
@@ -4319,10 +4313,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;
     }
@@ -4374,14 +4365,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 
@@ -4573,7 +4564,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;
@@ -4965,7 +4961,7 @@ break_at_finish_at_depth_command_1 (char *arg, int flag, int from_tty)
        {
          if (deprecated_selected_frame)
            {
-             selected_pc = deprecated_selected_frame->pc;
+             selected_pc = get_frame_pc (deprecated_selected_frame);
              if (arg)
                if_arg = 1;
            }
@@ -4994,7 +4990,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;
     }
@@ -5044,7 +5040,8 @@ break_at_finish_command_1 (char *arg, int flag, int from_tty)
          if (deprecated_selected_frame)
            {
              addr_string = (char *) xmalloc (15);
-             sprintf (addr_string, "*0x%s", paddr_nz (deprecated_selected_frame->pc));
+             sprintf (addr_string, "*0x%s",
+                      paddr_nz (get_frame_pc (deprecated_selected_frame)));
              if (arg)
                if_arg = 1;
            }
@@ -5424,7 +5421,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);
@@ -5579,7 +5576,7 @@ until_break_command_continuation (struct continuation_arg *arg)
 
 /* ARGSUSED */
 void
-until_break_command (char *arg, int from_tty)
+until_break_command (char *arg, int from_tty, int anywhere)
 {
   struct symtabs_and_lines sals;
   struct symtab_and_line sal;
@@ -5612,7 +5609,16 @@ until_break_command (char *arg, int from_tty)
 
   resolve_sal_pc (&sal);
 
-  breakpoint = set_momentary_breakpoint (sal, deprecated_selected_frame, bp_until);
+  if (anywhere)
+    /* If the user told us to continue until a specified location,
+       we don't specify a frame at which we need to stop.  */
+    breakpoint = set_momentary_breakpoint (sal, null_frame_id, bp_until);
+  else
+    /* Otherwise, specify the current frame, because we want to stop only
+       at the very same frame.  */
+    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);
@@ -5640,13 +5646,14 @@ until_break_command (char *arg, int from_tty)
       add_continuation (until_break_command_continuation, arg1);
     }
 
-  /* Keep within the current frame */
-
+  /* Keep within the current frame, or in frames called by the current
+     one.  */
   if (prev_frame)
     {
-      sal = find_pc_line (prev_frame->pc, 0);
-      sal.pc = prev_frame->pc;
-      breakpoint = set_momentary_breakpoint (sal, prev_frame, bp_until);
+      sal = find_pc_line (get_frame_pc (prev_frame), 0);
+      sal.pc = get_frame_pc (prev_frame);
+      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
@@ -5659,7 +5666,7 @@ until_break_command (char *arg, int from_tty)
   if (!event_loop_p || !target_can_async_p ())
     do_cleanups (old_chain);
 }
-\f
+
 #if 0
 /* These aren't used; I don't konw what they were for.  */
 /* Set a breakpoint at the catch clause for NAME.  */
@@ -5773,7 +5780,7 @@ get_catch_sals (int this_level_only)
   if (deprecated_selected_frame == NULL)
     error ("No selected frame.");
   block = get_frame_block (deprecated_selected_frame, 0);
-  pc = deprecated_selected_frame->pc;
+  pc = get_frame_pc (deprecated_selected_frame);
 
   sals.nelts = 0;
   sals.sals = NULL;
@@ -6225,7 +6232,7 @@ catch_exception_command_1 (enum exception_event_kind ex_event, char *arg,
    inside a catch_errors */
 
 static int
-cover_target_enable_exception_callback (PTR arg)
+cover_target_enable_exception_callback (void *arg)
 {
   args_for_catchpoint_enable *args = arg;
   struct symtab_and_line *sal;
@@ -6902,7 +6909,7 @@ delete_command (char *arg, int from_tty)
    Unused in this case.  */
 
 static int
-breakpoint_re_set_one (PTR bint)
+breakpoint_re_set_one (void *bint)
 {
   /* get past catch_errs */
   struct breakpoint *b = (struct breakpoint *) bint;
@@ -7043,7 +7050,7 @@ breakpoint_re_set_one (PTR bint)
        value_free (b->val);
       b->val = evaluate_expression (b->exp);
       release_value (b->val);
-      if (VALUE_LAZY (b->val))
+      if (VALUE_LAZY (b->val) && b->enable_state == bp_enabled)
        value_fetch_lazy (b->val);
 
       if (b->cond_string != NULL)
This page took 0.030833 seconds and 4 git commands to generate.