[RFC] 06/10 Don't rely on ecs->wait_for_more before fetching the event

Pedro Alves pedro@codesourcery.com
Tue May 6 15:50:00 GMT 2008


The main juice of this patch is avoiding this relying on ecs->wait_some_more
before fetching the event from the target, which invalidates the
wrong context when the user switches the current thread, to a thread
that was not the last that had an event.

void
fetch_inferior_event (void *client_data)
{
  struct execution_control_state *ecs = &ecss;

  if (!ecs->wait_some_more)
    {
      /* Fill in with reasonable starting values.  */
      init_execution_control_state (ecs);

      /* We'll update this if & when we switch to a new thread. */
      previous_inferior_ptid = inferior_ptid;

      overlay_cache_invalid = 1;

      /* We have to invalidate the registers BEFORE calling target_wait
         because they can be loaded from the target while in target_wait.
         This makes remote debugging a bit more efficient for those
         targets that provide critical registers as part of their normal
         status mechanism. */

      registers_changed ();
    }

  if (deprecated_target_wait_hook)
    ecs->ptid =
      deprecated_target_wait_hook (ecs->waiton_ptid, ecs->wp);
  else
    ecs->ptid = target_wait (ecs->waiton_ptid, ecs->wp);

  /* Now figure out what to do with the result of the result.  */
  handle_inferior_event (ecs);


execution_control_state is a mess to look at, because it
contains variables that are context-switches, variables
that only serve to pass data around while handling one event,
but are meaningless between events, but some which are no longer
used at all.

So, the patch while fixing the above issue, splits execution
control state in 3.

/* Context-switchable data.  */
struct thread_stepping_state
{
  /* Should we step over breakpoint next time keep_going
     is called?  */
  int stepping_over_breakpoint;
  struct symtab_and_line sal;
  int current_line;
  struct symtab *current_symtab;
  int step_after_step_resume_breakpoint;
  int stepping_through_solib_after_catch;
  bpstat stepping_through_solib_catchpoints;
};

/* Data to be passed around while handling an event.  This data is
   discarded between events.  */
struct execution_control_state
{
  ptid_t ptid;
  struct target_waitstatus ws;
  int random_signal;
  CORE_ADDR stop_func_start;
  CORE_ADDR stop_func_end;
  char *stop_func_name;
  int new_thread_event;
  int wait_some_more;
};

/* global inferior control state P/

/* The PTID we'll do a target_wait on.*/
ptid_t waiton_ptid;

/* Current inferior wait state.  */
enum infwait_states infwait_state;



-- 
Pedro Alves
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 006-dont_rely_on_wait_for_more.diff
Type: text/x-diff
Size: 27643 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20080506/61230caa/attachment.bin>


More information about the Gdb-patches mailing list