addr = target_stopped_data_address (); if (addr == 0)
if (!target_stopped_data_address (&current_target, &addr))
bpstat_stop_status (CORE_ADDR bp_addr, ptid_t ptid){  struct breakpoint *b, *temp;  /* True if we've hit a breakpoint (as opposed to a watchpoint).  */  int real_breakpoint = 0;  /* Root of the chain of bpstat's */  struct bpstats root_bs[1];  /* Pointer to the last thing in the chain currently.  */  bpstat bs = root_bs;  int thread_id = pid_to_thread_id (ptid);  ALL_BREAKPOINTS_SAFE (b, temp)  {    if (!breakpoint_enabled (b) && b->enable_state != bp_permanent)      continue;    if (b->type != bp_watchpoint	&& b->type != bp_hardware_watchpoint	&& b->type != bp_read_watchpoint	&& b->type != bp_access_watchpoint	&& b->type != bp_hardware_breakpoint	&& 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)	/* a non-watchpoint bp */      {	if (b->loc->address != bp_addr) 	/* address doesn't match */	  continue;	if (overlay_debugging		/* unmapped overlay section */	    && section_is_overlay (b->loc->section) 	    && !section_is_mapped (b->loc->section))	  continue;      }    if (b->type == bp_hardware_breakpoint)      {	if (b->loc->address != bp_addr)	  continue;	if (overlay_debugging		/* unmapped overlay section */	    && section_is_overlay (b->loc->section) 	    && !section_is_mapped (b->loc->section))	  continue;      }    /* Is this a catchpoint of a load or unload?  If so, did we       get a load or unload of the specified library?  If not,       ignore it. */    if ((b->type == bp_catch_load)#if defined(SOLIB_HAVE_LOAD_EVENT)	&& (!SOLIB_HAVE_LOAD_EVENT (PIDGET (inferior_ptid))	    || ((b->dll_pathname != NULL)		&& (strcmp (b->dll_pathname, 			    SOLIB_LOADED_LIBRARY_PATHNAME (			      PIDGET (inferior_ptid)))		    != 0)))#endif      )      continue;    if ((b->type == bp_catch_unload)#if defined(SOLIB_HAVE_UNLOAD_EVENT)	&& (!SOLIB_HAVE_UNLOAD_EVENT (PIDGET (inferior_ptid))	    || ((b->dll_pathname != NULL)		&& (strcmp (b->dll_pathname, 			    SOLIB_UNLOADED_LIBRARY_PATHNAME (			      PIDGET (inferior_ptid)))		    != 0)))#endif      )      continue;    if ((b->type == bp_catch_fork)	&& !inferior_has_forked (PIDGET (inferior_ptid),				 &b->forked_inferior_pid))      continue;    if ((b->type == bp_catch_vfork)	&& !inferior_has_vforked (PIDGET (inferior_ptid),				  &b->forked_inferior_pid))      continue;    if ((b->type == bp_catch_exec)	&& !inferior_has_execd (PIDGET (inferior_ptid), &b->exec_pathname))      continue;    if (ep_is_exception_catchpoint (b) &&	!(current_exception_event = target_get_current_exception_event ()))      continue;    /* Come here if it's a watchpoint, or if the break address matches */    bs = bpstat_alloc (b, bs);	/* Alloc a bpstat to explain stop */    /* Watchpoints may change this, if not found to have triggered. */    bs->stop = 1;    bs->print = 1;    if (b->type == bp_watchpoint ||	b->type == bp_hardware_watchpoint)      {	char *message = xstrprintf ("Error evaluating expression for watchpoint %d\n",				    b->number);	struct cleanup *cleanups = make_cleanup (xfree, message);	int e = catch_errors (watchpoint_check, bs, message, 			      RETURN_MASK_ALL);	do_cleanups (cleanups);	switch (e)	  {	  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;	  case WP_VALUE_CHANGED:	    /* Stop.  */	    ++(b->hit_count);	    break;	  case WP_VALUE_NOT_CHANGED:	    /* Don't stop.  */	    bs->print_it = print_it_noop;	    bs->stop = 0;	    continue;	  default:	    /* Can't happen.  */	    /* FALLTHROUGH */	  case 0:	    /* Error from catch_errors.  */	    printf_filtered ("Watchpoint %d deleted.\n", b->number);	    if (b->related_breakpoint)	      b->related_breakpoint->disposition = disp_del_at_next_stop;	    b->disposition = disp_del_at_next_stop;	    /* We've already printed what needs to be printed.  */	    bs->print_it = print_it_done;	    /* Stop.  */	    break;	  }      }    else if (b->type == bp_read_watchpoint || 	     b->type == bp_access_watchpoint)      {	CORE_ADDR addr;	struct value *v;	int found = 0;	addr = target_stopped_data_address ();	if (addr == 0)	  continue;	for (v = b->val_chain; v; v = v->next)	  {	    if (VALUE_LVAL (v) == lval_memory		&& ! VALUE_LAZY (v))	      {		struct type *vtype = check_typedef (VALUE_TYPE (v));		if (v == b->val_chain		    || (TYPE_CODE (vtype) != TYPE_CODE_STRUCT			&& TYPE_CODE (vtype) != TYPE_CODE_ARRAY))		  {		    CORE_ADDR vaddr;		    vaddr = VALUE_ADDRESS (v) + VALUE_OFFSET (v);		    /* Exact match not required.  Within range is                       sufficient.  */		    if (addr >= vaddr &&			addr < vaddr + TYPE_LENGTH (VALUE_TYPE (v)))		      found = 1;		  }	      }	  }	if (found)	  {	    char *message = xstrprintf ("Error evaluating expression for watchpoint %d\n",					b->number);	    struct cleanup *cleanups = make_cleanup (xfree, message);	    int e = catch_errors (watchpoint_check, bs, message,				  RETURN_MASK_ALL);	    do_cleanups (cleanups);	    switch (e)	      {	      case WP_DELETED:		/* We've already printed what needs to be printed.  */		bs->print_it = print_it_done;		/* Stop.  */		break;	      case WP_VALUE_CHANGED:		if (b->type == bp_read_watchpoint)		  {		    /* Don't stop: read watchpoints shouldn't fire if		       the value has changed.  This is for targets		       which cannot set read-only watchpoints.  */		    bs->print_it = print_it_noop;		    bs->stop = 0;		    continue;		  }		++(b->hit_count);		break;	      case WP_VALUE_NOT_CHANGED:		/* Stop.  */		++(b->hit_count);		break;	      default:		/* Can't happen.  */	      case 0:		/* Error from catch_errors.  */		printf_filtered ("Watchpoint %d deleted.\n", b->number);		if (b->related_breakpoint)		  b->related_breakpoint->disposition = disp_del_at_next_stop;		b->disposition = disp_del_at_next_stop;		/* We've already printed what needs to be printed.  */		bs->print_it = print_it_done;		break;	      }	  }	else	/* found == 0 */	  {	    /* This is a case where some watchpoint(s) triggered,	       but not at the address of this watchpoint (FOUND	       was left zero).  So don't print anything for this	       watchpoint.  */	    bs->print_it = print_it_noop;	    bs->stop = 0;            continue;	  }      }    else      {	/* By definition, an encountered breakpoint is a triggered	   breakpoint. */	++(b->hit_count);	real_breakpoint = 1;      }    if (frame_id_p (b->frame_id)	&& !frame_id_eq (b->frame_id, get_frame_id (get_current_frame ())))      bs->stop = 0;    else      {	int value_is_zero = 0;	if (b->cond)	  {	    /* Need to select the frame, with all that implies	       so that the conditions will have the right context.  */	    select_frame (get_current_frame ());	    value_is_zero	      = catch_errors (breakpoint_cond_eval, (b->cond),			      "Error in testing breakpoint condition:\n",			      RETURN_MASK_ALL);	    /* FIXME-someday, should give breakpoint # */	    free_all_values ();	  }	if (b->cond && value_is_zero)	  {	    bs->stop = 0;	    /* Don't consider this a hit.  */	    --(b->hit_count);	  }	else if (b->thread != -1 && b->thread != thread_id)	  {	    bs->stop = 0;	    /* Don't consider this a hit.  */	    --(b->hit_count);	  }	else if (b->ignore_count > 0)	  {	    b->ignore_count--;	    annotate_ignore_count_change ();	    bs->stop = 0;	  }	else	  {	    /* We will stop here */	    if (b->disposition == disp_disable)	      b->enable_state = bp_disabled;	    if (b->silent)	      bs->print = 0;	    bs->commands = b->commands;	    if (bs->commands &&		(strcmp ("silent", bs->commands->line) == 0		 || (xdb_commands && strcmp ("Q", bs->commands->line) == 0)))	      {		bs->commands = bs->commands->next;		bs->print = 0;	      }	    bs->commands = copy_command_lines (bs->commands);	  }      }    /* Print nothing for this entry if we dont stop or if we dont print.  */    if (bs->stop == 0 || bs->print == 0)      bs->print_it = print_it_noop;  }  bs->next = NULL;		/* Terminate the chain */  bs = root_bs->next;		/* Re-grab the head of the chain */  /* The value of a hardware watchpoint hasn't changed, but the     intermediate memory locations we are watching may have.  */  if (bs && !bs->stop &&      (bs->breakpoint_at->type == bp_hardware_watchpoint ||       bs->breakpoint_at->type == bp_read_watchpoint ||       bs->breakpoint_at->type == bp_access_watchpoint))    {      remove_breakpoints ();      insert_breakpoints ();    }  return bs;}