David Smith dsmith@redhat.com
Thu Mar 29 18:25:00 GMT 2001

This patch multi-arch's the PREPARE_TO_PROCEED macro.  PREPARE_TO_PROCEED 
gets called in proceed() (infrun.c:1028).  Here's where it gets called (which 
also explains its use):

   /* In a multi-threaded task we may select another thread
      and then continue or step.

      But if the old thread was stopped at a breakpoint, it
      will immediately cause another breakpoint stop without
      any execution (i.e. it will report a breakpoint hit
      incorrectly).  So we must step over it first.

      PREPARE_TO_PROCEED checks the current thread against the thread
      that reported the most recent event.  If a step-over is required
      it returns TRUE and sets the current thread to the old thread. */
   if (PREPARE_TO_PROCEED (1) && breakpoint_here_p (read_pc ()))
       oneproc = 1;
       thread_step_needed = 1;


The real problem with this change is that to know whether or not the user has 
switched threads since the breakpoint was hit, we have to cache the return 
values of target_wait()/target_wait_hook().  So, I modified 
handle_inferior_event() to cache the needed information (and I added a 
function to returned the cached information).  The existing implementations 
(hppa-tdep.c, lin-lwp.c, linux-thread.c, m3-nat.c) cheat a bit by defining 
their own wait functions.

Here's the ChangeLog entry:

2001-03-29  David Smith  <dsmith@redhat.com>

	* arch-utils.c (default_prepare_to_proceed)
	(generic_prepare_to_proceed): Added new functions.
	* arch-utils.h: New function declarations for
	default_prepare_to_proceed() and generic_prepare_to_proceed().
	* gdbarch.sh: Added PREPARE_TO_PROCEED.
	* gdbarch.c: Regenerated.
	* gdbarch.h: Regenerated.
	* inferior.h: Added get_last_target_status() declaration.
	* infrun.c (get_last_target_status): Added new function.
	(handle_inferior_event): Saves last pid and waitstatus, which will
	get returned by get_last_target_status().
David Smith
Red Hat, Inc.
256.704.9222 (direct)
256.837.3839 (fax)

More information about the Gdb-patches mailing list