+2012-03-02 Pedro Alves <palves@redhat.com>
+
+ * inferiors.c (add_pid_to_list, pull_pid_from_list): Delete.
+ * linux-low.c (struct simple_pid_list): New.
+ (stopped_pids): New a struct simple_pid_list pointer.
+ (add_to_pid_list, pull_pid_from_list): New.
+ (handle_extended_wait): Don't assume the first signal new children
+ report is SIGSTOP. Adjust call to pull_pid_from_list.
+ (linux_wait_for_lwp): Adjust.
+
2012-03-02 Yao Qi <yao@codesourcery.com>
* tracepoint.c (do_action_at_tracepoint): Write `stop_pc' in
current_inferior = NULL;
}
-/* Two utility functions for a truly degenerate inferior_list: a simple
- PID listing. */
-
-void
-add_pid_to_list (struct inferior_list *list, unsigned long pid)
-{
- struct inferior_list_entry *new_entry;
-
- new_entry = xmalloc (sizeof (struct inferior_list_entry));
- new_entry->id = pid_to_ptid (pid);
- add_inferior_to_list (list, new_entry);
-}
-
-int
-pull_pid_from_list (struct inferior_list *list, unsigned long pid)
-{
- struct inferior_list_entry *new_entry;
-
- new_entry = find_inferior_id (list, pid_to_ptid (pid));
- if (new_entry == NULL)
- return 0;
- else
- {
- remove_inferior (list, new_entry);
- free (new_entry);
- return 1;
- }
-}
-
struct process_info *
add_process (int pid, int attached)
{
struct inferior_list all_lwps;
-/* A list of all unknown processes which receive stop signals. Some other
- process will presumably claim each of these as forked children
- momentarily. */
+/* A list of all unknown processes which receive stop signals. Some
+ other process will presumably claim each of these as forked
+ children momentarily. */
-struct inferior_list stopped_pids;
+struct simple_pid_list
+{
+ /* The process ID. */
+ int pid;
+
+ /* The status as reported by waitpid. */
+ int status;
+
+ /* Next in chain. */
+ struct simple_pid_list *next;
+};
+struct simple_pid_list *stopped_pids;
+
+/* Trivial list manipulation functions to keep track of a list of new
+ stopped processes. */
+
+static void
+add_to_pid_list (struct simple_pid_list **listp, int pid, int status)
+{
+ struct simple_pid_list *new_pid = xmalloc (sizeof (struct simple_pid_list));
+
+ new_pid->pid = pid;
+ new_pid->status = status;
+ new_pid->next = *listp;
+ *listp = new_pid;
+}
+
+static int
+pull_pid_from_list (struct simple_pid_list **listp, int pid, int *statusp)
+{
+ struct simple_pid_list **p;
+
+ for (p = listp; *p != NULL; p = &(*p)->next)
+ if ((*p)->pid == pid)
+ {
+ struct simple_pid_list *next = (*p)->next;
+
+ *statusp = (*p)->status;
+ xfree (*p);
+ *p = next;
+ return 1;
+ }
+ return 0;
+}
/* FIXME this is a bit of a hack, and could be removed. */
int stopping_threads;
{
ptid_t ptid;
unsigned long new_pid;
- int ret, status = W_STOPCODE (SIGSTOP);
+ int ret, status;
ptrace (PTRACE_GETEVENTMSG, lwpid_of (event_child), 0, &new_pid);
/* If we haven't already seen the new PID stop, wait for it now. */
- if (! pull_pid_from_list (&stopped_pids, new_pid))
+ if (!pull_pid_from_list (&stopped_pids, new_pid, &status))
{
/* The new child has a pending SIGSTOP. We can't affect it until it
hits the SIGSTOP, but we're already attached. */
was reported to us by the kernel. Save its PID. */
if (child == NULL && WIFSTOPPED (*wstatp))
{
- add_pid_to_list (&stopped_pids, ret);
+ add_to_pid_list (&stopped_pids, ret, *wstatp);
goto retry;
}
else if (child == NULL)
void set_inferior_target_data (struct thread_info *, void *);
void *inferior_regcache_data (struct thread_info *);
void set_inferior_regcache_data (struct thread_info *, void *);
-void add_pid_to_list (struct inferior_list *list, unsigned long pid);
-int pull_pid_from_list (struct inferior_list *list, unsigned long pid);
void loaded_dll (const char *name, CORE_ADDR base_addr);
void unloaded_dll (const char *name, CORE_ADDR base_addr);