free_valchain (bpt->loc);
delete_breakpoint (struct breakpoint *bpt){  struct breakpoint *b;  bpstat bs;  struct bp_location *loc;  if (bpt == NULL)    error ("Internal error (attempted to delete a NULL breakpoint)");  /* Has this bp already been deleted?  This can happen because multiple     lists can hold pointers to bp's.  bpstat lists are especial culprits.     One example of this happening is a watchpoint's scope bp.  When the     scope bp triggers, we notice that the watchpoint is out of scope, and     delete it.  We also delete its scope bp.  But the scope bp is marked     "auto-deleting", and is already on a bpstat.  That bpstat is then     checked for auto-deleting bp's, which are deleted.     A real solution to this problem might involve reference counts in bp's,     and/or giving them pointers back to their referencing bpstat's, and     teaching delete_breakpoint to only free a bp's storage when no more     references were extent.  A cheaper bandaid was chosen. */  if (bpt->type == bp_none)    return;  if (delete_breakpoint_hook)    delete_breakpoint_hook (bpt);  breakpoint_delete_event (bpt->number);  if (bpt->loc->inserted)    remove_breakpoint (bpt->loc, mark_inserted);  if (breakpoint_chain == bpt)    breakpoint_chain = bpt->next;  if (bp_location_chain == bpt->loc)    bp_location_chain = bpt->loc->next;  /* If we have callback-style exception catchpoints, don't go through     the adjustments to the C++ runtime library etc. if the inferior     isn't actually running.  target_enable_exception_callback for a     null target ops vector gives an undesirable error message, so we     check here and avoid it. Since currently (1997-09-17) only HP-UX aCC's     exceptions are supported in this way, it's OK for now. FIXME */  if (ep_is_exception_catchpoint (bpt) && target_has_execution)    {      /* Format possible error msg */      char *message = xstrprintf ("Error in deleting catchpoint %d:\n",				  bpt->number);      struct cleanup *cleanups = make_cleanup (xfree, message);      args_for_catchpoint_enable args;      args.kind = bpt->type == bp_catch_catch ? 	EX_EVENT_CATCH : EX_EVENT_THROW;      args.enable_p = 0;      catch_errors (cover_target_enable_exception_callback, &args,		    message, RETURN_MASK_ALL);      do_cleanups (cleanups);    }  ALL_BREAKPOINTS (b)    if (b->next == bpt)    {      b->next = bpt->next;      break;    }  ALL_BP_LOCATIONS (loc)    if (loc->next == bpt->loc)      {	loc->next = bpt->loc->next;	break;      }  check_duplicates (bpt);  /* If this breakpoint was inserted, and there is another breakpoint     at the same address, we need to insert the other breakpoint.  */  if (bpt->loc->inserted      && bpt->type != bp_hardware_watchpoint      && bpt->type != bp_read_watchpoint      && bpt->type != bp_access_watchpoint      && bpt->type != bp_catch_fork      && bpt->type != bp_catch_vfork      && bpt->type != bp_catch_exec)    {      ALL_BREAKPOINTS (b)	if (b->loc->address == bpt->loc->address	    && b->loc->section == bpt->loc->section	    && !b->loc->duplicate	    && b->enable_state != bp_disabled	    && b->enable_state != bp_shlib_disabled	    && !b->pending	    && b->enable_state != bp_call_disabled)	{	  int val;	  /* We should never reach this point if there is a permanent	     breakpoint at the same address as the one being deleted.	     If there is a permanent breakpoint somewhere, it should	     always be the only one inserted.  */	  if (b->enable_state == bp_permanent)	    internal_error (__FILE__, __LINE__,			    "another breakpoint was inserted on top of "			    "a permanent breakpoint");	  if (b->type == bp_hardware_breakpoint)	    val = target_insert_hw_breakpoint (b->loc->address, b->loc->shadow_contents);	  else	    val = target_insert_breakpoint (b->loc->address, b->loc->shadow_contents);	  /* If there was an error in the insert, print a message, then stop execution.  */	  if (val != 0)	    {	      struct ui_file *tmp_error_stream = mem_fileopen ();	      make_cleanup_ui_file_delete (tmp_error_stream);	     	      if (b->type == bp_hardware_breakpoint)		{		  fprintf_unfiltered (tmp_error_stream, 					"Cannot insert hardware breakpoint %d.\n"				      "You may have requested too many hardware breakpoints.\n",					b->number);		  }		else		  {		    fprintf_unfiltered (tmp_error_stream, "Cannot insert breakpoint %d.\n", b->number);		    fprintf_filtered (tmp_error_stream, "Error accessing memory address ");		    print_address_numeric (b->loc->address, 1, tmp_error_stream);		    fprintf_filtered (tmp_error_stream, ": %s.\n",				      safe_strerror (val));		  }	      	      fprintf_unfiltered (tmp_error_stream,"The same program may be running in another process.");	      target_terminal_ours_for_output ();	      error_stream(tmp_error_stream); 	    }	  else	    b->loc->inserted = 1;	}    }  free_command_lines (&bpt->commands);  if (bpt->cond)    xfree (bpt->cond);  if (bpt->cond_string != NULL)    xfree (bpt->cond_string);  if (bpt->addr_string != NULL)    xfree (bpt->addr_string);  if (bpt->exp != NULL)    xfree (bpt->exp);  if (bpt->exp_string != NULL)    xfree (bpt->exp_string);  if (bpt->val != NULL)    value_free (bpt->val);  if (bpt->source_file != NULL)    xfree (bpt->source_file);  if (bpt->dll_pathname != NULL)    xfree (bpt->dll_pathname);  if (bpt->triggered_dll_pathname != NULL)    xfree (bpt->triggered_dll_pathname);  if (bpt->exec_pathname != NULL)    xfree (bpt->exec_pathname);  /* 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.  */  for (bs = stop_bpstat; bs; bs = bs->next)    if (bs->breakpoint_at == bpt)      {	bs->breakpoint_at = NULL;	bs->old_val = NULL;	/* bs->commands will be freed later.  */      }  /* On the chance that someone will soon try again to delete this same     bp, we mark it as deleted before freeing its storage. */  bpt->type = bp_none;  xfree (bpt->loc);  xfree (bpt);}