gdb/gdbserver/

* linux-low.c (linux_wait_for_event_1): Rename to ...
	(linux_wait_for_event): ... here and merge it with former
	linux_wait_for_event - new variable wait_ptid, use it.
	(linux_wait_for_event): Remove - merge it to linux_wait_for_event_1.
This commit is contained in:
Jan Kratochvil 2012-01-25 18:25:13 +00:00
parent 484abf42a0
commit d8301ad1da
2 changed files with 34 additions and 44 deletions

View File

@ -1,3 +1,10 @@
2012-01-25 Jan Kratochvil <jan.kratochvil@redhat.com>
* linux-low.c (linux_wait_for_event_1): Rename to ...
(linux_wait_for_event): ... here and merge it with former
linux_wait_for_event - new variable wait_ptid, use it.
(linux_wait_for_event): Remove - merge it to linux_wait_for_event_1.
2012-01-23 Pedro Alves <palves@redhat.com>
* server.c (main): Avoid yet another case of infinite loop while

View File

@ -1569,9 +1569,10 @@ ptid_t step_over_bkpt;
the stopped child otherwise. */
static int
linux_wait_for_event_1 (ptid_t ptid, int *wstat, int options)
linux_wait_for_event (ptid_t ptid, int *wstat, int options)
{
struct lwp_info *event_child, *requested_child;
ptid_t wait_ptid;
event_child = NULL;
requested_child = NULL;
@ -1620,13 +1621,24 @@ linux_wait_for_event_1 (ptid_t ptid, int *wstat, int options)
return lwpid_of (event_child);
}
if (ptid_is_pid (ptid))
{
/* A request to wait for a specific tgid. This is not possible
with waitpid, so instead, we wait for any child, and leave
children we're not interested in right now with a pending
status to report later. */
wait_ptid = minus_one_ptid;
}
else
wait_ptid = ptid;
/* We only enter this loop if no process has a pending wait status. Thus
any action taken in response to a wait status inside this loop is
responding as soon as we detect the status, not after any pending
events. */
while (1)
{
event_child = linux_wait_for_lwp (ptid, wstat, options);
event_child = linux_wait_for_lwp (wait_ptid, wstat, options);
if ((options & WNOHANG) && event_child == NULL)
{
@ -1638,6 +1650,19 @@ linux_wait_for_event_1 (ptid_t ptid, int *wstat, int options)
if (event_child == NULL)
error ("event from unknown child");
if (ptid_is_pid (ptid)
&& ptid_get_pid (ptid) != ptid_get_pid (ptid_of (event_child)))
{
if (! WIFSTOPPED (*wstat))
mark_lwp_dead (event_child, *wstat);
else
{
event_child->status_pending_p = 1;
event_child->status_pending = *wstat;
}
continue;
}
current_inferior = get_lwp_thread (event_child);
/* Check for thread exit. */
@ -1730,48 +1755,6 @@ linux_wait_for_event_1 (ptid_t ptid, int *wstat, int options)
return 0;
}
static int
linux_wait_for_event (ptid_t ptid, int *wstat, int options)
{
ptid_t wait_ptid;
if (ptid_is_pid (ptid))
{
/* A request to wait for a specific tgid. This is not possible
with waitpid, so instead, we wait for any child, and leave
children we're not interested in right now with a pending
status to report later. */
wait_ptid = minus_one_ptid;
}
else
wait_ptid = ptid;
while (1)
{
int event_pid;
event_pid = linux_wait_for_event_1 (wait_ptid, wstat, options);
if (event_pid > 0
&& ptid_is_pid (ptid) && ptid_get_pid (ptid) != event_pid)
{
struct lwp_info *event_child
= find_lwp_pid (pid_to_ptid (event_pid));
if (! WIFSTOPPED (*wstat))
mark_lwp_dead (event_child, *wstat);
else
{
event_child->status_pending_p = 1;
event_child->status_pending = *wstat;
}
}
else
return event_pid;
}
}
/* Count the LWP's that have had events. */
static int