diff options
author | Pedro Alves <palves@redhat.com> | 2012-03-02 16:23:42 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2012-03-02 16:23:42 +0000 |
commit | 05044653678510ef24f2a66773ba2e8f40e12b48 (patch) | |
tree | 2ca5e6c1ae24689e6ecf583c1591352bf1124fa6 /gdb | |
parent | b261e0c5364661b66d55f4e77e95e7d09af8b9aa (diff) | |
download | gdb-05044653678510ef24f2a66773ba2e8f40e12b48.zip gdb-05044653678510ef24f2a66773ba2e8f40e12b48.tar.gz gdb-05044653678510ef24f2a66773ba2e8f40e12b48.tar.bz2 |
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.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/gdbserver/ChangeLog | 10 | ||||
-rw-r--r-- | gdb/gdbserver/inferiors.c | 29 | ||||
-rw-r--r-- | gdb/gdbserver/linux-low.c | 57 | ||||
-rw-r--r-- | gdb/gdbserver/server.h | 2 |
4 files changed, 60 insertions, 38 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 2b9558b..c1baa9f 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -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> * tracepoint.c (do_action_at_tracepoint): Write `stop_pc' in diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c index ba5cb10..2b9169a 100644 --- a/gdb/gdbserver/inferiors.c +++ b/gdb/gdbserver/inferiors.c @@ -239,35 +239,6 @@ clear_inferiors (void) 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) { diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index bc14ec3..7638ca3 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -92,11 +92,54 @@ 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; @@ -353,12 +396,12 @@ handle_extended_wait (struct lwp_info *event_child, int wstat) { 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. */ @@ -1170,7 +1213,7 @@ retry: 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) diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h index 30d608c..22b3125 100644 --- a/gdb/gdbserver/server.h +++ b/gdb/gdbserver/server.h @@ -279,8 +279,6 @@ void *inferior_target_data (struct thread_info *); 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); |