import gdb-1999-12-21 snapshot
[deliverable/binutils-gdb.git] / gdb / breakpoint.c
index b9fdcb0a076253a754ce44346c5e0c85e72208aa..e1f97c7309bb9cd14431dfc39e84581be72ce14f 100644 (file)
@@ -137,7 +137,7 @@ static void
 condition_command PARAMS ((char *, int));
 
 static int
-get_number PARAMS ((char **));
+get_number_trailer PARAMS ((char **, int));
 
 void
 set_breakpoint_count PARAMS ((int));
@@ -157,7 +157,9 @@ insertion_state_t;
 static int
 remove_breakpoint PARAMS ((struct breakpoint *, insertion_state_t));
 
-static int print_it_normal PARAMS ((bpstat));
+static enum print_stop_action print_it_typical PARAMS ((bpstat));
+
+static enum print_stop_action print_bp_stop_message (bpstat bs);
 
 typedef struct
   {
@@ -170,10 +172,6 @@ static int watchpoint_check PARAMS ((PTR));
 
 static int cover_target_enable_exception_callback PARAMS ((PTR));
 
-static int print_it_done PARAMS ((bpstat));
-
-static int print_it_noop PARAMS ((bpstat));
-
 static void maintenance_info_breakpoints PARAMS ((char *, int));
 
 #ifdef GET_LONGJMP_TARGET
@@ -226,8 +224,10 @@ static char *ep_parse_optional_if_clause PARAMS ((char **arg));
 
 static char *ep_parse_optional_filename PARAMS ((char **arg));
 
+#if defined(CHILD_INSERT_EXEC_CATCHPOINT)
 static void catch_exec_command_1 PARAMS ((char *arg, int tempflag, 
                                          int from_tty));
+#endif
 
 static void create_exception_catchpoint 
   PARAMS ((int tempflag, char *cond_string,
@@ -260,9 +260,7 @@ void set_breakpoint_count PARAMS ((int));
 
 extern int addressprint;       /* Print machine addresses? */
 
-#if defined (GET_LONGJMP_TARGET) || defined (SOLIB_ADD)
 static int internal_breakpoint_number = -1;
-#endif
 
 /* Are we executing breakpoint commands?  */
 static int executing_breakpoint_commands;
@@ -271,12 +269,12 @@ static int executing_breakpoint_commands;
    ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current
    breakpoint.  */
 
-#define ALL_BREAKPOINTS(b)  for (b = breakpoint_chain; b; b = b->next)
+#define ALL_BREAKPOINTS(B)  for (B = breakpoint_chain; B; B = B->next)
 
-#define ALL_BREAKPOINTS_SAFE(b,tmp)    \
-       for (b = breakpoint_chain;      \
-            b? (tmp=b->next, 1): 0;    \
-            b = tmp)
+#define ALL_BREAKPOINTS_SAFE(B,TMP)    \
+       for (B = breakpoint_chain;      \
+            B ? (TMP=B->next, 1): 0;   \
+            B = TMP)
 
 /* True if SHIFT_INST_REGS defined, false otherwise.  */
 
@@ -403,12 +401,16 @@ int default_breakpoint_line;
 
    Currently the string can either be a number or "$" followed by the name
    of a convenience variable.  Making it an expression wouldn't work well
-   for map_breakpoint_numbers (e.g. "4 + 5 + 6").  */
+   for map_breakpoint_numbers (e.g. "4 + 5 + 6").
+   
+   TRAILER is a character which can be found after the number; most
+   commonly this is `-'.  If you don't want a trailer, use \0.  */ 
 static int
-get_number (pp)
+get_number_trailer (pp, trailer)
      char **pp;
+     int trailer;
 {
-  int retval;
+  int retval = 0;      /* default */
   char *p = *pp;
 
   if (p == NULL)
@@ -428,11 +430,13 @@ get_number (pp)
       strncpy (varname, start, p - start);
       varname[p - start] = '\0';
       val = value_of_internalvar (lookup_internalvar (varname));
-      if (TYPE_CODE (VALUE_TYPE (val)) != TYPE_CODE_INT)
-       error (
- "Convenience variables used to specify breakpoints must have integer values."
-         );
-      retval = (int) value_as_long (val);
+      if (TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_INT)
+       retval = (int) value_as_long (val);
+      else
+       {
+         printf_filtered ("Convenience variable must have integer value.\n");
+         retval = 0;
+       }
     }
   else
     {
@@ -442,16 +446,116 @@ get_number (pp)
        ++p;
       if (p == *pp)
        /* There is no number here.  (e.g. "cond a == b").  */
-       error_no_arg ("breakpoint number");
-      retval = atoi (*pp);
+       {
+         /* Skip non-numeric token */
+         while (*p && !isspace((int) *p))
+           ++p;
+         /* Return zero, which caller must interpret as error. */
+         retval = 0;
+       }
+      else
+       retval = atoi (*pp);
+    }
+  if (!(isspace (*p) || *p == '\0' || *p == trailer))
+    {
+      /* Trailing junk: return 0 and let caller print error msg. */
+      while (!(isspace (*p) || *p == '\0' || *p == trailer))
+       ++p;
+      retval = 0;
     }
-  if (!(isspace (*p) || *p == '\0'))
-    error ("breakpoint number expected");
   while (isspace (*p))
     p++;
   *pp = p;
   return retval;
 }
+
+
+/* Like get_number_trailer, but don't allow a trailer.  */
+int
+get_number (pp)
+     char **pp;
+{
+  return get_number_trailer (pp, '\0');
+}
+
+/* Parse a number or a range.
+ * A number will be of the form handled by get_number.
+ * A range will be of the form <number1> - <number2>, and 
+ * will represent all the integers between number1 and number2,
+ * inclusive.
+ *
+ * While processing a range, this fuction is called iteratively;
+ * At each call it will return the next value in the range.
+ *
+ * At the beginning of parsing a range, the char pointer PP will
+ * be advanced past <number1> and left pointing at the '-' token.
+ * Subsequent calls will not advance the pointer until the range
+ * is completed.  The call that completes the range will advance
+ * pointer PP past <number2>.
+ */
+
+int 
+get_number_or_range (pp)
+     char **pp;
+{
+  static int last_retval, end_value;
+  static char *end_ptr;
+  static int in_range = 0;
+
+  if (**pp != '-')
+    {
+      /* Default case: pp is pointing either to a solo number, 
+        or to the first number of a range.  */
+      last_retval = get_number_trailer (pp, '-');
+      if (**pp == '-')
+       {
+         char **temp;
+
+         /* This is the start of a range (<number1> - <number2>).
+            Skip the '-', parse and remember the second number,
+            and also remember the end of the final token.  */
+
+         temp = &end_ptr; 
+         end_ptr = *pp + 1; 
+         while (isspace ((int) *end_ptr))
+           end_ptr++;  /* skip white space */
+         end_value = get_number (temp);
+         if (end_value < last_retval) 
+           {
+             error ("inverted range");
+           }
+         else if (end_value == last_retval)
+           {
+             /* degenerate range (number1 == number2).  Advance the
+                token pointer so that the range will be treated as a
+                single number.  */ 
+             *pp = end_ptr;
+           }
+         else
+           in_range = 1;
+       }
+    }
+  else if (! in_range)
+    error ("negative value");
+  else
+    {
+      /* pp points to the '-' that betokens a range.  All
+        number-parsing has already been done.  Return the next
+        integer value (one greater than the saved previous value).
+        Do not advance the token pointer 'pp' until the end of range
+        is reached.  */
+
+      if (++last_retval == end_value)
+       {
+         /* End of range reached; advance token pointer.  */
+         *pp = end_ptr;
+         in_range = 0;
+       }
+    }
+  return last_retval;
+}
+
+
 \f
 /* condition N EXP -- set break condition of breakpoint N to EXP.  */
 
@@ -469,6 +573,8 @@ condition_command (arg, from_tty)
 
   p = arg;
   bnum = get_number (&p);
+  if (bnum == 0)
+    error ("Bad breakpoint argument: '%s'", arg);
 
   ALL_BREAKPOINTS (b)
     if (b->number == bnum)
@@ -525,6 +631,7 @@ commands_command (arg, from_tty)
 
   p = arg;
   bnum = get_number (&p);
+
   if (p && *p)
     error ("Unexpected extra arguments following breakpoint number.");
 
@@ -842,8 +949,13 @@ insert_breakpoints ()
        if (within_current_scope)
          {
            /* Evaluate the expression and cut the chain of values
-              produced off from the value chain.  */
+              produced off from the value chain.
+
+              Make sure the value returned isn't lazy; we use
+              laziness to determine what memory GDB actually needed
+              in order to compute the value of the expression.  */
            v = evaluate_expression (b->exp);
+           VALUE_CONTENTS(v);
            value_release_to_mark (mark);
 
            b->val_chain = v;
@@ -852,8 +964,11 @@ insert_breakpoints ()
            /* Look at each value on the value chain.  */
            for (; v; v = v->next)
              {
-               /* If it's a memory location, then we must watch it.  */
-               if (v->lval == lval_memory)
+               /* If it's a memory location, and GDB actually needed
+                   its contents to evaluate the expression, then we
+                   must watch it.  */
+               if (VALUE_LVAL (v) == lval_memory
+                   && ! VALUE_LAZY (v))
                  {
                    CORE_ADDR addr;
                    int len, type;
@@ -1011,6 +1126,13 @@ update_breakpoints_after_exec ()
        continue;
       }
 
+    /* Thread event breakpoints must be set anew after an exec().  */
+    if (b->type == bp_thread_event)
+      {
+       delete_breakpoint (b);
+       continue;
+      }
+
     /* Step-resume breakpoints are meaningless after an exec(). */
     if (b->type == bp_step_resume)
       {
@@ -1198,7 +1320,8 @@ remove_breakpoint (b, is)
        {
          /* For each memory reference remove the watchpoint
             at that address.  */
-         if (v->lval == lval_memory)
+         if (VALUE_LVAL (v) == lval_memory
+             && ! VALUE_LAZY (v))
            {
              CORE_ADDR addr;
              int len, type;
@@ -1740,80 +1863,105 @@ top:
   discard_cleanups (old_chain);
 }
 
-/* This is the normal print_it function for a bpstat.  In the future,
+/* This is the normal print function for a bpstat.  In the future,
    much of this logic could (should?) be moved to bpstat_stop_status,
-   by having it set different print_it functions.
-
-   Current scheme: When we stop, bpstat_print() is called.
-   It loops through the bpstat list of things causing this stop,
-   calling the print_it function for each one. The default
-   print_it function, used for breakpoints, is print_it_normal().
-   (Also see print_it_noop() and print_it_done()).
-
-   Return values from this routine (used by bpstat_print() to
-   decide what to do):
-   1: Means we printed something, and we do *not* desire that
-   something to be followed by a location.
-   0: Means we printed something, and we *do*  desire that
-   something to be followed by a location.
-   -1: Means we printed nothing.  */
-
-static int
-print_it_normal (bs)
+   by having it set different print_it values.
+
+   Current scheme: When we stop, bpstat_print() is called.  It loops
+   through the bpstat list of things causing this stop, calling the
+   print_bp_stop_message function on each one. The behavior of the
+   print_bp_stop_message function depends on the print_it field of
+   bpstat. If such field so indicates, call this function here.
+
+   Return values from this routine (ultimately used by bpstat_print()
+   and normal_stop() to decide what to do): 
+   PRINT_NOTHING: Means we already printed all we needed to print,
+   don't print anything else.
+   PRINT_SRC_ONLY: Means we printed something, and we do *not* desire
+   that something to be followed by a location.
+   PRINT_SCR_AND_LOC: Means we printed something, and we *do* desire
+   that something to be followed by a location.
+   PRINT_UNKNOWN: Means we printed nothing or we need to do some more
+   analysis.  */
+
+static enum print_stop_action
+print_it_typical (bs)
      bpstat bs;
 {
   /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
      which has since been deleted.  */
-  if (bs->breakpoint_at == NULL
-      || (bs->breakpoint_at->type != bp_breakpoint
-         && bs->breakpoint_at->type != bp_catch_load
-         && bs->breakpoint_at->type != bp_catch_unload
-         && bs->breakpoint_at->type != bp_catch_fork
-         && bs->breakpoint_at->type != bp_catch_vfork
-         && bs->breakpoint_at->type != bp_catch_exec
-         && bs->breakpoint_at->type != bp_catch_catch
-         && bs->breakpoint_at->type != bp_catch_throw
-         && bs->breakpoint_at->type != bp_hardware_breakpoint
-         && bs->breakpoint_at->type != bp_watchpoint
-         && bs->breakpoint_at->type != bp_read_watchpoint
-         && bs->breakpoint_at->type != bp_access_watchpoint
-         && bs->breakpoint_at->type != bp_hardware_watchpoint))
-    return -1;
+  if (bs->breakpoint_at == NULL)
+    return PRINT_UNKNOWN;
 
-  if (ep_is_shlib_catchpoint (bs->breakpoint_at))
+  switch (bs->breakpoint_at->type)
     {
+    case bp_breakpoint:
+    case bp_hardware_breakpoint:
+      /* I think the user probably only wants to see one breakpoint
+         number, not all of them.  */
+      annotate_breakpoint (bs->breakpoint_at->number);
+      printf_filtered ("\nBreakpoint %d, ", bs->breakpoint_at->number);
+      return PRINT_SRC_AND_LOC;
+      break;
+
+    case bp_shlib_event:
+      /* Did we stop because the user set the stop_on_solib_events
+        variable?  (If so, we report this as a generic, "Stopped due
+        to shlib event" message.) */
+      printf_filtered ("Stopped due to shared library event\n");
+      return PRINT_NOTHING;
+      break;
+
+    case bp_thread_event:
+      /* Not sure how we will get here. 
+        GDB should not stop for these breakpoints.  */
+      printf_filtered ("Thread Event Breakpoint: gdb should not stop!\n");
+      return PRINT_NOTHING;
+      break;
+
+    case bp_catch_load:
       annotate_catchpoint (bs->breakpoint_at->number);
       printf_filtered ("\nCatchpoint %d (", bs->breakpoint_at->number);
-      if (bs->breakpoint_at->type == bp_catch_load)
-       printf_filtered ("loaded");
-      else if (bs->breakpoint_at->type == bp_catch_unload)
-       printf_filtered ("unloaded");
+      printf_filtered ("loaded");
       printf_filtered (" %s), ", bs->breakpoint_at->triggered_dll_pathname);
-      return 0;
-    }
-  else if (bs->breakpoint_at->type == bp_catch_fork ||
-          bs->breakpoint_at->type == bp_catch_vfork)
-    {
+      return PRINT_SRC_AND_LOC;
+      break;
+
+    case bp_catch_unload:
       annotate_catchpoint (bs->breakpoint_at->number);
       printf_filtered ("\nCatchpoint %d (", bs->breakpoint_at->number);
-      if (bs->breakpoint_at->type == bp_catch_fork)
-       printf_filtered ("forked");
-      else if (bs->breakpoint_at->type == bp_catch_vfork)
-       printf_filtered ("vforked");
+      printf_filtered ("unloaded");
+      printf_filtered (" %s), ", bs->breakpoint_at->triggered_dll_pathname);
+      return PRINT_SRC_AND_LOC;
+      break;
+
+    case bp_catch_fork:
+      annotate_catchpoint (bs->breakpoint_at->number);
+      printf_filtered ("\nCatchpoint %d (", bs->breakpoint_at->number);
+      printf_filtered ("forked");
       printf_filtered (" process %d), ", 
                       bs->breakpoint_at->forked_inferior_pid);
-      return 0;
-    }
-  else if (bs->breakpoint_at->type == bp_catch_exec)
-    {
+      return PRINT_SRC_AND_LOC;
+      break;
+
+    case bp_catch_vfork:
+      annotate_catchpoint (bs->breakpoint_at->number);
+      printf_filtered ("\nCatchpoint %d (", bs->breakpoint_at->number);
+      printf_filtered ("vforked");
+      printf_filtered (" process %d), ", 
+                      bs->breakpoint_at->forked_inferior_pid);
+      return PRINT_SRC_AND_LOC;
+      break;
+
+    case bp_catch_exec:
       annotate_catchpoint (bs->breakpoint_at->number);
       printf_filtered ("\nCatchpoint %d (exec'd %s), ",
                       bs->breakpoint_at->number,
                       bs->breakpoint_at->exec_pathname);
-      return 0;
-    }
-  else if (bs->breakpoint_at->type == bp_catch_catch)
-    {
+      return PRINT_SRC_AND_LOC;
+      break;
+
+    case bp_catch_catch:
       if (current_exception_event && 
          (CURRENT_EXCEPTION_KIND == EX_EVENT_CATCH))
        {
@@ -1837,15 +1985,17 @@ print_it_normal (bs)
            printf_filtered ("unknown");
 
          printf_filtered ("\n");
-         return 1;     /* don't bother to print location frame info */
+         /* don't bother to print location frame info */
+         return PRINT_SRC_ONLY;
        }
       else
        {
-         return -1;    /* really throw, some other bpstat will handle it */
+         /* really throw, some other bpstat will handle it */
+         return PRINT_UNKNOWN; 
        }
-    }
-  else if (bs->breakpoint_at->type == bp_catch_throw)
-    {
+      break;
+
+    case bp_catch_throw:
       if (current_exception_event && 
          (CURRENT_EXCEPTION_KIND == EX_EVENT_THROW))
        {
@@ -1869,97 +2019,157 @@ print_it_normal (bs)
            printf_filtered ("unknown");
 
          printf_filtered ("\n");
-         return 1;     /* don't bother to print location frame info */
+         /* don't bother to print location frame info */
+         return PRINT_SRC_ONLY; 
        }
       else
        {
-         return -1;    /* really catch, some other bpstat willhandle it */
+         /* really catch, some other bpstat will handle it */
+         return PRINT_UNKNOWN; 
        }
-    }
+      break;
 
-  else if (bs->breakpoint_at->type == bp_breakpoint ||
-          bs->breakpoint_at->type == bp_hardware_breakpoint)
-    {
-      /* I think the user probably only wants to see one breakpoint
-         number, not all of them.  */
-      annotate_breakpoint (bs->breakpoint_at->number);
-      printf_filtered ("\nBreakpoint %d, ", bs->breakpoint_at->number);
-      return 0;
-    }
-  else if ((bs->old_val != NULL) &&
-          (bs->breakpoint_at->type == bp_watchpoint ||
-           bs->breakpoint_at->type == bp_access_watchpoint ||
-           bs->breakpoint_at->type == bp_hardware_watchpoint))
-    {
-      annotate_watchpoint (bs->breakpoint_at->number);
+    case bp_watchpoint:
+    case bp_hardware_watchpoint:
+      if (bs->old_val != NULL)
+       {
+         annotate_watchpoint (bs->breakpoint_at->number);
+         mention (bs->breakpoint_at);
+         printf_filtered ("\nOld value = ");
+         value_print (bs->old_val, gdb_stdout, 0, Val_pretty_default);
+         printf_filtered ("\nNew value = ");
+         value_print (bs->breakpoint_at->val, gdb_stdout, 0,
+                      Val_pretty_default);
+         printf_filtered ("\n");
+         value_free (bs->old_val);
+         bs->old_val = NULL;
+       }
+      /* More than one watchpoint may have been triggered.  */
+      return PRINT_UNKNOWN;
+      break;
+
+    case bp_read_watchpoint:
       mention (bs->breakpoint_at);
-      printf_filtered ("\nOld value = ");
-      value_print (bs->old_val, gdb_stdout, 0, Val_pretty_default);
-      printf_filtered ("\nNew value = ");
+      printf_filtered ("\nValue = ");
       value_print (bs->breakpoint_at->val, gdb_stdout, 0,
                   Val_pretty_default);
       printf_filtered ("\n");
-      value_free (bs->old_val);
-      bs->old_val = NULL;
-      /* More than one watchpoint may have been triggered.  */
-      return -1;
-    }
-  else if (bs->breakpoint_at->type == bp_access_watchpoint ||
-          bs->breakpoint_at->type == bp_read_watchpoint)
-    {
-      mention (bs->breakpoint_at);
-      printf_filtered ("\nValue = ");
+      return PRINT_UNKNOWN;
+      break;
+
+    case bp_access_watchpoint:
+      if (bs->old_val != NULL)     
+       {
+         annotate_watchpoint (bs->breakpoint_at->number);
+         mention (bs->breakpoint_at);
+         printf_filtered ("\nOld value = ");
+         value_print (bs->old_val, gdb_stdout, 0, Val_pretty_default);
+         value_free (bs->old_val);
+         bs->old_val = NULL;
+         printf_filtered ("\nNew value = ");
+       }
+      else 
+       {
+         mention (bs->breakpoint_at);
+         printf_filtered ("\nValue = ");
+       }
       value_print (bs->breakpoint_at->val, gdb_stdout, 0,
                   Val_pretty_default);
       printf_filtered ("\n");
-      return -1;
+      return PRINT_UNKNOWN;
+      break;
+
+    /* Fall through, we don't deal with these types of breakpoints
+       here. */
+
+    case bp_finish:
+    case bp_until:
+    case bp_none:
+    case bp_longjmp:
+    case bp_longjmp_resume:
+    case bp_step_resume:
+    case bp_through_sigtramp:
+    case bp_watchpoint_scope:
+    case bp_call_dummy:
+    default:
+      return PRINT_UNKNOWN;
+    }
+}
+
+/* Generic routine for printing messages indicating why we
+   stopped. The behavior of this function depends on the value
+   'print_it' in the bpstat structure.  Under some circumstances we
+   may decide not to print anything here and delegate the task to
+   normal_stop(). */
+
+static enum print_stop_action
+print_bp_stop_message (bpstat bs)
+{
+  switch (bs->print_it)
+    {
+    case print_it_noop:
+      /* Nothing should be printed for this bpstat entry. */
+      return PRINT_UNKNOWN;
+      break;
+
+    case print_it_done:
+      /* We still want to print the frame, but we already printed the
+         relevant messages. */
+      return PRINT_SRC_AND_LOC;
+      break;
+
+    case print_it_normal:
+      /* Normal case, we handle everything in print_it_typical. */
+      return print_it_typical (bs);
+      break;
+    default:
+      internal_error ("print_bp_stop_message: unrecognized enum value");
+      break;
     }
-  /* We can't deal with it.  
-     Maybe another member of the bpstat chain can.  */
-  return -1;
 }
 
-/* Print a message indicating what happened.
-   This is called from normal_stop().
-   The input to this routine is the head of the bpstat list - a list
-   of the eventpoints that caused this stop.
-   This routine calls the "print_it" routine(s) associated
-   with these eventpoints. This will print (for example)
-   the "Breakpoint n," part of the output.
-   The return value of this routine is one of:
+/* Print a message indicating what happened.  This is called from
+   normal_stop().  The input to this routine is the head of the bpstat
+   list - a list of the eventpoints that caused this stop.  This
+   routine calls the generic print routine for printing a message
+   about reasons for stopping.  This will print (for example) the
+   "Breakpoint n," part of the output.  The return value of this
+   routine is one of:
 
-   -1: Means we printed nothing
-   0: Means we printed something, and expect subsequent
+   PRINT_UNKNOWN: Means we printed nothing
+   PRINT_SRC_AND_LOC: Means we printed something, and expect subsequent
    code to print the location. An example is 
    "Breakpoint 1, " which should be followed by
    the location.
-   : Means we printed something, but there is no need
+   PRINT_SRC_ONLY: Means we printed something, but there is no need
    to also print the location part of the message.
    An example is the catch/throw messages, which
-   don't require a location appended to the end.  */
+   don't require a location appended to the end.  
+   PRINT_NOTHING: We have done some printing and we don't need any 
+   further info to be printed.*/
 
-int
+enum print_stop_action
 bpstat_print (bs)
      bpstat bs;
 {
   int val;
 
-  if (bs == NULL)
-    return -1;
-
-  val = (*bs->print_it) (bs);
-  if (val >= 0)
-    return val;
-
   /* Maybe another breakpoint in the chain caused us to stop.
      (Currently all watchpoints go on the bpstat whether hit or not.
      That probably could (should) be changed, provided care is taken
      with respect to bpstat_explains_signal).  */
-  if (bs->next)
-    return bpstat_print (bs->next);
+  for (; bs; bs = bs->next)
+    {
+      val = print_bp_stop_message (bs);
+      if (val == PRINT_SRC_ONLY 
+         || val == PRINT_SRC_AND_LOC 
+         || val == PRINT_NOTHING)
+       return val;
+    }
 
-  /* We reached the end of the chain without printing anything.  */
-  return -1;
+  /* We reached the end of the chain, or we got a null BS to start
+     with and nothing was printed. */
+  return PRINT_UNKNOWN;
 }
 
 /* Evaluate the expression EXP and return 1 if value is zero.
@@ -2074,9 +2284,14 @@ watchpoint_check (p)
          So we can't even detect the first assignment to it and
          watch after that (since the garbage may or may not equal
          the first value assigned).  */
+      /* We print all the stop information in print_it_typical(), but
+        in this case, by the time we call print_it_typical() this bp
+        will be deleted already. So we have no choice but print the
+        information here. */
       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 (b->related_breakpoint)
        b->related_breakpoint->disposition = del_at_next_stop;
       b->disposition = del_at_next_stop;
@@ -2085,40 +2300,6 @@ which its expression is valid.\n", bs->breakpoint_at->number);
     }
 }
 
-/* This is used when everything which needs to be printed has
-   already been printed.  But we still want to print the frame.  */
-
-/* Background: When we stop, bpstat_print() is called.
-   It loops through the bpstat list of things causing this stop,
-   calling the print_it function for each one. The default
-   print_it function, used for breakpoints, is print_it_normal().
-   Also see print_it_noop() and print_it_done() are the other 
-   two possibilities. See comments in bpstat_print() and
-   in header of print_it_normal() for more detail.  */
-
-static int
-print_it_done (bs)
-     bpstat bs;
-{
-  return 0;
-}
-
-/* This is used when nothing should be printed for this bpstat entry.  */
-/* Background: When we stop, bpstat_print() is called.
-   It loops through the bpstat list of things causing this stop,
-   calling the print_it function for each one. The default
-   print_it function, used for breakpoints, is print_it_normal().
-   Also see print_it_noop() and print_it_done() are the other 
-   two possibilities. See comments in bpstat_print() and
-   in header of print_it_normal() for more detail.  */
-
-static int
-print_it_noop (bs)
-     bpstat bs;
-{
-  return -1;
-}
-
 /* Get a bpstat associated with having just stopped at address *PC
    and frame address CORE_ADDRESS.  Update *PC to point at the
    breakpoint (if we hit a breakpoint).  NOT_A_BREAKPOINT is nonzero
@@ -2245,6 +2426,9 @@ bpstat_stop_status (pc, not_a_breakpoint)
          {
          case WP_DELETED:
            /* We've already printed what needs to be printed.  */
+           /* Actually this is superfluous, because by the time we
+               call print_it_typical() the wp will be already deleted,
+               and the function will return immediately. */
            bs->print_it = print_it_done;
            /* Stop.  */
            break;
@@ -2256,8 +2440,6 @@ bpstat_stop_status (pc, not_a_breakpoint)
            /* Don't stop.  */
            bs->print_it = print_it_noop;
            bs->stop = 0;
-           /* Don't consider this a hit.  */
-           --(b->hit_count);
            continue;
          default:
            /* Can't happen.  */
@@ -2287,7 +2469,8 @@ bpstat_stop_status (pc, not_a_breakpoint)
          continue;
        for (v = b->val_chain; v; v = v->next)
          {
-           if (v->lval == lval_memory)
+           if (VALUE_LVAL (v) == lval_memory
+               && ! VALUE_LAZY (v))
              {
                CORE_ADDR vaddr;
 
@@ -2345,9 +2528,8 @@ bpstat_stop_status (pc, not_a_breakpoint)
        real_breakpoint = 1;
       }
 
-    if (b->frame && b->frame != (get_current_frame ())->frame &&
-       (b->type == bp_step_resume &&
-        (INNER_THAN (get_current_frame ()->frame, b->frame))))
+    if (b->frame &&
+       b->frame != (get_current_frame ())->frame)
       bs->stop = 0;
     else
       {
@@ -2374,6 +2556,7 @@ bpstat_stop_status (pc, not_a_breakpoint)
        else if (b->ignore_count > 0)
          {
            b->ignore_count--;
+           annotate_ignore_count_change ();
            bs->stop = 0;
          }
        else
@@ -2660,6 +2843,9 @@ bpstat_what (bs)
        case bp_shlib_event:
          bs_class = shlib_event;
          break;
+       case bp_thread_event:
+         bs_class = bp_nostop;
+         break;
        case bp_catch_load:
        case bp_catch_unload:
          /* Only if this catchpoint triggered should we cause the
@@ -2803,28 +2989,19 @@ bpstat_get_triggered_catchpoints (ep_list, cp_list)
   *cp_list = bs;
 }
 
-/* Print information on breakpoint number BNUM, or -1 if all.
-   If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
-   is nonzero, process only watchpoints.  */
-
-typedef struct
-{
-  enum bptype type;
-  char *description;
-}
-ep_type_description_t;
-
+/* Print B to gdb_stdout. */
 static void
-breakpoint_1 (bnum, allflag)
-     int bnum;
-     int allflag;
+print_one_breakpoint (struct breakpoint *b,
+                     CORE_ADDR *last_addr)
 {
-  register struct breakpoint *b;
   register struct command_line *l;
   register struct symbol *sym;
-  CORE_ADDR last_addr = (CORE_ADDR) -1;
-  int found_a_breakpoint = 0;
-  static ep_type_description_t bptypes[] =
+  struct ep_type_description
+    {
+      enum bptype type;
+      char *description;
+    };
+  static struct ep_type_description bptypes[] =
   {
     {bp_none, "?deleted?"},
     {bp_breakpoint, "breakpoint"},
@@ -2842,6 +3019,7 @@ breakpoint_1 (bnum, allflag)
     {bp_watchpoint_scope, "watchpoint scope"},
     {bp_call_dummy, "call dummy"},
     {bp_shlib_event, "shlib events"},
+    {bp_thread_event, "thread events"},
     {bp_catch_load, "catch load"},
     {bp_catch_unload, "catch unload"},
     {bp_catch_fork, "catch fork"},
@@ -2850,235 +3028,293 @@ breakpoint_1 (bnum, allflag)
     {bp_catch_catch, "catch catch"},
     {bp_catch_throw, "catch throw"}
   };
-
+  
   static char *bpdisps[] =
   {"del", "dstp", "dis", "keep"};
   static char bpenables[] = "nynny";
   char wrap_indent[80];
 
-
-
-  ALL_BREAKPOINTS (b)
-    if (bnum == -1
-       || bnum == b->number)
+  annotate_record ();
+
+  /* 1 */
+  annotate_field (0);
+  printf_filtered ("%-3d ", b->number);
+
+  /* 2 */
+  annotate_field (1);
+  if (((int) b->type > (sizeof (bptypes) / sizeof (bptypes[0])))
+      || ((int) b->type != bptypes[(int) b->type].type))
+    internal_error ("bptypes table does not describe type #%d.",
+                   (int) b->type);
+  printf_filtered ("%-14s ", bptypes[(int) b->type].description);
+
+  /* 3 */
+  annotate_field (2);
+  printf_filtered ("%-4s ", bpdisps[(int) b->disposition]);
+
+  /* 4 */
+  annotate_field (3);
+  printf_filtered ("%-3c ", bpenables[(int) b->enable]);
+  
+  /* 5 and 6 */
+  strcpy (wrap_indent, "                           ");
+  if (addressprint)
+    strcat (wrap_indent, "           ");
+  switch (b->type)
     {
-/*  We only print out user settable breakpoints unless the allflag is set. */
-      if (!allflag
-         && b->type != bp_breakpoint
-         && b->type != bp_catch_load
-         && b->type != bp_catch_unload
-         && b->type != bp_catch_fork
-         && b->type != bp_catch_vfork
-         && b->type != bp_catch_exec
-         && b->type != bp_catch_catch
-         && b->type != bp_catch_throw
-         && b->type != bp_hardware_breakpoint
-         && b->type != bp_watchpoint
-         && b->type != bp_read_watchpoint
-         && b->type != bp_access_watchpoint
-         && b->type != bp_hardware_watchpoint)
-       continue;
+    case bp_none:
+      internal_error ("print_one_breakpoint: bp_none encountered\n");
+      break;
 
-      if (!found_a_breakpoint++)
-       {
-         annotate_breakpoints_headers ();
-
-         annotate_field (0);
-         printf_filtered ("Num ");
-         annotate_field (1);
-         printf_filtered ("Type           ");
-         annotate_field (2);
-         printf_filtered ("Disp ");
-         annotate_field (3);
-         printf_filtered ("Enb ");
-         if (addressprint)
-           {
-             annotate_field (4);
-             printf_filtered ("Address    ");
-           }
-         annotate_field (5);
-         printf_filtered ("What\n");
+    case bp_watchpoint:
+    case bp_hardware_watchpoint:
+    case bp_read_watchpoint:
+    case bp_access_watchpoint:
+      /* Field 4, the address, is omitted (which makes the columns
+        not line up too nicely with the headers, but the effect
+        is relatively readable).  */
+      annotate_field (5);
+      print_expression (b->exp, gdb_stdout);
+      break;
+      
+    case bp_catch_load:
+    case bp_catch_unload:
+      /* Field 4, the address, is omitted (which makes the columns
+        not line up too nicely with the headers, but the effect
+        is relatively readable).  */
+      annotate_field (5);
+      if (b->dll_pathname == NULL)
+       printf_filtered ("<any library> ");
+      else
+       printf_filtered ("library \"%s\" ", b->dll_pathname);
+      break;
+      
+    case bp_catch_fork:
+    case bp_catch_vfork:
+      /* Field 4, the address, is omitted (which makes the columns
+        not line up too nicely with the headers, but the effect
+        is relatively readable).  */
+      annotate_field (5);
+      if (b->forked_inferior_pid != 0)
+       printf_filtered ("process %d ", b->forked_inferior_pid);
+      break;
+      
+    case bp_catch_exec:
+      /* Field 4, the address, is omitted (which makes the columns
+        not line up too nicely with the headers, but the effect
+        is relatively readable).  */
+      annotate_field (5);
+      if (b->exec_pathname != NULL)
+       printf_filtered ("program \"%s\" ", b->exec_pathname);
+      break;
 
-         annotate_breakpoints_table ();
-       }
+    case bp_catch_catch:
+      /* Field 4, the address, is omitted (which makes the columns
+        not line up too nicely with the headers, but the effect
+        is relatively readable).  */
+      annotate_field (5);
+      printf_filtered ("exception catch ");
+      break;
 
-      annotate_record ();
-      annotate_field (0);
-      printf_filtered ("%-3d ", b->number);
-      annotate_field (1);
-      if ((int) b->type > (sizeof (bptypes) / sizeof (bptypes[0])))
-       error ("bptypes table does not describe type #%d.", (int) b->type);
-      if ((int) b->type != bptypes[(int) b->type].type)
-       error ("bptypes table does not describe type #%d?", (int) b->type);
-      printf_filtered ("%-14s ", bptypes[(int) b->type].description);
-      annotate_field (2);
-      printf_filtered ("%-4s ", bpdisps[(int) b->disposition]);
-      annotate_field (3);
-      printf_filtered ("%-3c ", bpenables[(int) b->enable]);
-
-      strcpy (wrap_indent, "                           ");
+    case bp_catch_throw:
+      /* Field 4, the address, is omitted (which makes the columns
+        not line up too nicely with the headers, but the effect
+        is relatively readable).  */
+      annotate_field (5);
+      printf_filtered ("exception throw ");
+      break;
+      
+    case bp_breakpoint:
+    case bp_hardware_breakpoint:
+    case bp_until:
+    case bp_finish:
+    case bp_longjmp:
+    case bp_longjmp_resume:
+    case bp_step_resume:
+    case bp_through_sigtramp:
+    case bp_watchpoint_scope:
+    case bp_call_dummy:
+    case bp_shlib_event:
+    case bp_thread_event:
       if (addressprint)
-       strcat (wrap_indent, "           ");
-      switch (b->type)
        {
-       case bp_watchpoint:
-       case bp_hardware_watchpoint:
-       case bp_read_watchpoint:
-       case bp_access_watchpoint:
-         /* Field 4, the address, is omitted (which makes the columns
-            not line up too nicely with the headers, but the effect
-            is relatively readable).  */
-         annotate_field (5);
-         print_expression (b->exp, gdb_stdout);
-         break;
-
-       case bp_catch_load:
-       case bp_catch_unload:
-         /* Field 4, the address, is omitted (which makes the columns
-            not line up too nicely with the headers, but the effect
-            is relatively readable).  */
-         annotate_field (5);
-         if (b->dll_pathname == NULL)
-           printf_filtered ("<any library> ");
-         else
-           printf_filtered ("library \"%s\" ", b->dll_pathname);
-         break;
-
-       case bp_catch_fork:
-       case bp_catch_vfork:
-         /* Field 4, the address, is omitted (which makes the columns
-            not line up too nicely with the headers, but the effect
-            is relatively readable).  */
-         annotate_field (5);
-         if (b->forked_inferior_pid != 0)
-           printf_filtered ("process %d ", b->forked_inferior_pid);
-         break;
-
-       case bp_catch_exec:
-         /* Field 4, the address, is omitted (which makes the columns
-            not line up too nicely with the headers, but the effect
-            is relatively readable).  */
-         annotate_field (5);
-         if (b->exec_pathname != NULL)
-           printf_filtered ("program \"%s\" ", b->exec_pathname);
-         break;
-       case bp_catch_catch:
-         /* Field 4, the address, is omitted (which makes the columns
-            not line up too nicely with the headers, but the effect
-            is relatively readable).  */
-         annotate_field (5);
-         printf_filtered ("exception catch ");
-         break;
-       case bp_catch_throw:
-         /* Field 4, the address, is omitted (which makes the columns
-            not line up too nicely with the headers, but the effect
-            is relatively readable).  */
-         annotate_field (5);
-         printf_filtered ("exception throw ");
-         break;
-
-       case bp_breakpoint:
-       case bp_hardware_breakpoint:
-       case bp_until:
-       case bp_finish:
-       case bp_longjmp:
-       case bp_longjmp_resume:
-       case bp_step_resume:
-       case bp_through_sigtramp:
-       case bp_watchpoint_scope:
-       case bp_call_dummy:
-       case bp_shlib_event:
-         if (addressprint)
-           {
-             annotate_field (4);
-             /* FIXME-32x64: need a print_address_numeric with
-                field width */
-             printf_filtered
-               ("%s ",
-                local_hex_string_custom
-                ((unsigned long) b->address, "08l"));
-           }
-
-         annotate_field (5);
-
-         last_addr = b->address;
-         if (b->source_file)
+         annotate_field (4);
+         /* FIXME-32x64: need a print_address_numeric with
+            field width */
+         printf_filtered
+           ("%s ",
+            local_hex_string_custom
+            ((unsigned long) b->address, "08l"));
+       }
+      annotate_field (5);
+      *last_addr = b->address;
+      if (b->source_file)
+       {
+         sym = find_pc_sect_function (b->address, b->section);
+         if (sym)
            {
-             sym = find_pc_sect_function (b->address, b->section);
-             if (sym)
-               {
-                 fputs_filtered ("in ", gdb_stdout);
-                 fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout);
-                 wrap_here (wrap_indent);
-                 fputs_filtered (" at ", gdb_stdout);
-               }
-             fputs_filtered (b->source_file, gdb_stdout);
-             printf_filtered (":%d", b->line_number);
+             fputs_filtered ("in ", gdb_stdout);
+             fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout);
+             wrap_here (wrap_indent);
+             fputs_filtered (" at ", gdb_stdout);
            }
-         else
-           print_address_symbolic (b->address, gdb_stdout, demangle, " ");
-         break;
+         fputs_filtered (b->source_file, gdb_stdout);
+         printf_filtered (":%d", b->line_number);
        }
-
-      if (b->thread != -1)
-       printf_filtered (" thread %d", b->thread);
-
+      else
+       print_address_symbolic (b->address, gdb_stdout, demangle, " ");
+      break;
+    }
+  
+  if (b->thread != -1)
+    {
+      printf_filtered (" thread %d", b->thread);
+    }
+  
+  printf_filtered ("\n");
+  
+  if (b->frame)
+    {
+      annotate_field (6);
+      printf_filtered ("\tstop only in stack frame at ");
+      print_address_numeric (b->frame, 1, gdb_stdout);
       printf_filtered ("\n");
-
-      if (b->frame)
-       {
-         annotate_field (6);
-
-         printf_filtered ("\tstop only in stack frame at ");
-         print_address_numeric (b->frame, 1, gdb_stdout);
-         printf_filtered ("\n");
-       }
-
-      if (b->cond)
-       {
-         annotate_field (7);
-
-         printf_filtered ("\tstop only if ");
-         print_expression (b->cond, gdb_stdout);
-         printf_filtered ("\n");
-       }
-
-      if (b->thread != -1)
+    }
+  
+  if (b->cond)
+    {
+      annotate_field (7);
+      printf_filtered ("\tstop only if ");
+      print_expression (b->cond, gdb_stdout);
+      printf_filtered ("\n");
+    }
+  
+  if (b->thread != -1)
+    {
+      /* FIXME should make an annotation for this */
+      printf_filtered ("\tstop only in thread %d\n", b->thread);
+    }
+  
+  if (show_breakpoint_hit_counts && b->hit_count)
+    {
+      /* FIXME should make an annotation for this */
+      if (ep_is_catchpoint (b))
+       printf_filtered ("\tcatchpoint");
+      else
+       printf_filtered ("\tbreakpoint");
+      printf_filtered (" already hit %d time%s\n",
+                      b->hit_count, (b->hit_count == 1 ? "" : "s"));
+    }
+  
+  if (b->ignore_count)
+    {
+      annotate_field (8);
+      printf_filtered ("\tignore next %d hits\n", b->ignore_count);
+    }
+  
+  if ((l = b->commands))
+    {
+      annotate_field (9);
+      while (l)
        {
-         /* FIXME should make an annotation for this */
-         printf_filtered ("\tstop only in thread %d\n", b->thread);
+         print_command_line (l, 4, gdb_stdout);
+         l = l->next;
        }
+    }
+}
 
-      if (show_breakpoint_hit_counts && b->hit_count)
-       {
-         /* FIXME should make an annotation for this */
-         if (ep_is_catchpoint (b))
-           printf_filtered ("\tcatchpoint");
-         else
-           printf_filtered ("\tbreakpoint");
-         printf_filtered (" already hit %d time%s\n",
-                          b->hit_count, (b->hit_count == 1 ? "" : "s"));
-       }
+struct captured_breakpoint_query_args
+  {
+    int bnum;
+  };
 
-      if (b->ignore_count)
+static int
+do_captured_breakpoint_query (void *data)
+{
+  struct captured_breakpoint_query_args *args = data;
+  register struct breakpoint *b;
+  CORE_ADDR dummy_addr = 0;
+  ALL_BREAKPOINTS (b)
+    {
+      if (args->bnum == b->number)
        {
-         annotate_field (8);
-
-         printf_filtered ("\tignore next %d hits\n", b->ignore_count);
+         print_one_breakpoint (b, &dummy_addr);
+         return GDB_RC_OK;
        }
+    }
+  return GDB_RC_NONE;
+}
 
-      if ((l = b->commands))
-       {
-         annotate_field (9);
+enum gdb_rc
+gdb_breakpoint_query (/* output object, */ int bnum)
+{
+  struct captured_breakpoint_query_args args;
+  args.bnum = bnum;
+  /* For the moment we don't trust print_one_breakpoint() to not throw
+     an error. */
+  return catch_errors (do_captured_breakpoint_query, &args,
+                      NULL, RETURN_MASK_ALL);
+}
 
-         while (l)
-           {
-             print_command_line (l, 4, gdb_stdout);
-             l = l->next;
-           }
-       }
-    }
+/* Print information on breakpoint number BNUM, or -1 if all.
+   If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
+   is nonzero, process only watchpoints.  */
 
+static void
+breakpoint_1 (bnum, allflag)
+     int bnum;
+     int allflag;
+{
+  register struct breakpoint *b;
+  CORE_ADDR last_addr = (CORE_ADDR) -1;
+  int found_a_breakpoint = 0;
+  
+  ALL_BREAKPOINTS (b)
+    if (bnum == -1
+       || bnum == b->number)
+      {
+       /* We only print out user settable breakpoints unless the
+          allflag is set. */
+       if (!allflag
+           && b->type != bp_breakpoint
+           && b->type != bp_catch_load
+           && b->type != bp_catch_unload
+           && b->type != bp_catch_fork
+           && b->type != bp_catch_vfork
+           && b->type != bp_catch_exec
+           && b->type != bp_catch_catch
+           && b->type != bp_catch_throw
+           && b->type != bp_hardware_breakpoint
+           && b->type != bp_watchpoint
+           && b->type != bp_read_watchpoint
+           && b->type != bp_access_watchpoint
+           && b->type != bp_hardware_watchpoint)
+         continue;
+       
+       if (!found_a_breakpoint++)
+         {
+           annotate_breakpoints_headers ();
+           annotate_field (0);
+           printf_filtered ("Num ");
+           annotate_field (1);
+           printf_filtered ("Type           ");
+           annotate_field (2);
+           printf_filtered ("Disp ");
+           annotate_field (3);
+           printf_filtered ("Enb ");
+           if (addressprint)
+             {
+               annotate_field (4);
+               printf_filtered ("Address    ");
+             }
+           annotate_field (5);
+           printf_filtered ("What\n");
+           annotate_breakpoints_table ();
+         }
+       
+       print_one_breakpoint (b, &last_addr);
+      }
+  
   if (!found_a_breakpoint)
     {
       if (bnum == -1)
@@ -3087,11 +3323,15 @@ breakpoint_1 (bnum, allflag)
        printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum);
     }
   else
-    /* Compare against (CORE_ADDR)-1 in case some compiler decides
-       that a comparison of an unsigned with -1 is always false.  */
-  if (last_addr != (CORE_ADDR) -1)
-    set_next_address (last_addr);
+    {
+      /* Compare against (CORE_ADDR)-1 in case some compiler decides
+        that a comparison of an unsigned with -1 is always false.  */
+      if (last_addr != (CORE_ADDR) -1)
+       set_next_address (last_addr);
+    }
 
+  /* FIXME? Should this be moved up so that it is only called when
+     there have been breakpoints? */
   annotate_breakpoints_table_end ();
 }
 
@@ -3384,6 +3624,42 @@ disable_longjmp_breakpoint ()
     }
 }
 
+struct breakpoint *
+create_thread_event_breakpoint (address)
+     CORE_ADDR address;
+{
+  struct breakpoint *b;
+  struct symtab_and_line sal;
+  char addr_string[80];                /* Surely an addr can't be longer than that. */
+
+  INIT_SAL (&sal);             /* initialize to zeroes */
+  sal.pc = address;
+  sal.section = find_pc_overlay (sal.pc);
+  if ((b = set_raw_breakpoint (sal)) == NULL)
+    return NULL;
+  
+  b->number = internal_breakpoint_number--;
+  b->disposition = donttouch;
+  b->type = bp_thread_event;   /* XXX: do we need a new type? 
+                                  bp_thread_event */
+  b->enable = 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 = strsave (addr_string);
+
+  return b;
+}
+
+void
+remove_thread_event_breakpoints (void)
+{
+  struct breakpoint *b, *temp;
+
+  ALL_BREAKPOINTS_SAFE (b, temp)
+    if (b->type == bp_thread_event)
+      delete_breakpoint (b);
+}
+
 #ifdef SOLIB_ADD
 void
 remove_solib_event_breakpoints ()
@@ -3868,6 +4144,7 @@ mention (b)
     case bp_call_dummy:
     case bp_watchpoint_scope:
     case bp_shlib_event:
+    case bp_thread_event:
       break;
     }
   if (say_where)
@@ -4648,21 +4925,46 @@ can_use_hardware_watchpoint (v)
   if (!can_use_hw_watchpoints)
     return 0;
 
-  /* Make sure all the intermediate values are in memory.  Also make sure
-     we found at least one memory expression.  Guards against watch 0x12345,
-     which is meaningless, but could cause errors if one tries to insert a 
-     hardware watchpoint for the constant expression.  */
+  /* Make sure that the value of the expression depends only upon
+     memory contents, and values computed from them within GDB.  If we
+     find any register references or function calls, we can't use a
+     hardware watchpoint.
+
+     The idea here is that evaluating an expression generates a series
+     of values, one holding the value of every subexpression.  (The
+     expression a*b+c has five subexpressions: a, b, a*b, c, and
+     a*b+c.)  GDB's values hold almost enough information to establish
+     the criteria given above --- they identify memory lvalues,
+     register lvalues, computed values, etcetera.  So we can evaluate
+     the expression, and then scan the chain of values that leaves
+     behind to decide whether we can detect any possible change to the
+     expression's final value using only hardware watchpoints.
+
+     However, I don't think that the values returned by inferior
+     function calls are special in any way.  So this function may not
+     notice that an expression involving an inferior function call
+     can't be watched with hardware watchpoints.  FIXME.  */
   for (; v; v = v->next)
     {
-      if (v->lval == lval_memory)
+      if (VALUE_LVAL (v) == lval_memory)
        {
-         CORE_ADDR vaddr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
-         int       len   = TYPE_LENGTH (VALUE_TYPE (v));
-
-         if (!TARGET_REGION_OK_FOR_HW_WATCHPOINT (vaddr, len))
-           return 0;
+         if (VALUE_LAZY (v))
+           /* A lazy memory lvalue is one that GDB never needed to fetch;
+              we either just used its address (e.g., `a' in `a.b') or
+              we never needed it at all (e.g., `a' in `a,b').  */
+           ;
          else
-           found_memory_cnt++;
+           {
+             /* Ahh, memory we actually used!  Check if we can cover
+                 it with hardware watchpoints.  */
+             CORE_ADDR vaddr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);
+             int       len   = TYPE_LENGTH (VALUE_TYPE (v));
+
+             if (!TARGET_REGION_OK_FOR_HW_WATCHPOINT (vaddr, len))
+               return 0;
+             else
+               found_memory_cnt++;
+           }
        }
       else if (v->lval != not_lval && v->modifiable == 0)
        return 0;       /* ??? What does this represent? */
@@ -5126,6 +5428,7 @@ typedef enum
 }
 catch_fork_kind;
 
