From patchwork Fri Oct 16 16:36:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 9191 Received: (qmail 67080 invoked by alias); 16 Oct 2015 16:37:05 -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 67050 invoked by uid 89); 16 Oct 2015 16:37:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 16 Oct 2015 16:37:02 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id ABADF91E8D; Fri, 16 Oct 2015 16:37:01 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9GGaxbj020480; Fri, 16 Oct 2015 12:37:00 -0400 Message-ID: <562127AB.4050303@redhat.com> Date: Fri, 16 Oct 2015 17:36:59 +0100 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Joel Brobecker CC: gdb-patches@sourceware.org Subject: Re: [PATCH 1/7] Merge async and sync code paths some more References: <1439398917-22761-1-git-send-email-palves@redhat.com> <1439398917-22761-2-git-send-email-palves@redhat.com> <20151016003525.GB1806@adacore.com> <5620D9D1.8080205@redhat.com> <20151016162250.GH3341@adacore.com> In-Reply-To: <20151016162250.GH3341@adacore.com> On 10/16/2015 05:22 PM, Joel Brobecker wrote: >> I'm trying to build a Windows gdb to see this in >> action. Many thanks for the detailed analysis! > > Thanks Pedro. Let me know if I can help, I don't mind doing the > leg-work! It's just that I needed a bit of guidance because I don't > have the whole picture on how the mainloop is supposed to work, > particulary with the async-vs-non-async, all-stop-vs-non-stop, > etc. > I had forgotten how building on Cygwin takes ages! :-P So my main gripe with the patch is this: @@ -2821,6 +2821,15 @@ attach_command (char *args, int from_tty) mark_infrun_async_event_handler (); return; } + else + { + /* We don't expect any additional attach event from the target. + So make sure that the infrun_async_event_handler is disabled. + Otherwise, the main event loop might believe that we have + inferior events ready, causing us to wait for those event + that will never come, since our inferior is now stopped. */ + infrun_async (0); + } If debugging more than one inferior (granted, Windows doesn't support this, but, alas), this prevents gdb from reacting to pending events for threads of the other inferior. How about we make do_initial_windows_stuff call windows_wait/windows_resume directly, like we did for gdbserver here: https://sourceware.org/ml/gdb-patches/2013-12/msg00371.html As mentioned in that thread, I've wanted to do this before in order to get rid of stop_after_trap. The patch below seems to work for me. Thanks, Pedro Alves From b77696d634a1ff7e41fe75af24c9d6efcc7c46d2 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 16 Oct 2015 16:12:45 +0100 Subject: [PATCH] no wfi --- gdb/windows-nat.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 4ab74b4..e6c396b 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1642,7 +1642,6 @@ windows_add_all_dlls (void) static void do_initial_windows_stuff (struct target_ops *ops, DWORD pid, int attaching) { - extern int stop_after_trap; int i; struct inferior *inf; struct thread_info *tp; @@ -1681,16 +1680,20 @@ do_initial_windows_stuff (struct target_ops *ops, DWORD pid, int attaching) target_terminal_inferior (); windows_initialization_done = 0; - inf->control.stop_soon = STOP_QUIETLY; + while (1) { - stop_after_trap = 1; - wait_for_inferior (); - tp = inferior_thread (); - if (tp->suspend.stop_signal != GDB_SIGNAL_TRAP) - resume (tp->suspend.stop_signal); - else + struct target_waitstatus status; + + windows_wait (ops, minus_one_ptid, &status, 0); + + /* Note windows_wait returns TARGET_WAITKIND_SPURIOUS for thread + events. */ + if (status.kind != TARGET_WAITKIND_LOADED + && status.kind != TARGET_WAITKIND_SPURIOUS) break; + + windows_resume (ops, minus_one_ptid, 0, GDB_SIGNAL_0); } /* Now that the inferior has been started and all DLLs have been mapped, @@ -1711,8 +1714,6 @@ do_initial_windows_stuff (struct target_ops *ops, DWORD pid, int attaching) windows_add_all_dlls (); windows_initialization_done = 1; - inf->control.stop_soon = NO_STOP_QUIETLY; - stop_after_trap = 0; return; } -- 1.9.3