From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id S18QKHf6W2go+h0AWB0awg (envelope-from ) for ; Wed, 25 Jun 2025 09:32:39 -0400 Received: by simark.ca (Postfix, from userid 112) id 8E1931E11C; Wed, 25 Jun 2025 09:32:39 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-9.0 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 874F21E0C2 for ; Wed, 25 Jun 2025 09:32:37 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7D0373857729 for ; Wed, 25 Jun 2025 13:32:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7D0373857729 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by sourceware.org (Postfix) with ESMTPS id 5E3C93857B8F for ; Wed, 25 Jun 2025 13:32:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5E3C93857B8F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5E3C93857B8F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750858320; cv=none; b=a9D0uhfdw6weUzIJBBJbpR1pVkuzBwXn8O6u+55q8aIi4hEEpEZXc6Deq10CzZrhWpVzJLsKRNbUN21FEyVJK2Pa5Y771Im3IinmklxWOG7WPTmVP4AP1pgECnoUSLAw8amNrKqEhL5t1bBYv9rw6hba2jJarF6UNfF6IYwIfnw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1750858320; c=relaxed/simple; bh=9svlRLwkkWsCK5QbFQI2e7/fmg8EcBsjWGZ+wz7HPa0=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=RCbdblEuEXatoG19M40lpJ+r83tiRej+N2QVOD1t+roZv8RgyCh4xLQVKq0HIRK3IQ1cyh6ztlV1r0/+C5xx5MQlM/ZU9edxL/qO8wAMGo8LBFDFYrRn1cLrHQ91pYkwce8QFVpl1UN63zPR17aC5W5UJnBZTLoMsVSrepe2/n0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5E3C93857B8F Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-3a50fc7ac4dso1058502f8f.0 for ; Wed, 25 Jun 2025 06:32:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750858319; x=1751463119; h=content-transfer-encoding:in-reply-to:content-language:from :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=E4qRBxPxywj3IVDgM2c9cNEeDbIEqpDmwWiybxgCmmk=; b=nTgobxpSyLRrHUGd6RS6mwWri5nUaHreNAIyT/NUv1pvfwESIQr3TXfzB8I/bUxGZ7 2lBofuCJJ/OOnyMNp37iDHUNwCnICbHQhfjmz3gmCGxaOVGA9FNRrEDMuZ3ibk1kv8Uu +pHOFi0z4WvxIaNH9f8xuXcFt7pK5xJ6vtN04OTqcsNFNsYgKpxz22Y9YMQiCo0lihki 51GbZQWp09gtBg9ohIgO7yU0fELa2fAWXXNSEwvA1uO0PP0FrR/KMqkVwKSdogyxrM7p +Cniy3+XVBCKNQP70DwLjNHUWSOGOR4ryHT3mQ82bi0EZ77/VrNwCdqdj+OoWz+i4UWG 9hUQ== X-Forwarded-Encrypted: i=1; AJvYcCWDGwDi5JIKfIvBKJQbDHASg7/zSrIhMCZRhraz4YSiOHJ9AFJb+Os0HRw5HKaRu9qp6/KR3ladtDrWuA==@sourceware.org X-Gm-Message-State: AOJu0Yy3jU37gLIFCaX+ytVDQoZ5mpEpQBidMRvUrL+Js8oKh6e2VhA+ 8K7Bitos6WmRdxL3A4syxF3sJLEOdDXBLV7Y3G+NJ5g3nrH8FhQigAISg1uCnQ== X-Gm-Gg: ASbGncvL1EcnCWOUNSK2WhbJ39ruwNOlp4bkK/S7Q+MkgRkTNS0xmc+PuK1wxt+tScj syYDSWnj3BM7W7Q0OJewhjDYUlfuKQNTRuDYNFzKx9gFvOe7yaQeuPlEIaIAXAw1P4qfw5kuGTG 2t+L5ljfPVeofR97PcOZAORui9wNqGAXTTSZ7ECeODZvVSGGNDYXqd1RQacT+PTpdh/qKHeheYN k/NLStuaL/lnG2QTHJNm3qoNln59/rsMhZZGwZ09kgs2SHyhv53YOzyxbhfZmUGIprTRIVnIW3s KDPhZ40eUy9TD2BoAo9Gb54apxZakgG/Yv45xct9rFX+LEwvAcS4RqD1pBqOlnhJBkninXgBsbC WsNIOk9M61+bkSrfMN33dkHcmDElK4w== X-Google-Smtp-Source: AGHT+IGb3py/bbXXGPpYbmEiL8eWQAPxyAdzo5yzBx6rnZ/KhEWdp6mjLEviJybTVgRrZSpuYZuLRg== X-Received: by 2002:a05:6000:3106:b0:3a4:d53d:be20 with SMTP id ffacd0b85a97d-3a6ed62e869mr2286360f8f.18.1750858318870; Wed, 25 Jun 2025 06:31:58 -0700 (PDT) Received: from ?IPV6:2001:8a0:fac3:6d00:5314:95f5:d044:767a? ([2001:8a0:fac3:6d00:5314:95f5:d044:767a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a6e805e0fesm4623280f8f.30.2025.06.25.06.31.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 Jun 2025 06:31:58 -0700 (PDT) Message-ID: <81ba0310-7b26-43e5-8770-1c2dba9f73f3@palves.net> Date: Wed, 25 Jun 2025 14:31:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Improve attach on Windows To: Hannes Domani , "gdb-patches@sourceware.org" References: <1549974991.1116105.1750000125453.ref@mail.yahoo.com> <1549974991.1116105.1750000125453@mail.yahoo.com> From: Pedro Alves Content-Language: en-US In-Reply-To: <1549974991.1116105.1750000125453@mail.yahoo.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Hi Hannes, [Guess the list was dropped by mistake, adding it back.] On 2025-06-15 16:08, Hannes Domani wrote: >> Automatically switching to main thread is IMHO more useful.  That >> results in very similar output than what we see on Linux: >> >> attach 5164 >> Attaching to program: /home/alves/gdb/build-cygwin-testsuite/outputs/gdb.base/attach/attach, process 5164 >> [New Thread 5164.0x87c] >> [New Thread 5164.0x28f0] >> [New Thread 5164.0x376c] >> [New Thread 5164.0x2db4] >> [New Thread 5164.0xce4] >> main () at /home/alves/gdb/src/gdb/testsuite/gdb.base/attach.c:19 >> 19        while (! should_exit) >> (gdb) > > I wonder if we should do something similar when Ctrl-C is hit. > That could be done, I guess. I can think of one downside, but I'm not sure it's strong enough. If you're debugging a program that has a Ctrl-C handler installed, and you decide to pass the exception to the program, after GDB intercepted it, you can do it immediately with "signal SIGINT", or "queue-signal SIGINT; c". But if GDB automatically changes threads, then you have to remember to switch to the thread that got the exception, before issuing the "signal" command. Maybe that could be sorted out with a warning. But then it might be annoying to see the warning all the time. BTW, in the users/palves/windows-non-stop-v2-plus branch, you'll find some extra patches, and this one: commit 95bafb7217bac2d51f5b6a59d34d79bcbaa1eddc Author: Pedro Alves AuthorDate: Fri May 5 15:51:31 2023 +0100 Commit: Pedro Alves CommitDate: Mon Jun 9 18:49:19 2025 +0100 Windows all-stop, interrupt with "stopped" instead of SIGTRAP ... is sort of related. It doesn't affect pressing Ctrl-C, but it affects explicit "interrupt", like: (gdb) c& Continuing. (gdb) [New Thread 11688.0x2ff8] [Thread 11688.0x2e30 exited with code 0] [New Thread 11688.0x3040] interrupt (gdb) Thread 1 "sleep" stopped. [Switching to Thread 11688.0x2e94] 0x00007ffd839118d7 in ntdll!ZwWaitForMultipleObjects () from /cygdrive/c/Windows/SYSTEM32/ntdll.dll For Ctrl-C, it might be possible to make GDB see the Ctrl-C before the inferior does, and then stop the inferior with "stopped" too (i.e., just suspend threads, no exception injected.). I still have the Ctrl-C rework series that makes Linux work that way (by making the inferior transparently run on a separate pseudo tty) that I hope I'll eventually be able to get back to. Not sure Windows would need a similar treatment, though, but it might. Pedro Alves