From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MKuWJFQyK2g2NyoAWB0awg (envelope-from ) for ; Mon, 19 May 2025 09:29:56 -0400 Received: by simark.ca (Postfix, from userid 112) id 919D51E11C; Mon, 19 May 2025 09:29:56 -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 1E8DB1E102 for ; Mon, 19 May 2025 09:29:56 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B1FA33858C41 for ; Mon, 19 May 2025 13:29:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B1FA33858C41 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by sourceware.org (Postfix) with ESMTPS id A20A43858C42 for ; Mon, 19 May 2025 13:24:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A20A43858C42 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 A20A43858C42 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747661046; cv=none; b=vGsqLqnpwASRoXj1kNk21iJ8OxH8UhNxAyhKQKuwVcJo2zgtOS8Ttg2BDaUFAyPRqgaqiEM2R1dLQMv0bt5sSAuiH7KvMQG43cuHJj9KydOjYHrZxQOQnR+LDwYVUkhllSbXYHhOJmYMteNA488pEU/D4OqblxskgvevLZW4Lwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747661046; c=relaxed/simple; bh=lBwzdly3y5Fp3EAt5lhkzGcgIN3pWJ4+sR5J36nvaH8=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=IMUlRDevJUV5kkwFc0vRUOQjIvMSLQUSe3lyri/gHZLRZiEA9qd6oAmN+AS9YuFohfyPmWlJtiyHqQMl6XcqZPXnTXHJzRwRmwKRSZd1iJ7LXxTPgKuUTNl4BCAw24zlo0E9S2HXVYS0aN6Eof9HEXf7JcoMQJi8eFT5QoinoXE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A20A43858C42 Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-3a3706ff36bso796708f8f.2 for ; Mon, 19 May 2025 06:24:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747661045; x=1748265845; 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=tjJwDEdy8o/v8drvT0IWhUGp43xuFJqewYc14s4iUnQ=; b=bPIMa9jPpYS6bozCRT4Aq2gY7UTBtlxmQn+iri0/1okIHu1g24IcSj6adk9YzzFI0w SEeS8zcFN8VfGiJISyVELH/68HgyHH2P/Rd3yBYjDA8I5bxWmaWqYc2uCWbUogly2//0 QnQxIXBwShSQcJCfpQJuOtUlr1xkONbP4KAWFxcLGp44urDFtJJVdggWitCdxP1HZWbn rAAJRpAKPXlJYqATlVpnacNKY+ooDXWcjjrC4nuzvXH2+uSB5jrkIfbWXKTDcDwUoxDm j+XoKVoekTnqeTV7rgL3YnrUfuESmzZAXGrHpyXQ9CNTP4L55vPhI/9AbNyBIDu6k2TZ aDTQ== X-Gm-Message-State: AOJu0YwBA1lefvngiI2xdFTM8oOtHIwmW3nCxNGxf2l75wnOZ5Hu+LPB iN1tscHusu232tfWg8LCeRD50hWZhFPBcLfl+S5UJC8xaeeJ5r5uWyWyfxWEJEhX X-Gm-Gg: ASbGncvPC6U9ncnNc/nZmmMrhZxCmzLFU06eypFmLt1y1V06saNCjZj2fbiodWfm3yW yjpKp4wI39LOs2lDEgwdDBLewicj34p7bmQwxtbWegmT3yL7bcW3AIwdZ6buMUdXgkyv9fqjUuf 9696GBtYILluNrI36ppbaysu0YmC9l4NppiorIMpAi9E0D1pkTNMB6d7bdJOzzyWAkrmSEkqI0T F34xJaIr4kV9dWYwffrU9wPUFz66vODZf8JOq3xCXzMNSeRsloUQGl1Oyk5j8etFHri1ew0OSEg Rnn6045oQtZ0oQV2UonY1fxGkGzNGNp1/amlQhDBSuLaTtHyt4E= X-Google-Smtp-Source: AGHT+IH79jJeqjQ9OaJGlWFiKif1QEt6L185+YJUIJLLFXFG7cm54GPYAAyaoIV2R7jC88Ry2qIEtQ== X-Received: by 2002:a05:6000:186c:b0:3a3:6a3f:bc85 with SMTP id ffacd0b85a97d-3a36a3fbee8mr4988044f8f.25.1747661045108; Mon, 19 May 2025 06:24:05 -0700 (PDT) Received: from localhost ([2001:8a0:4fe9:b400:8d90:6f0d:36bf:32df]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a3699a9bf3sm7752518f8f.54.2025.05.19.06.24.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 May 2025 06:24:04 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 17/47] Windows gdb: Introduce windows_continue_flags Date: Mon, 19 May 2025 14:22:38 +0100 Message-ID: <20250519132308.3553663-18-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 windows_continue already has two boolean parameters: (..., int killed, bool last_call = false) A patch later in the series would need a third. Instead, convert windows_continue to use an optional enum-flags parameter instead of multiple booleans. Approved-By: Tom Tromey Change-Id: I17c4d8a12b662190f972c380f838cb3317bd2e1e --- gdb/windows-nat.c | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 6393f394804..778cd8e348f 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -91,6 +91,22 @@ struct windows_solib std::string name; }; +/* Flags that can be passed to windows_continue. */ + +enum windows_continue_flag + { + /* This means we have killed the inferior, so windows_continue + should ignore weird errors due to threads shutting down. */ + WCONT_KILLED = 1, + + /* This means we expect this windows_continue call to be the last + call to continue the inferior -- we are either mourning it or + detaching. */ + WCONT_LAST_CALL = 2, + }; + +DEF_ENUM_FLAGS_TYPE (windows_continue_flag, windows_continue_flags); + struct windows_per_inferior : public windows_process_info { windows_thread_info *find_thread (ptid_t ptid) override; @@ -325,8 +341,8 @@ struct windows_nat_target final : public x86_nat_target void delete_thread (ptid_t ptid, DWORD exit_code, bool main_thread_p); DWORD fake_create_process (); - BOOL windows_continue (DWORD continue_status, int id, int killed, - bool last_call = false); + BOOL windows_continue (DWORD continue_status, int id, + windows_continue_flags cont_flags = 0); /* Helper function to start process_thread. */ static DWORD WINAPI process_thread_starter (LPVOID self); @@ -1198,14 +1214,12 @@ windows_per_inferior::handle_access_violation } /* Resume thread specified by ID, or all artificially suspended - threads, if we are continuing execution. KILLED non-zero means we - have killed the inferior, so we should ignore weird errors due to - threads shutting down. LAST_CALL is true if we expect this to be - the last call to continue the inferior -- we are either mourning it - or detaching. */ + threads, if we are continuing execution. See description of + windows_continue_flags for CONT_FLAGS. */ + BOOL windows_nat_target::windows_continue (DWORD continue_status, int id, - int killed, bool last_call) + windows_continue_flags cont_flags) { windows_process.desired_stop_thread_id = id; @@ -1247,7 +1261,7 @@ windows_nat_target::windows_continue (DWORD continue_status, int id, { BOOL status = set_thread_context (th->h, context); - if (!killed) + if ((cont_flags & WCONT_KILLED) == 0) CHECK (status); } context->ContextFlags = 0; @@ -1259,7 +1273,7 @@ windows_nat_target::windows_continue (DWORD continue_status, int id, continue_last_debug_event_main_thread (_("Failed to resume program execution"), continue_status, - last_call); + cont_flags & WCONT_LAST_CALL); return TRUE; } @@ -1362,9 +1376,9 @@ windows_nat_target::resume (ptid_t ptid, int step, enum gdb_signal sig) Otherwise complain. */ if (resume_all) - windows_continue (continue_status, -1, 0); + windows_continue (continue_status, -1); else - windows_continue (continue_status, ptid.lwp (), 0); + windows_continue (continue_status, ptid.lwp ()); } /* Interrupt the inferior. */ @@ -2072,7 +2086,7 @@ windows_nat_target::detach (inferior *inf, int from_tty) if (m_continued) break_out_process_thread (process_alive); - windows_continue (DBG_CONTINUE, -1, 0, true); + windows_continue (DBG_CONTINUE, -1, WCONT_LAST_CALL); std::optional err; if (process_alive) @@ -2820,13 +2834,13 @@ windows_nat_target::create_inferior (const char *exec_file, do_initial_windows_stuff (pi.dwProcessId, 0); - /* windows_continue (DBG_CONTINUE, -1, 0); */ + /* windows_continue (DBG_CONTINUE, -1); */ } void windows_nat_target::mourn_inferior () { - (void) windows_continue (DBG_CONTINUE, -1, 0, true); + windows_continue (DBG_CONTINUE, -1, WCONT_LAST_CALL); x86_cleanup_dregs(); if (windows_process.open_process_used) { @@ -2884,7 +2898,7 @@ windows_nat_target::kill () for (;;) { - if (!windows_continue (DBG_CONTINUE, -1, 1)) + if (!windows_continue (DBG_CONTINUE, -1, WCONT_KILLED)) break; wait_for_debug_event_main_thread (&windows_process.current_event); if (windows_process.current_event.dwDebugEventCode -- 2.49.0