From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id oI6SNJ4yK2g2NyoAWB0awg (envelope-from ) for ; Mon, 19 May 2025 09:31:10 -0400 Received: by simark.ca (Postfix, from userid 112) id D4FF71E11C; Mon, 19 May 2025 09:31:10 -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 719C21E102 for ; Mon, 19 May 2025 09:31:10 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 232F73857B9E for ; Mon, 19 May 2025 13:31:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 232F73857B9E Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by sourceware.org (Postfix) with ESMTPS id C36003858D3C for ; Mon, 19 May 2025 13:24:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C36003858D3C 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 C36003858D3C 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=1747661049; cv=none; b=OWLqTHsqP/BNBptcn0zccnvyf1TWOaKBEJB26QdQFLSxph3rzwB5i166MnjTeUuT4NiC//YObEkdGnyKRT9Iec6Yu124VdMetvN/ozfKko6OKm/k0nIuEi+V3fcqms5IUJAbWhPbINWcmFhR79BY2iUWzVBzzS4jh8h68VRXP/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747661049; c=relaxed/simple; bh=OpZnBLbg8PnZda5zeiLCk+k8b5af1wgSrzGkbT9z8ps=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=m3dIqFgeevLa2/5d1+0qlopI/yEo4Z30LVJ/sS7/na/kzSyuGXAZaHkNyisLApuTrN0eXj2wulzZT8PjkHPYt6cHd8vcGSn5HbIVl7BcLSElTcDQimwgbpQSaJe7Lu+oxPwC7xh1YaneG8JncSUjNtxusPkWLvH7aAR6v/4MG1g= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C36003858D3C Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-442f9043f56so23141435e9.0 for ; Mon, 19 May 2025 06:24:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747661047; x=1748265847; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rD9a8lVESmnnbCT/ORz8rXmmAJKz0avfmNUY0ASmATo=; b=F1jebVPcRyFRq5+p6CzFw2BD9xO204LoWHGXTI/f5RHbg4T9PQpeZqaYCFPypqE+nj dQo5vwObGWxiWHi4lbWtSXdRVCwnwoX8dNs+1yHTw2AQdNhiTKGcVejrq9tAeI0WWlcs weNFBxfEiRS0zHekuWGsUQ/ntW4d9YN74YYKl3YlJfFJpoPYyPvRPEChe7Dum6K+V7Pn 2VrRFgKhiyKi7fyeTduDJtsq6JWkmLWueh5xVke9/59uSDmRbFYFixs6uRCBHkZNG1YP 9naT5gHrpJq6bh0/S7KcS4Fq/x6UgnIs/vy28daT9LtZ2VJd/kvg4l2WDH9dGcOf17C7 NeQg== X-Gm-Message-State: AOJu0Yz7qtX8uvmYM7PCHnO8bnKYSgWO1+fQAUdQE2G5mIVjuiFIKPks xSFPElY1h2tizatEvTnu2ae9Tpsu4DuHRDlhMO4G9pRH2gTnGXjQSzkGFn36lW4q X-Gm-Gg: ASbGncu1DBJCwbj9xjbbMwU8Z6z1E+yO4x/tMwhUufjyfzL08npHTslna2nqgsnsCGC uijvM20Pnhp28BXoV3t9UTsuM2Ln7qpPJtww3kF/AQjgJZ+TAgKrE1Szk17W/3/psR7T6HGKDk5 +QssmJ0QDIIki/G/QBGXvHd5Z8coV1ysVCmaKhSRS8EAv2GtrG1miIZ6MgQdNyRSaHejQkPC+ox Cq+FQt+fBjIDTYILG2SAPJtyOUhgTxYEKSmLoPIElaoCrNHNhTQeZCjTkLSoJvcTLEKFTT4NCvJ fEppMJB7YxZ7K37Tib/PNi/fBOSG1frLmfYTNQaufEn0+1+HrG6vTK4GuPxFRA== X-Google-Smtp-Source: AGHT+IEDmxvj4tOwkB7J8ghcu5X2IWttnM8on+7mW5rs6261nKzedKq+vjObstlTXRuO3tOoZzlgTQ== X-Received: by 2002:a05:600c:3114:b0:440:61eb:2ce5 with SMTP id 5b1f17b1804b1-442fd64e335mr141658865e9.17.1747661047195; Mon, 19 May 2025 06:24:07 -0700 (PDT) Received: from localhost ([2001:8a0:4fe9:b400:8d90:6f0d:36bf:32df]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-442fd59ab3esm142800525e9.40.2025.05.19.06.24.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 May 2025 06:24:06 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 18/47] Windows gdb: Factor code out of windows_nat_target::windows_continue Date: Mon, 19 May 2025 14:22:39 +0100 Message-ID: <20250519132308.3553663-19-pedro@palves.net> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250519132308.3553663-1-pedro@palves.net> References: <20250519132308.3553663-1-pedro@palves.net> MIME-Version: 1.0 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 This factors some code out of windows_nat_target::windows_continue into a new windows_continue_one function. This will make the following patch easier to read (as well as the resulting code itself). Approved-By: Tom Tromey Change-Id: I14a0386b1b8b03015e86273060af173b5130e375 --- gdb/windows-nat.c | 78 +++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 36 deletions(-) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 778cd8e348f..1f6293aa8c0 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -117,6 +117,9 @@ struct windows_per_inferior : public windows_process_info void invalidate_context (windows_thread_info *th); + void continue_one_thread (windows_thread_info *th, + windows_continue_flags cont_flags); + int windows_initialization_done = 0; std::vector> thread_list; @@ -1213,6 +1216,44 @@ windows_per_inferior::handle_access_violation return false; } +void +windows_per_inferior::continue_one_thread (windows_thread_info *th, + windows_continue_flags cont_flags) +{ + struct x86_debug_reg_state *state = x86_debug_reg_state (process_id); + + windows_process.with_context (th, [&] (auto *context) + { + if (th->debug_registers_changed) + { + context->ContextFlags |= WindowsContext::debug; + context->Dr0 = state->dr_mirror[0]; + context->Dr1 = state->dr_mirror[1]; + context->Dr2 = state->dr_mirror[2]; + context->Dr3 = state->dr_mirror[3]; + context->Dr6 = DR6_CLEAR_VALUE; + context->Dr7 = state->dr_control_mirror; + th->debug_registers_changed = false; + } + if (context->ContextFlags) + { + DWORD ec = 0; + + if (GetExitCodeThread (th->h, &ec) + && ec == STILL_ACTIVE) + { + BOOL status = set_thread_context (th->h, context); + + if ((cont_flags & WCONT_KILLED) == 0) + CHECK (status); + } + context->ContextFlags = 0; + } + }); + + th->resume (); +} + /* Resume thread specified by ID, or all artificially suspended threads, if we are continuing execution. See description of windows_continue_flags for CONT_FLAGS. */ @@ -1234,42 +1275,7 @@ windows_nat_target::windows_continue (DWORD continue_status, int id, for (auto &th : windows_process.thread_list) if (id == -1 || id == (int) th->tid) - { - struct x86_debug_reg_state *state - = x86_debug_reg_state (windows_process.process_id); - - windows_process.with_context (th.get (), [&] (auto *context) - { - if (th->debug_registers_changed) - { - context->ContextFlags - |= WindowsContext::debug; - context->Dr0 = state->dr_mirror[0]; - context->Dr1 = state->dr_mirror[1]; - context->Dr2 = state->dr_mirror[2]; - context->Dr3 = state->dr_mirror[3]; - context->Dr6 = DR6_CLEAR_VALUE; - context->Dr7 = state->dr_control_mirror; - th->debug_registers_changed = false; - } - if (context->ContextFlags) - { - DWORD ec = 0; - - if (GetExitCodeThread (th->h, &ec) - && ec == STILL_ACTIVE) - { - BOOL status = set_thread_context (th->h, context); - - if ((cont_flags & WCONT_KILLED) == 0) - CHECK (status); - } - context->ContextFlags = 0; - } - }); - - th->resume (); - } + windows_process.continue_one_thread (th.get (), cont_flags); continue_last_debug_event_main_thread (_("Failed to resume program execution"), continue_status, -- 2.49.0