+2013-05-17 Joel Brobecker <brobecker@adacore.com>
+
+ * lynx-low.c (struct process_info_private): New type.
+ (lynx_add_process): New function.
+ (lynx_create_inferior, lynx_attach): Replace calls to
+ add_process by calls to lynx_add_process.
+ (lynx_resume): If PTID is null, then try using
+ current_process()->private->last_wait_event_ptid.
+ Add comments.
+ (lynx_clear_inferiors): Delete. The contents of that function
+ has been inlined in lynx_mourn;
+ (lynx_wait_1): Save the ptid in the process's private data.
+ (lynx_mourn): Free the process' private data. Replace call
+ to lynx_clear_inferiors by call to clear_inferiors.
+
2013-05-17 Yao Qi <yao@codesourcery.com>
* i386-low.c (i386_length_and_rw_bits): Move the comment to
int using_threads = 1;
+/* Per-process private data. */
+
+struct process_info_private
+{
+ /* The PTID obtained from the last wait performed on this process.
+ Initialized to null_ptid until the first wait is performed. */
+ ptid_t last_wait_event_ptid;
+};
+
/* Print a debug trace on standard output if debug_threads is set. */
static void
return result;
}
+/* Call add_process with the given parameters, and initializes
+ the process' private data. */
+
+static struct process_info *
+lynx_add_process (int pid, int attached)
+{
+ struct process_info *proc;
+
+ proc = add_process (pid, attached);
+ proc->private = xcalloc (1, sizeof (*proc->private));
+ proc->private->last_wait_event_ptid = null_ptid;
+
+ return proc;
+}
+
/* Implement the create_inferior method of the target_ops vector. */
static int
_exit (0177);
}
- add_process (pid, 0);
+ lynx_add_process (pid, 0);
/* Do not add the process thread just yet, as we do not know its tid.
We will add it later, during the wait for the STOP event corresponding
to the lynx_ptrace (PTRACE_TRACEME) call above. */
error ("Cannot attach to process %lu: %s (%d)\n", pid,
strerror (errno), errno);
- add_process (pid, 1);
+ lynx_add_process (pid, 1);
add_thread (ptid, NULL);
return 0;
? PTRACE_SINGLESTEP : PTRACE_CONT);
const int signal = resume_info[0].sig;
+ /* If given a null_ptid, then try using the current_process'
+ private->last_wait_event_ptid. On most LynxOS versions,
+ using any of the process' thread works well enough, but
+ LynxOS 178 is a little more sensitive, and triggers some
+ unexpected signals (Eg SIG61) when we resume the inferior
+ using a different thread. */
+ if (ptid_equal (ptid, minus_one_ptid))
+ ptid = current_process()->private->last_wait_event_ptid;
+
+ /* The ptid might still be NULL; this can happen between the moment
+ we create the inferior or attach to a process, and the moment
+ we resume its execution for the first time. It is fine to
+ use the current_inferior's ptid in those cases. */
if (ptid_equal (ptid, minus_one_ptid))
ptid = thread_to_gdb_id (current_inferior);
lynx_resume (&resume_info, 1);
}
-/* Remove all inferiors and associated threads. */
-
-static void
-lynx_clear_inferiors (void)
-{
- /* We do not use private data, so nothing much to do except calling
- clear_inferiors. */
- clear_inferiors ();
-}
-
/* A wrapper around waitpid that handles the various idiosyncrasies
of LynxOS' waitpid. */
ret = lynx_waitpid (pid, &wstat);
new_ptid = lynx_ptid_build (ret, ((union wait *) &wstat)->w_tid);
+ find_process_pid (ret)->private->last_wait_event_ptid = new_ptid;
/* If this is a new thread, then add it now. The reason why we do
this here instead of when handling new-thread events is because
static void
lynx_mourn (struct process_info *proc)
{
- lynx_clear_inferiors ();
+ /* Free our private data. */
+ free (proc->private);
+ proc->private = NULL;
+
+ clear_inferiors ();
}
/* Implement the join target_ops method. */