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.
This commit is contained in:
Pedro Alves 2012-03-02 16:23:42 +00:00
parent b261e0c536
commit 0504465367
4 changed files with 60 additions and 38 deletions

View File

@ -1,3 +1,13 @@
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> 2012-03-02 Yao Qi <yao@codesourcery.com>
* tracepoint.c (do_action_at_tracepoint): Write `stop_pc' in * tracepoint.c (do_action_at_tracepoint): Write `stop_pc' in

View File

@ -239,35 +239,6 @@ clear_inferiors (void)
current_inferior = NULL; 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 * struct process_info *
add_process (int pid, int attached) add_process (int pid, int attached)
{ {

View File

@ -92,11 +92,54 @@
struct inferior_list all_lwps; struct inferior_list all_lwps;
/* A list of all unknown processes which receive stop signals. Some other /* A list of all unknown processes which receive stop signals. Some
process will presumably claim each of these as forked children other process will presumably claim each of these as forked
momentarily. */ 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. */ /* FIXME this is a bit of a hack, and could be removed. */
int stopping_threads; int stopping_threads;
@ -353,12 +396,12 @@ handle_extended_wait (struct lwp_info *event_child, int wstat)
{ {
ptid_t ptid; ptid_t ptid;
unsigned long new_pid; unsigned long new_pid;
int ret, status = W_STOPCODE (SIGSTOP); int ret, status;
ptrace (PTRACE_GETEVENTMSG, lwpid_of (event_child), 0, &new_pid); 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 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 /* The new child has a pending SIGSTOP. We can't affect it until it
hits the SIGSTOP, but we're already attached. */ hits the SIGSTOP, but we're already attached. */
@ -1170,7 +1213,7 @@ retry:
was reported to us by the kernel. Save its PID. */ was reported to us by the kernel. Save its PID. */
if (child == NULL && WIFSTOPPED (*wstatp)) if (child == NULL && WIFSTOPPED (*wstatp))
{ {
add_pid_to_list (&stopped_pids, ret); add_to_pid_list (&stopped_pids, ret, *wstatp);
goto retry; goto retry;
} }
else if (child == NULL) else if (child == NULL)

View File

@ -279,8 +279,6 @@ void *inferior_target_data (struct thread_info *);
void set_inferior_target_data (struct thread_info *, void *); void set_inferior_target_data (struct thread_info *, void *);
void *inferior_regcache_data (struct thread_info *); void *inferior_regcache_data (struct thread_info *);
void set_inferior_regcache_data (struct thread_info *, void *); 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 loaded_dll (const char *name, CORE_ADDR base_addr);
void unloaded_dll (const char *name, CORE_ADDR base_addr); void unloaded_dll (const char *name, CORE_ADDR base_addr);