From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by sourceware.org (Postfix) with ESMTPS id 5DE28384AB6F for ; Tue, 7 May 2024 23:44:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5DE28384AB6F 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 5DE28384AB6F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715125469; cv=none; b=kUDfYXFyzWwlDTSC18jyYAWG86ankjMThYhZFVmO5tEJAxGWHJUYzkPSOIWqiQMJW5AR757Voe3U80hJhX0sD4yo0Psu715QoVSv2n2OmbjA++D02o0fHpfvyPP5XWQkT7jagQBRDNrDyZ6WsFDt66Tr7niVnVUoVCdLIhDzMvA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715125469; c=relaxed/simple; bh=xQRMLcTLQ/d41t+OlYFX10yd5ahv6xv75Ug7vhRvSpY=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Z9pr6KdN/72EQpSKEfIkDp4cD3Pbd/PfiwYIC+HEQALbSvsfU+U0h3k1FucRjq0I795wW8UqDmDE1p0q12ITcufAwNjnGZyOZDdu/a5F8I86lO5llHiLMN9YEFN7kUGn+cWPslBsgSZKPTmQPP0BJrFjr1xJZN2Bd9WJSqXDv5Q= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-41b21ed19f5so26354595e9.2 for ; Tue, 07 May 2024 16:44:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715125466; x=1715730266; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tHHpsWIiGIdTvJNxPDnJ66W3bz0VpxWEQP7X7LoK4LM=; b=Bj0ae3/6RcJuDFAGBMscudHCuVMj6QQNA/LS7riPTA/an0Q+2C0EfbOc3E5gLE1d38 5T0YkyWqDH/tWjdDevfPAZtLE5CTIWkG30+H7q/uDMmCjF3o5YS/1X3fiZCqIkTfMXNb VYoR7+eQJge2r0yzLjvpfkm824jzC30MSdmTKq5iw+p9oGkdip7V1EynbC76G5IGlf4Q e0SGGb3bR5nvdv6t3x8QjSFa+LsJWNkshgUJtuARcYStbMlT1UlwOKcQHcLET42uhCVI q4/if2kc2t6qNjDi8OnrUoa5aU0rca3fywGS4tKrDr1I9XmEVuinjdCzkTiNO+rePuZX IfhA== X-Gm-Message-State: AOJu0YxjVqsdnYyZ0cMLPschWDPTKIKzNx1J7myoIGyrdL2uCeuz19Fe b0JslqckvjUvjSCkqtALfqUqV+d8A0haOFLU9viif8CXD0RfGBj0jYKXnFZ0 X-Google-Smtp-Source: AGHT+IEf7rs9rESq+dFdIu2zbc3ZsdhRDpuFHuK6Y8QLCXpu8u0cnfBNq7wbx3l9pI8GkMg9sS6hrA== X-Received: by 2002:a05:6000:1b85:b0:349:7e8e:b29a with SMTP id ffacd0b85a97d-34fca80e9a8mr824922f8f.62.1715125465948; Tue, 07 May 2024 16:44:25 -0700 (PDT) Received: from localhost ([2001:8a0:f908:4900:2dd1:1a0d:2b75:dc42]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-41f88208886sm1883105e9.45.2024.05.07.16.44.25 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 May 2024 16:44:25 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 29/34] windows_per_inferior::continue_one_thread, unify WoW64/non-WoW64 paths Date: Wed, 8 May 2024 00:42:28 +0100 Message-ID: <20240507234233.371123-30-pedro@palves.net> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240507234233.371123-1-pedro@palves.net> References: <20240507234233.371123-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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: Consolidate the WoW64 & non-WoW64 paths in windows_per_inferior::continue_one_thread to avoid code duplication. The next patch will add more code to this function, and this unification avoids writing that new code twice. Change-Id: I794aadb412a3b8081212e4acf2af80d3edba7392 --- gdb/windows-nat.c | 68 ++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 6e72f99c3f5..5500d8b8c87 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1288,64 +1288,60 @@ windows_per_inferior::continue_one_thread (windows_thread_info *th, struct x86_debug_reg_state *state = x86_debug_reg_state (process_id); #ifdef __x86_64__ - if (wow64_process) + DWORD &context_flags_ref = (wow64_process + ? th->wow64_context.ContextFlags + : th->context.ContextFlags); +#else + DWORD &context_flags_ref = th->context.ContextFlags; +#endif + + if (th->debug_registers_changed) { - if (th->debug_registers_changed) + context_flags_ref |= CONTEXT_DEBUG_REGISTERS; +#ifdef __x86_64__ + if (wow64_process) { - th->wow64_context.ContextFlags |= CONTEXT_DEBUG_REGISTERS; th->wow64_context.Dr0 = state->dr_mirror[0]; th->wow64_context.Dr1 = state->dr_mirror[1]; th->wow64_context.Dr2 = state->dr_mirror[2]; th->wow64_context.Dr3 = state->dr_mirror[3]; th->wow64_context.Dr6 = DR6_CLEAR_VALUE; th->wow64_context.Dr7 = state->dr_control_mirror; - th->debug_registers_changed = false; } - if (th->wow64_context.ContextFlags) - { - DWORD ec = 0; - - if (GetExitCodeThread (th->h, &ec) - && ec == STILL_ACTIVE) - { - BOOL status = Wow64SetThreadContext (th->h, - &th->wow64_context); - - if ((cont_flags & WCONT_KILLED) == 0) - CHECK (status); - } - th->wow64_context.ContextFlags = 0; - } - } - else + else #endif - { - if (th->debug_registers_changed) { - th->context.ContextFlags |= CONTEXT_DEBUG_REGISTERS; th->context.Dr0 = state->dr_mirror[0]; th->context.Dr1 = state->dr_mirror[1]; th->context.Dr2 = state->dr_mirror[2]; th->context.Dr3 = state->dr_mirror[3]; th->context.Dr6 = DR6_CLEAR_VALUE; th->context.Dr7 = state->dr_control_mirror; - th->debug_registers_changed = false; } - if (th->context.ContextFlags) - { - DWORD ec = 0; - if (GetExitCodeThread (th->h, &ec) - && ec == STILL_ACTIVE) - { - BOOL status = SetThreadContext (th->h, &th->context); + th->debug_registers_changed = false; + } + if (context_flags_ref != 0) + { + DWORD ec = 0; - if ((cont_flags & WCONT_KILLED) == 0) - CHECK (status); - } - th->context.ContextFlags = 0; + if (GetExitCodeThread (th->h, &ec) + && ec == STILL_ACTIVE) + { + BOOL status; +#ifdef __x86_64__ + if (wow64_process) + status = Wow64SetThreadContext (th->h, &th->wow64_context); + else +#endif + status = SetThreadContext (th->h, &th->context); + + if ((cont_flags & WCONT_KILLED) == 0) + CHECK (status); } + context_flags_ref = 0; } + th->resume (); th->last_sig = GDB_SIGNAL_0; } -- 2.43.2