From patchwork Tue Nov 26 17:11:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 36230 Received: (qmail 97250 invoked by alias); 26 Nov 2019 17:12:20 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 96044 invoked by uid 89); 26 Nov 2019 17:12:11 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 26 Nov 2019 17:12:08 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 14BE320A87; Tue, 26 Nov 2019 12:12:04 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id F360221086 for ; Tue, 26 Nov 2019 12:11:33 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id E7B4828175 for ; Tue, 26 Nov 2019 12:11:33 -0500 (EST) X-Gerrit-PatchSet: 1 Date: Tue, 26 Nov 2019 12:11:33 -0500 From: "Tom Tromey (Code Review)" To: gdb-patches@sourceware.org Message-ID: Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] Add pending stop support to gdbserver's Windows port X-Gerrit-Change-Id: I8d2d24a55dc081887deebdd952dd6512ae23fa71 X-Gerrit-Change-Number: 724 X-Gerrit-ChangeURL: X-Gerrit-Commit: 7b7e28d75c1427101cd96232e1d992e0431dd574 References: Reply-To: tromey@sourceware.org, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/724 ...................................................................... Add pending stop support to gdbserver's Windows port This changes gdbserver to also handle pending stops, the same way that gdb does. This is PR gdb/22992. 2019-11-26 Tom Tromey PR gdb/22992 * win32-low.c (child_continue): Call matching_pending_stop. (get_child_debug_event): Call fetch_pending_stop. Push pending stop when needed. Change-Id: I8d2d24a55dc081887deebdd952dd6512ae23fa71 --- M gdb/gdbserver/ChangeLog M gdb/gdbserver/win32-low.c 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 9008bdc..a076a40 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,5 +1,12 @@ 2019-11-26 Tom Tromey + PR gdb/22992 + * win32-low.c (child_continue): Call matching_pending_stop. + (get_child_debug_event): Call fetch_pending_stop. Push pending + stop when needed. + +2019-11-26 Tom Tromey + * win32-low.c (win32_supports_z_point_type): Always handle Z_PACKET_SW_BP. (win32_insert_point): Call insert_memory_breakpoint when needed. diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c index c472e0e..f85fa23 100644 --- a/gdb/gdbserver/win32-low.c +++ b/gdb/gdbserver/win32-low.c @@ -430,6 +430,10 @@ static BOOL child_continue (DWORD continue_status, int thread_id) { + desired_stop_thread_id = thread_id; + if (matching_pending_stop (debug_threads)) + return TRUE; + /* The inferior will only continue after the ContinueDebugEvent call. */ for_each_thread ([&] (thread_info *thread) @@ -1261,6 +1265,16 @@ else #endif { + gdb::optional stop = fetch_pending_stop (debug_threads); + if (stop.has_value ()) + { + *ourstatus = stop->status; + current_event = stop->event; + ptid = debug_event_ptid (¤t_event); + current_thread = find_thread_ptid (ptid); + return 1; + } + /* Keep the wait time low enough for comfortable remote interruption, but high enough so gdbserver doesn't become a bottleneck. */ @@ -1348,7 +1362,7 @@ (unsigned) current_event.dwThreadId)); ourstatus->kind = TARGET_WAITKIND_EXITED; ourstatus->value.integer = current_event.u.ExitProcess.dwExitCode; - child_continue (DBG_CONTINUE, -1); + child_continue (DBG_CONTINUE, desired_stop_thread_id); CloseHandle (current_process_handle); current_process_handle = NULL; break; @@ -1408,7 +1422,21 @@ } ptid = debug_event_ptid (¤t_event); - current_thread = find_thread_ptid (ptid); + + if (desired_stop_thread_id != -1 && desired_stop_thread_id != ptid.lwp ()) + { + /* Pending stop. See the comment by the definition of + "pending_stops" for details on why this is needed. */ + OUTMSG2 (("get_windows_debug_event - " + "unexpected stop in 0x%x (expecting 0x%x)\n", + ptid.lwp (), desired_stop_thread_id)); + maybe_adjust_pc (); + pending_stops.push_back ({(DWORD) ptid.lwp (), *ourstatus, current_event}); + ourstatus->kind = TARGET_WAITKIND_SPURIOUS; + } + else + current_thread = find_thread_ptid (ptid); + return 1; } @@ -1455,7 +1483,7 @@ /* fall-through */ case TARGET_WAITKIND_SPURIOUS: /* do nothing, just continue */ - child_continue (continue_status, -1); + child_continue (continue_status, desired_stop_thread_id); break; } }