This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] Cleanups re: step_resume_breakpoints


Originally there was only ever one step_resume_breakpoint.
Now there is potentially one per thread.  These clean-ups
just help keep the thread_list internally consistent
(delete copies of the step_resume_breakpoint), and also
insure that we delete only the step_resume_breakpoint that
pertains to the current thread.
2001-06-01  Michael Snyder  <msnyder@redhat.com>

	* thread.c (delete_step_resume_breakpoint): New function.
	Maintain internal consistency of the thread list while deleting
	a step_resume_breakpoint.
	* gdbthread.h (delete_step_resume_breakpoint): Export.
	* breakpoint.c (bpstat_find_step_resume_breakpoint):
	Make thread-aware: don't return a step_resume_breakpoint 
	for the wrong thread.
	* infrun.c (wait_for_inferior): Call delete_step_resume_breakpoint
	instead of delete_breakpoint_current_contents.
	(fetch_inferior_event): Ditto.
	(handle_inferior_event): Call delete_step_resume_breakpoint
	instead of delete_breakpoint.

Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.34
diff -c -3 -p -r1.34 infrun.c
*** infrun.c	2001/06/01 23:23:19	1.34
--- infrun.c	2001/06/02 00:19:43
*************** wait_for_inferior (void)
*** 1277,1283 ****
    struct execution_control_state ecss;
    struct execution_control_state *ecs;
  
!   old_cleanups = make_cleanup (delete_breakpoint_current_contents,
  			       &step_resume_breakpoint);
    make_cleanup (delete_breakpoint_current_contents,
  		&through_sigtramp_breakpoint);
--- 1277,1283 ----
    struct execution_control_state ecss;
    struct execution_control_state *ecs;
  
!   old_cleanups = make_cleanup (delete_step_resume_breakpoint,
  			       &step_resume_breakpoint);
    make_cleanup (delete_breakpoint_current_contents,
  		&through_sigtramp_breakpoint);
*************** fetch_inferior_event (void *client_data)
*** 1341,1347 ****
  
    if (!async_ecs->wait_some_more)
      {
!       old_cleanups = make_exec_cleanup (delete_breakpoint_current_contents,
  					&step_resume_breakpoint);
        make_exec_cleanup (delete_breakpoint_current_contents,
  			 &through_sigtramp_breakpoint);
--- 1341,1347 ----
  
    if (!async_ecs->wait_some_more)
      {
!       old_cleanups = make_exec_cleanup (delete_step_resume_breakpoint, 
  					&step_resume_breakpoint);
        make_exec_cleanup (delete_breakpoint_current_contents,
  			 &through_sigtramp_breakpoint);
*************** handle_inferior_event (struct execution_
*** 2362,2369 ****
  	     interferes with us */
  	  if (step_resume_breakpoint != NULL)
  	    {
! 	      delete_breakpoint (step_resume_breakpoint);
! 	      step_resume_breakpoint = NULL;
  	    }
  	  /* Not sure whether we need to blow this away too, but probably
  	     it is like the step-resume breakpoint.  */
--- 2362,2368 ----
  	     interferes with us */
  	  if (step_resume_breakpoint != NULL)
  	    {
! 	      delete_step_resume_breakpoint (&step_resume_breakpoint);
  	    }
  	  /* Not sure whether we need to blow this away too, but probably
  	     it is like the step-resume breakpoint.  */
*************** handle_inferior_event (struct execution_
*** 2461,2468 ****
  	      step_resume_breakpoint =
  		bpstat_find_step_resume_breakpoint (stop_bpstat);
  	    }
! 	  delete_breakpoint (step_resume_breakpoint);
! 	  step_resume_breakpoint = NULL;
  	  break;
  
  	case BPSTAT_WHAT_THROUGH_SIGTRAMP:
--- 2460,2466 ----
  	      step_resume_breakpoint =
  		bpstat_find_step_resume_breakpoint (stop_bpstat);
  	    }
! 	  delete_step_resume_breakpoint (&step_resume_breakpoint);
  	  break;
  
  	case BPSTAT_WHAT_THROUGH_SIGTRAMP:
Index: thread.c
===================================================================
RCS file: /cvs/src/src/gdb/thread.c,v
retrieving revision 1.15
diff -c -3 -p -r1.15 thread.c
*** thread.c	2001/05/12 05:04:01	1.15
--- thread.c	2001/06/02 00:19:43
*************** static void restore_current_thread (ptid
*** 65,70 ****
--- 65,87 ----
  static void switch_to_thread (ptid_t ptid);
  static void prune_threads (void);
  
+ void
+ delete_step_resume_breakpoint (void *arg)
+ {
+   struct breakpoint **breakpointp = (struct breakpoint **) arg;
+   struct thread_info *tp;
+ 
+   if (*breakpointp != NULL)
+     {
+       delete_breakpoint (*breakpointp);
+       for (tp = thread_list; tp; tp = tp->next)
+ 	if (tp->step_resume_breakpoint == *breakpointp)
+ 	  tp->step_resume_breakpoint = NULL;
+ 
+       *breakpointp = NULL;
+     }
+ }
+ 
  static void
  free_thread (struct thread_info *tp)
  {
Index: gdbthread.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbthread.h,v
retrieving revision 1.3
diff -c -3 -p -r1.3 gdbthread.h
*** gdbthread.h	2001/05/04 04:15:24	1.3
--- gdbthread.h	2001/06/02 00:19:43
*************** extern struct thread_info *add_thread (p
*** 78,83 ****
--- 78,86 ----
  /* Delete an existing thread list entry.  */
  extern void delete_thread (ptid_t);
  
+ /* Delete a step_resume_breakpoint from the thread database. */
+ extern void delete_step_resume_breakpoint (void *);
+ 
  /* Translate the integer thread id (GDB's homegrown id, not the system's)
     into a "pid" (which may be overloaded with extra thread information).  */
  extern ptid_t thread_id_to_pid (int);
Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.38
diff -c -3 -p -r1.38 breakpoint.c
*** breakpoint.c	2001/05/23 00:52:44	1.38
--- breakpoint.c	2001/06/02 00:19:44
*************** bpstat_find_breakpoint (bpstat bsp, stru
*** 1719,1731 ****
  struct breakpoint *
  bpstat_find_step_resume_breakpoint (bpstat bsp)
  {
    if (bsp == NULL)
      error ("Internal error (bpstat_find_step_resume_breakpoint)");
  
    for (; bsp != NULL; bsp = bsp->next)
      {
        if ((bsp->breakpoint_at != NULL) &&
! 	  (bsp->breakpoint_at->type == bp_step_resume))
  	return bsp->breakpoint_at;
      }
  
--- 1719,1737 ----
  struct breakpoint *
  bpstat_find_step_resume_breakpoint (bpstat bsp)
  {
+   int current_thread;
+ 
    if (bsp == NULL)
      error ("Internal error (bpstat_find_step_resume_breakpoint)");
  
+   current_thread = pid_to_thread_id (inferior_ptid);
+ 
    for (; bsp != NULL; bsp = bsp->next)
      {
        if ((bsp->breakpoint_at != NULL) &&
! 	  (bsp->breakpoint_at->type == bp_step_resume) &&
! 	  (bsp->breakpoint_at->thread == current_thread || 
! 	   bsp->breakpoint_at->thread == -1))
  	return bsp->breakpoint_at;
      }
  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]