From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 2XlGFslWgmqYFysAWB0awg (envelope-from ) for ; Sun, 16 Aug 2026 20:33:13 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=palves.net header.i=@palves.net header.a=rsa-sha256 header.s=dreamhost header.b=nL/LXrmT; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 4A5891E09B; Sun, 16 Aug 2026 20:33:13 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (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 5BCA91E09B for ; Sun, 16 Aug 2026 20:33:12 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C80DA4BA2E15 for ; Mon, 17 Aug 2026 00:33:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C80DA4BA2E15 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=palves.net header.i=@palves.net header.a=rsa-sha256 header.s=dreamhost header.b=nL/LXrmT Received: from bird.elm.relay.mailchannels.net (bird.elm.relay.mailchannels.net [23.83.212.17]) by sourceware.org (Postfix) with ESMTPS id 4E7B84BA5436 for ; Mon, 17 Aug 2026 00:32:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4E7B84BA5436 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=palves.net ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4E7B84BA5436 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=23.83.212.17 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786926767; cv=none; b=aM4Lol94LAkw6ItLKRnTrodmvUyEKgoP/3y7sSmOnvmFZF6nAMtrJAgcgtY4zoxMOuDbgidh+r7q2yMnBrPSRR9rT/IM/aQJh2L2EaG+2V1QJkCMCeD5QHsLWrJIj7pIvcm7rGQ0w1B+J0NLfEErrfRZgjEpi0iSMzwTZpyXpJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786926767; c=relaxed/simple; bh=YugiF7vPQnV8QZnjWl0iy1RdNgJlZzBzPB9Ls0NIRH0=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=fNJmG/GHctFUecI571u1QzL/JQ4/D6zKWdx4XNlDFtulFC5SIumwxqHnsbv/KYzVq3HL0jOUaV9X40BSmBzV+4olfr1gFd0OXbEW+UGK948sI6Ie3v95Szmmnrit3Hy41tp2RK0r3OvKqrayqH+KHxJNW7r/p1M98w4AopQhYhY= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=palves.net header.i=@palves.net header.a=rsa-sha256 header.s=dreamhost header.b=nL/LXrmT DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E7B84BA5436 X-Sender-Id: dreamhost|x-authsender|pedro@palves.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id BB9A48C128D; Mon, 17 Aug 2026 00:32:44 +0000 (UTC) Received: from pdx1-sub0-mail-a247.dreamhost.com (100-112-42-149.trex-nlb.outbound.svc.cluster.local [100.112.42.149]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 391608C286C; Mon, 17 Aug 2026 00:32:44 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|pedro@palves.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|pedro@palves.net X-MailChannels-Auth-Id: dreamhost X-Quick-Shrill: 0cf7957e3c2102a2_1786926764602_3976157055 X-MC-Loop-Signature: 1786926764602:3015713743 X-MC-Ingress-Time: 1786926764602 Received: from pdx1-sub0-mail-a247.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.112.42.149 (trex/8.0.2); Mon, 17 Aug 2026 00:32:44 +0000 Received: from [192.168.1.103] (bl5-1-200.dsl.telepac.pt [82.154.1.200]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pedro@palves.net) by pdx1-sub0-mail-a247.dreamhost.com (Postfix) with ESMTPSA id 4hNYhC3JYWzyrG; Sun, 16 Aug 2026 17:32:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=palves.net; s=dreamhost; t=1786926764; bh=8QY/9qJ1BnP/s2HHOvVgBLQkM5WlneisNMw7lIf/VeM=; h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding; b=nL/LXrmTSrtE8PQ2mENMFuuWLcFUvMrROHaxAPLZPzHvYGO0WkIV7S059ejVz6AJm ytwWN/Gja5uOFn2/xwtkTQzm/xeO3/Qx/C338Ixok/PPI73pdblkoMrIO2NI+qPf3H sZqAR2m+i8n2ddfX3I1MSoqYAx19dOsUUfzVQD2tzrHRluqJwqIEk52I8Uc0IqAwnw 3NRPSlyasQJv90a2cYeWMK60yEfDl/pbXNZbvZ7pLh5FA3t8y7SDf760gyZSs6CCvZ X/KK/ZvMJVcTQNN1A6Jz2zdPOyTyjkyqYBfCFxDtI7VYlwnt9XbOS0fteXhLo+njSG mxTCvccm84JgA== Message-ID: <130bf75f-5fcc-4a4c-8363-a9dc9eecc10e@palves.net> Date: Mon, 17 Aug 2026 01:32:40 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] Windows gdb: Fix resetting of the debug-registers bit in ContextFlags To: Hannes Domani , gdb-patches@sourceware.org References: <20260722153353.429342-1-ssbssa.ref@yahoo.de> <20260722153353.429342-1-ssbssa@yahoo.de> From: Pedro Alves Content-Language: en-US In-Reply-To: <20260722153353.429342-1-ssbssa@yahoo.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 Sorry for the delay. I'm traveling this week, and last week I thought I would manage to take a look at this before leaving but something came up that prevented it. FWIW, this version looks good to me. The note about WOW64 in the commit log is exactly the sort of thing that we were missing before. Thank you. Pedro Alves On 2026-07-22 16:32, Hannes Domani wrote: > The CONTEXT_DEBUG_REGISTERS also includes the arch-specific bit > (CONTEXT_i386 or CONTEXT_AMD64) which is included in all CONTEXT_* > defines. > > So this basically just checks if any CONTEXT_* define is set: > if ((context->ContextFlags & CONTEXT_DEBUG_REGISTERS) != 0) > > And similarly, unsetting CONTEXT_DEBUG_REGISTERS removes the > arch-specific bit as well. > > This isn't a problem per-se, since Windows seems to just ignore the > arch-specific bit anyways in SetThreadContext. > But it also creates inconsistent behavior for WOW64, because it uses > the wrong arch-specific bit there. > > So this creates a CONTEXT_DEBUG_REG_FLAG define with just the > debug-registers bit, and uses it in these problematic locations. > --- > v2: > - updated commit message > - changed CONTEXT_DEBUG_REG_FLAG define to avoid hardcoded number > --- > gdb/x86-windows-nat.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/gdb/x86-windows-nat.c b/gdb/x86-windows-nat.c > index 27adeb1f154..2f556e47b39 100644 > --- a/gdb/x86-windows-nat.c > +++ b/gdb/x86-windows-nat.c > @@ -42,6 +42,10 @@ enum > > #define DR6_CLEAR_VALUE 0xffff0ff0 > > +/* The CONTEXT_DEBUG_REGISTERS define without the arch-specific bit > + (CONTEXT_i386 or CONTEXT_AMD64). */ > +#define CONTEXT_DEBUG_REG_FLAG (CONTEXT_DEBUG_REGISTERS & ~CONTEXT_CONTROL) > + > struct x86_windows_per_inferior : public windows_per_inferior > { > /* The function to use in order to determine whether a register is > @@ -142,7 +146,7 @@ x86_windows_nat_target::thread_context_continue (windows_thread_info *th, > { > windows_process->fill_thread_context (th); > > - gdb_assert ((context->ContextFlags & CONTEXT_DEBUG_REGISTERS) != 0); > + gdb_assert ((context->ContextFlags & CONTEXT_DEBUG_REG_FLAG) != 0); > > /* Check whether the thread has Dr6 set indicating a > watchpoint hit, and we haven't seen the watchpoint event > @@ -173,13 +177,13 @@ x86_windows_nat_target::thread_context_continue (windows_thread_info *th, > update the debug registers later when the thread > is re-resumed by the core after the watchpoint > event. */ > - context->ContextFlags &= ~CONTEXT_DEBUG_REGISTERS; > + context->ContextFlags &= ~CONTEXT_DEBUG_REG_FLAG; > } > } > else > DEBUG_EVENTS ("0x%x has no dr6 set", th->tid); > > - if ((context->ContextFlags & CONTEXT_DEBUG_REGISTERS) != 0) > + if ((context->ContextFlags & CONTEXT_DEBUG_REG_FLAG) != 0) > { > DEBUG_EVENTS ("0x%x changing dregs", th->tid); > context->Dr0 = state->dr_mirror[0];