* breakpoint.c (mention), main.c (fputs_unfiltered): Add comments.
[deliverable/binutils-gdb.git] / gdb / breakpoint.c
index 7f9d0f21537efe64a244bb21d5124bc55e902127..9a1aba5b155abb98f0289eeeeab4a723eceb4568 100644 (file)
@@ -1083,8 +1083,6 @@ bpstat_alloc (b, cbs)
   return bs;
 }
 \f
-
-
 /* Possible return values for watchpoint_check (this can't be an enum
    because of check_errors).  */
 /* The watchpoint has been deleted.  */
@@ -1095,6 +1093,7 @@ bpstat_alloc (b, cbs)
 #define WP_VALUE_NOT_CHANGED 3
 
 /* Check watchpoint condition.  */
+
 static int
 watchpoint_check (p)
      char *p;
@@ -1109,11 +1108,13 @@ watchpoint_check (p)
   saved_frame = selected_frame;
   saved_level = selected_frame_level;
 
-  if (bs->breakpoint_at->exp_valid_block == NULL)
+  b = bs->breakpoint_at;
+
+  if (b->exp_valid_block == NULL)
     within_current_scope = 1;
   else
     {
-      fr = find_frame_addr_in_frame_chain (bs->breakpoint_at->watchpoint_frame);
+      fr = find_frame_addr_in_frame_chain (b->watchpoint_frame);
       within_current_scope = (fr != NULL);
       if (within_current_scope)
        /* If we end up stopping, the current frame will get selected
@@ -1131,12 +1132,12 @@ watchpoint_check (p)
 
       value_ptr mark = value_mark ();
       value_ptr new_val = evaluate_expression (bs->breakpoint_at->exp);
-      if (!value_equal (bs->breakpoint_at->val, new_val))
+      if (!value_equal (b->val, new_val))
        {
          release_value (new_val);
          value_free_to_mark (mark);
-         bs->old_val = bs->breakpoint_at->val;
-         bs->breakpoint_at->val = new_val;
+         bs->old_val = b->val;
+         b->val = new_val;
          /* We will stop here */
          select_frame (saved_frame, saved_level);
          return WP_VALUE_CHANGED;
@@ -1163,9 +1164,9 @@ watchpoint_check (p)
       printf_filtered ("\
 Watchpoint %d deleted because the program has left the block in\n\
 which its expression is valid.\n", bs->breakpoint_at->number);
-      if (bs->breakpoint_at->related_breakpoint)
-       delete_breakpoint (bs->breakpoint_at->related_breakpoint);
-      delete_breakpoint (bs->breakpoint_at);
+      if (b->related_breakpoint)
+       delete_breakpoint (b->related_breakpoint);
+      delete_breakpoint (b);
 
       select_frame (saved_frame, saved_level);
       return WP_DELETED;
@@ -2148,6 +2149,14 @@ mention (b)
 {
   int say_where = 0;
 
+  /* FIXME: This is misplaced; mention() is called by things (like hitting a
+     watchpoint) other than breakpoint creation.  It should be possible to
+     clean this up and at the same time replace the random calls to
+     breakpoint_changed with this hook, as has already been done for
+     delete_breakpoint_hook and so on.  */
+  if (create_breakpoint_hook)
+    create_breakpoint_hook (b);
+
   switch (b->type)
     {
     case bp_watchpoint:
@@ -2376,10 +2385,11 @@ break_command_1 (arg, flag, from_tty)
     }
   if (hardwareflag)
     {
-      int i, other_type_used, target_resources_ok;
-      i = hw_breakpoint_used_count();  
-      target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
-               bp_hardware_breakpoint, i+sals.nelts, 0);
+      int i, target_resources_ok;
+
+      i = hw_breakpoint_used_count ();  
+      target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT (
+               bp_hardware_breakpoint, i + sals.nelts, 0);
       if (target_resources_ok == 0)
        error ("No hardware breakpoint support in the target.");
       else if (target_resources_ok < 0)
@@ -3179,6 +3189,9 @@ delete_breakpoint (bpt)
   register struct breakpoint *b;
   register bpstat bs;
 
+  if (delete_breakpoint_hook)
+    delete_breakpoint_hook (bpt);
+
   if (bpt->inserted)
     remove_breakpoint (bpt);
       
@@ -3230,8 +3243,6 @@ delete_breakpoint (bpt)
   if (bpt->source_file != NULL)
     free (bpt->source_file);
 
-  breakpoints_changed ();
-
   /* Be sure no bpstat's are pointing at it after it's been freed.  */
   /* FIXME, how can we find all bpstat's?
      We just check stop_bpstat for now.  */
@@ -3537,6 +3548,9 @@ enable_breakpoint (bpt)
   int target_resources_ok, other_type_used;
   struct value *mark;
   
+  if (enable_breakpoint_hook)
+    enable_breakpoint_hook (bpt);
+
   if (bpt->type == bp_hardware_breakpoint)
     {
       int i;
@@ -3549,7 +3563,6 @@ enable_breakpoint (bpt)
         error ("Hardware breakpoints used exceeds limit.");
     }
   bpt->enable = enabled;
-  breakpoints_changed ();
   check_duplicates (bpt->address);
 
   if (bpt->type == bp_watchpoint || bpt->type == bp_hardware_watchpoint ||
@@ -3584,9 +3597,10 @@ is valid is not currently in scope.\n", bpt->number);
            bpt->type == bp_access_watchpoint)
       {
         int i = hw_watchpoint_used_count (bpt->type, &other_type_used);
-        int mem_cnt = can_use_hardware_watchpoint(bpt->val);
+        int mem_cnt = can_use_hardware_watchpoint (bpt->val);
+
         target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT(
-                bpt->type, i+mem_cnt, other_type_used);
+                bpt->type, i + mem_cnt, other_type_used);
         /* we can consider of type is bp_hardware_watchpoint, convert to 
           bp_watchpoint in the following condition */
         if (target_resources_ok < 0)
@@ -3641,9 +3655,10 @@ disable_breakpoint (bpt)
   if (bpt->type == bp_watchpoint_scope)
     return;
 
-  bpt->enable = disabled;
+  if (disable_breakpoint_hook)
+    disable_breakpoint_hook (bpt);
 
-  breakpoints_changed ();
+  bpt->enable = disabled;
 
   check_duplicates (bpt->address);
 }
@@ -3813,7 +3828,8 @@ _initialize_breakpoint ()
   breakpoint_count = 0;
 
   add_com ("ignore", class_breakpoint, ignore_command,
-          "Set ignore-count of breakpoint number N to COUNT.");
+          "Set ignore-count of breakpoint number N to COUNT.\n\
+Usage is `ignore N COUNT'.");
 
   add_com ("commands", class_breakpoint, commands_command,
           "Set commands to be executed when a breakpoint is hit.\n\
@@ -3826,8 +3842,8 @@ then no output is printed when it is hit, except what the commands print.");
 
   add_com ("condition", class_breakpoint, condition_command,
           "Specify breakpoint number N to break only if COND is true.\n\
-N is an integer; COND is an expression to be evaluated whenever\n\
-breakpoint N is reached.  ");
+Usage is `condition N COND', where N is an integer and COND is an\n\
+expression to be evaluated whenever breakpoint N is reached.  ");
 
   add_com ("tbreak", class_breakpoint, tbreak_command,
           "Set a temporary breakpoint.  Args like \"break\" command.\n\
This page took 0.025589 seconds and 4 git commands to generate.