+#if defined(CHILD_INSERT_FORK_CATCHPOINT) || defined(CHILD_INSERT_VFORK_CATCHPOINT)
 static void catch_fork_command_1 PARAMS ((catch_fork_kind fork_kind, 
                                          char *arg, 
                                          int tempflag, 
@@ -5167,7 +5470,9 @@ catch_fork_command_1 (fork_kind, arg, tempflag, from_tty)
       break;
     }
 }
+#endif
 
+#if defined(CHILD_INSERT_EXEC_CATCHPOINT)
 static void
 catch_exec_command_1 (arg, tempflag, from_tty)
      char *arg;
@@ -5192,6 +5497,7 @@ catch_exec_command_1 (arg, tempflag, from_tty)
      and enable reporting of such events. */
   create_exec_event_catchpoint (tempflag, cond_string);
 }
+#endif
 
 #if defined(SOLIB_ADD)
 static void
@@ -6079,6 +6385,7 @@ delete_command (arg, from_tty)
       {
        if (b->type != bp_call_dummy &&
            b->type != bp_shlib_event &&
+           b->type != bp_thread_event &&
            b->number >= 0)
          breaks_to_delete = 1;
       }
@@ -6091,6 +6398,7 @@ delete_command (arg, from_tty)
          {
            if (b->type != bp_call_dummy &&
                b->type != bp_shlib_event &&
+               b->type != bp_thread_event &&
                b->number >= 0)
              delete_breakpoint (b);
          }
