From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id EE501385B53F for ; Thu, 1 Dec 2022 17:30:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EE501385B53F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-ej1-x62a.google.com with SMTP id n20so5951321ejh.0 for ; Thu, 01 Dec 2022 09:30:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=j1vN+oVwh//RMJnVeCWtVZv1le7VcJMqoLZbPsG3B+4=; b=c8AYkr/o+WoFnSO89zTtlfZNkqsA2jZHWUF6FPLYy5NfqR2qRUqtZ6Yd9NN7NS/uOa Uie9s/PDHmBUBE1k1F+L/GkqFpE7fqEcFyIMgSo/HUpxINimuxJ/53fP7g8euw9qbRc1 53dglVxRUzkuUYWGVbrSgVNCXY/AaZ3VykGrCADpG7qX1szwT8/6uIaKlVWM2squZHtj M/VVGU+AtJx92G97v3FqXdx5J4eUojpirZgYvefiY7mdjMkQeI0dkotsZB1E9ZXAlWMU WBvRqk30AhnGf/qqRUobmA9nRgbHfptrVwiIcblPC0BkyYa+7R4OAWjR7BpmRSfcK0mT +B6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=j1vN+oVwh//RMJnVeCWtVZv1le7VcJMqoLZbPsG3B+4=; b=yFOI7iZGsoOZ5ahIa/hJXOANfv3vwKKCg9vEeyljR5NABXI/e60HtrDuCTWgQ5yeB9 p7O4I28odwxICNXOuhhyyWflfizhNrR9lGx1HxnpOix1Z6QqNxLbNvnQXDftenFiNmQt PhpVQTJaNdt/FiDDp2EcJmR0rtff7LG1VdPHW9qD+3aoGpq0s1bBt83OtgSImJc2vy6b 6jz5JloY+gvxHS+T9KoxunmQ1YwKueTv+Y4c8GwEey4GADpRdZIlbc/8lUxciVPyeABV vc1jKE0e5sSRUsOVCRW0T2dYvHzzzSj3flaHC+4yAffWponDzDmRbw3BkvHaakbp/o3W FtbA== X-Gm-Message-State: ANoB5pln1hFdRdQuwZWNg2DTVUlalGDsiJPvpL4w52bEyFkzDiBHeUs4 0Ajcovq7bcEAa8BfdhzeH6zA7g== X-Google-Smtp-Source: AA0mqf5UeTOWPSS6RSD6iG1OFiewy7DvD/cQjo2dSiVdh+Pm1tR/TjqdlO1+4aG9F67RNe/GIuj5ww== X-Received: by 2002:a17:906:2804:b0:78d:e7c0:a2b with SMTP id r4-20020a170906280400b0078de7c00a2bmr58009096ejc.273.1669915832792; Thu, 01 Dec 2022 09:30:32 -0800 (PST) Received: from murgatroyd ([2620:20:4000:100::1000]) by smtp.gmail.com with ESMTPSA id o12-20020aa7c50c000000b00468f7bb4895sm1964888edq.43.2022.12.01.09.30.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 09:30:32 -0800 (PST) From: Tom Tromey To: Hannes Domani via Gdb-patches Cc: Hannes Domani Subject: Re: [PATCH] [RFC] Move SetConsoleCtrlHandler calls to async thread References: <20221128191526.1426-1-ssbssa.ref@yahoo.de> <20221128191526.1426-1-ssbssa@yahoo.de> X-Attribution: Tom Date: Thu, 01 Dec 2022 10:30:29 -0700 In-Reply-To: <20221128191526.1426-1-ssbssa@yahoo.de> (Hannes Domani via Gdb-patches's message of "Mon, 28 Nov 2022 20:15:26 +0100") Message-ID: <87edtjm3pm.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: >>>>> "Hannes" == Hannes Domani via Gdb-patches writes: Hannes> Ctrl-C and Ctrl-Break don't work any more since the async commit, so I've tried Hannes> to move the SetConsoleCtrlHandler calls. Hannes> Now Ctrl-C seems to work, but Ctrl-Break completely stop both gdb and the Hannes> inferior (if new-console is disabled). Hannes> I'm not sure what's the proper fix is here, please advise. In my normal environment (ssh to a Windows machine), none of this has ever worked at all. I don't know why, something to do with ssh and/or cygwin. Anyway, I managed to test C-c by using remmina (RDP client) and then running gdb in the console provided there. I used conemu which I gather opened some kind of Cygwin shell. According to winver this machine is "Windows Server 2016". I tried a few versions: 1. AdaCore internal gdb from before the target async patches. (AdaCore has some local changes, but nothing relevant to this problem.) 2. AdaCore gdb corresponding to git master, plus your other recent windows-nat patches. 3. #2 plus your C-c patch. When I use "run" in gdb, control-c and control-break worked fine with 1 and 2. (FWIW I used the on-screen keyboard to send control-break, I don't know any other way to do it.) When I use "attach", neither 1 nor 2 work at all -- but your patch does, but only for C-c. C-break just makes gdb exit. Now, TBH, I find all of this surprising, because on seeing your patch, I agree that the target async work should cause a problem here. And, I don't understand why your patch fixes the "attach" behavior. With your patch installed, C-c still works, but C-break does not. I don't understand why this happens. My understanding is that SetConsoleCtrlHandler intercepts C-break as well, and the body of that callback hasn't changed. One other thing I don't understand is that C-c doesn't cause gdb to exit when it is waiting at the prompt. Instead I get this quit message: throw_quit ("Quit (expect signal SIGINT when the program is resumed)"); Like, if this happens, do we really need ctrl_c_handler for the C-c case at all? (Maybe we do need the handler because windows-nat doesn't use set_sigint_trap.) And should gdb default to handling ctrl-break as well? Like, I wonder if there's a race between something like the call to signal in child_terminal_inferior and installing the C-c handler. The comment in windows-nat says: [...] There are two possible situations: - The debugger and the program do not share the console, in which case the Ctrl-c event only reached the debugger. In that case, the ctrl_c handler will take care of interrupting the inferior. Note that this case is working starting with Windows XP. For Windows 2000, Ctrl-C should be pressed in the inferior console. Maybe the 'attach' issue is a known problem? Anyway. I've learned that there's a lot in this area I don't understand. I think the first thing to do is understand why we get different results. I wonder what I could change here to reproduce the problem. Maybe I shouldn't be using conemu but instead something else? Tom