From 0723dbf578cc2f8ab942f4bbd36e1377adcd0620 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Wed, 24 Feb 2010 17:01:58 +0000 Subject: [PATCH] * inferior.h (ptid_match): Declare. * infrun.c (ptid_match): New. * remote.c (queued_stop_reply): Rewrite and use ptid_match. (handle_notification): Add debug output. * linux-nat.c (ptid_match): Delete. --- gdb/ChangeLog | 8 ++++++++ gdb/inferior.h | 10 ++++++++++ gdb/infrun.c | 20 ++++++++++++++++++++ gdb/linux-nat.c | 27 --------------------------- gdb/remote.c | 45 ++++++++++++++++++++++++--------------------- 5 files changed, 62 insertions(+), 48 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c10f54b..d7cf444 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2010-02-24 Pedro Alves + + * inferior.h (ptid_match): Declare. + * infrun.c (ptid_match): New. + * remote.c (queued_stop_reply): Rewrite and use ptid_match. + (handle_notification): Add debug output. + * linux-nat.c (ptid_match): Delete. + 2010-02-24 David S. Miller * gdb_ptrace.h (PT_SYSCALL): If PTRACE_SYSCALL is available, use it. diff --git a/gdb/inferior.h b/gdb/inferior.h index 4571893..bd6f1c8 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -105,6 +105,16 @@ extern int ptid_equal (ptid_t p1, ptid_t p2); /* Return true if PTID represents a process id. */ extern int ptid_is_pid (ptid_t ptid); +/* Returns true if PTID matches filter FILTER. FILTER can be the wild + card MINUS_ONE_PTID (all ptid match it); can be a ptid representing + a process (ptid_is_pid returns true), in which case, all lwps and + threads of that given process match, lwps and threads of other + processes do not; or, it can represent a specific thread, in which + case, only that thread will match true. PTID must represent a + specific LWP or THREAD, it can never be a wild card. */ + +extern int ptid_match (ptid_t ptid, ptid_t filter); + /* Save value of inferior_ptid so that it may be restored by a later call to do_cleanups(). Returns the struct cleanup pointer needed for later doing the cleanup. */ diff --git a/gdb/infrun.c b/gdb/infrun.c index 9a5c3a8..83abdeb 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -6126,6 +6126,26 @@ ptid_is_pid (ptid_t ptid) return (ptid_get_lwp (ptid) == 0 && ptid_get_tid (ptid) == 0); } +int +ptid_match (ptid_t ptid, ptid_t filter) +{ + /* Since both parameters have the same type, prevent easy mistakes + from happening. */ + gdb_assert (!ptid_equal (ptid, minus_one_ptid) + && !ptid_equal (ptid, null_ptid) + && !ptid_is_pid (ptid)); + + if (ptid_equal (filter, minus_one_ptid)) + return 1; + if (ptid_is_pid (filter) + && ptid_get_pid (ptid) == ptid_get_pid (filter)) + return 1; + else if (ptid_equal (ptid, filter)) + return 1; + + return 0; +} + /* restore_inferior_ptid() will be used by the cleanup machinery to restore the inferior_ptid value saved in a call to save_inferior_ptid(). */ diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index e55d958..6a8a437 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -1221,33 +1221,6 @@ find_lwp_pid (ptid_t ptid) return NULL; } -/* Returns true if PTID matches filter FILTER. FILTER can be the wild - card MINUS_ONE_PTID (all ptid match it); can be a ptid representing - a process (ptid_is_pid returns true), in which case, all lwps of - that give process match, lwps of other process do not; or, it can - represent a specific thread, in which case, only that thread will - match true. PTID must represent an LWP, it can never be a wild - card. */ - -static int -ptid_match (ptid_t ptid, ptid_t filter) -{ - /* Since both parameters have the same type, prevent easy mistakes - from happening. */ - gdb_assert (!ptid_equal (ptid, minus_one_ptid) - && !ptid_equal (ptid, null_ptid)); - - if (ptid_equal (filter, minus_one_ptid)) - return 1; - if (ptid_is_pid (filter) - && ptid_get_pid (ptid) == ptid_get_pid (filter)) - return 1; - else if (ptid_equal (ptid, filter)) - return 1; - - return 0; -} - /* Call CALLBACK with its second argument set to DATA for every LWP in the list. If CALLBACK returns 1 for a particular LWP, return a pointer to the structure describing that LWP immediately. diff --git a/gdb/remote.c b/gdb/remote.c index 0ed49b9..7f8ec58 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -4637,26 +4637,23 @@ do_stop_reply_xfree (void *arg) static struct stop_reply * queued_stop_reply (ptid_t ptid) { - struct stop_reply *it, *prev; - struct stop_reply head; - - head.next = stop_reply_queue; - prev = &head; - - it = head.next; - - if (!ptid_equal (ptid, minus_one_ptid)) - for (; it; prev = it, it = it->next) - if (ptid_equal (ptid, it->ptid)) - break; + struct stop_reply *it; + struct stop_reply **it_link; - if (it) + it = stop_reply_queue; + it_link = &stop_reply_queue; + while (it) { - prev->next = it->next; - it->next = NULL; - } + if (ptid_match (it->ptid, ptid)) + { + *it_link = it->next; + it->next = NULL; + break; + } - stop_reply_queue = head.next; + it_link = &it->next; + it = *it_link; + } if (stop_reply_queue) /* There's still at least an event left. */ @@ -6169,10 +6166,13 @@ handle_notification (char *buf, size_t length) if (strncmp (buf, "Stop:", 5) == 0) { if (pending_stop_reply) - /* We've already parsed the in-flight stop-reply, but the stub - for some reason thought we didn't, possibly due to timeout - on its side. Just ignore it. */ - ; + { + /* We've already parsed the in-flight stop-reply, but the + stub for some reason thought we didn't, possibly due to + timeout on its side. Just ignore it. */ + if (remote_debug) + fprintf_unfiltered (gdb_stdlog, "ignoring resent notification\n"); + } else { struct cleanup *old_chain; @@ -6190,6 +6190,9 @@ handle_notification (char *buf, size_t length) /* Notify the event loop there's a stop reply to acknowledge and that there may be more events to fetch. */ mark_async_event_handler (remote_async_get_pending_events_token); + + if (remote_debug) + fprintf_unfiltered (gdb_stdlog, "stop notification captured\n"); } } else -- 2.7.4