aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2012-01-25 18:25:13 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2012-01-25 18:25:13 +0000
commitd8301ad1da7805ae1f9cb9806d49077ed76287d4 (patch)
treec160452850783f5e9633bff20a77fed0195d3a4f /gdb/gdbserver
parent484abf42a0ca7532ceff0cfe9f9ada88e1a199b6 (diff)
downloadgdb-d8301ad1da7805ae1f9cb9806d49077ed76287d4.zip
gdb-d8301ad1da7805ae1f9cb9806d49077ed76287d4.tar.gz
gdb-d8301ad1da7805ae1f9cb9806d49077ed76287d4.tar.bz2
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.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r--gdb/gdbserver/ChangeLog7
-rw-r--r--gdb/gdbserver/linux-low.c71
2 files changed, 34 insertions, 44 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 57ac46d..83af7f8 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -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
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 6535180..45aeb73 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -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