@@ -6264,6 +6572,10 @@ breakpoint_re_set_one (bint)
          starts and we really don't want to touch it.  */
     case bp_shlib_event:
 
+      /* Like bp_shlib_event, this breakpoint type is special.
+        Once it is set up, we do not want to touch it.  */
+    case bp_thread_event:
+
       /* Keep temporary breakpoints, which can be encountered when we step
          over a dlopen call and SOLIB_ADD is resetting the breakpoints.
          Otherwise these should have been blown away via the cleanup chain
@@ -6390,7 +6702,8 @@ ignore_command (args, from_tty)
     error_no_arg ("a breakpoint number");
 
   num = get_number (&p);
-
+  if (num == 0)
+    error ("bad breakpoint number: '%s'", args);
   if (*p == 0)
     error ("Second argument (specified ignore-count) is missing.");
 
@@ -6412,28 +6725,37 @@ map_breakpoint_numbers (args, function)
   register char *p = args;
   char *p1;
   register int num;
-  register struct breakpoint *b;
+  register struct breakpoint *b, *tmp;
+  int match;
 
   if (p == 0)
     error_no_arg ("one or more breakpoint numbers");
 
   while (*p)
     {
+      match = 0;
       p1 = p;
 
-      num = get_number (&p1);
-
-      ALL_BREAKPOINTS (b)
-       if (b->number == num)
+      num = get_number_or_range (&p1);
+      if (num == 0)
        {
-         struct breakpoint *related_breakpoint = b->related_breakpoint;
-         function (b);
-         if (related_breakpoint)
-           function (related_breakpoint);
-         goto win;
+         warning ("bad breakpoint number at or near '%s'", p);
+       }
+      else
+       {
+         ALL_BREAKPOINTS_SAFE (b, tmp)
+           if (b->number == num)
+             {
+               struct breakpoint *related_breakpoint = b->related_breakpoint;
+               match = 1;
+               function (b);
+               if (related_breakpoint)
+                 function (related_breakpoint);
+               break;
+             }
+         if (match == 0)
+           printf_unfiltered ("No breakpoint number %d.\n", num);
        }
-      printf_unfiltered ("No breakpoint number %d.\n", num);
-    win:
       p = p1;
     }
 }
This page took 0.040022 seconds and 4 git commands to generate.