From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 2VjBDRV2fGoxkyAAWB0awg (envelope-from ) for ; Wed, 12 Aug 2026 09:33:09 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=NjHrH8Yk; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 349421E168; Wed, 12 Aug 2026 09:33:09 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,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 [IPv6:2620:52:6:3111::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 D6D551E166 for ; Wed, 12 Aug 2026 09:33:07 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 721234BA79A0 for ; Wed, 12 Aug 2026 13:33:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 721234BA79A0 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=NjHrH8Yk Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by sourceware.org (Postfix) with ESMTPS id D50184BAE7DE for ; Wed, 12 Aug 2026 13:29:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D50184BAE7DE Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D50184BAE7DE Authentication-Results: sourceware.org; arc=none smtp.remote-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786541360; cv=none; b=sx0Ui0UcsjaH/TZl6Te67cX1tPlcAfhb014hxhn7hgHE5pA8oNho/N/Bmwnm8HoNY+pyY0IVyFFLM7sPmRsEel/+crwkEMsogXt90nDwxsd8l7z5N+kgRQhi2ZIQhG3+ZPrGF0BePVITLn/pKlN5GQIhzB4vtbdKiRY5msEHeFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786541360; c=relaxed/simple; bh=hmTr48dIXzHgi/13Us9jZrBwGmM5qzwV9kTuaVXclro=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kXuHSXkF+698G1NDspNeO7/OXwm6nfwenkZ81xQkHN7/N9o1N1z6Zmf7EomfLMJ+HPx5211tbK/plEAVZVsssTSch1p7KARjFPFRPdS+hq17NA0/qFnEm98HHqZaZ0jR1IJNTtq+zZvQ5S8WO1ohbbOFfjHSDwyi9vVbJ8zps30= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=NjHrH8Yk DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D50184BAE7DE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786541360; x=1818077360; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=hmTr48dIXzHgi/13Us9jZrBwGmM5qzwV9kTuaVXclro=; b=NjHrH8Yk/tI+c9j5ijVNZCDZoECVpOl9OBSoTVTU7U9lEl6/apZCRy/b 9/1rKvJOVPpoe9zlJq7BrInmB1+8/uuKuQFTu0IZ9t3pdY6k0FcShTCiP eHRKKRsU4iEAHoncv/2Oc0fZC9ePkh8gbGPfeM8gT4nQwyXfWOA8tvtyV u5rebi3CZEPNeIOf3fWoioEybkdcAnsjVWZaO2mQtxmuQkHtfFO9jglQF D/d0eRZAA29QnWELJc2zeIiEAdxJDE76AxG7XPemweZUc7lKUEswALKKg qbcRy8Wl91z9umHJkGbggP2KdN0Zo/ZnS8k4uaUq/GfCbvcQwxMqEZM1x Q==; X-CSE-ConnectionGUID: meFisxIRQdqEpzk0BnyLYg== X-CSE-MsgGUID: BCjVrWh6SwCrQjtZ2zpd+w== X-IronPort-AV: E=McAfee;i="6800,10657,11872"; a="97757860" X-IronPort-AV: E=Sophos;i="6.25,219,1779174000"; d="scan'208";a="97757860" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2026 06:29:19 -0700 X-CSE-ConnectionGUID: AX2i7orSRKa8zV+BDDXhrg== X-CSE-MsgGUID: 21ufBvHySqqFqnihHOikSA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,219,1779174000"; d="scan'208";a="259817919" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2026 06:29:19 -0700 From: Markus Metzger To: gdb-patches@sourceware.org Subject: [PATCH v4 23/44] gdb: allow switching to an inferior without threads Date: Wed, 12 Aug 2026 15:27:43 +0200 Message-ID: <20260812132805.380163-24-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260812132805.380163-1-markus.t.metzger@intel.com> References: <20260812132805.380163-1-markus.t.metzger@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" 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 GPU inferiors may temporarily have no threads when no work is dispatched to that GPU. We still want to allow switching to such inferiors and resuming them in all-stop mode (subsequent patch). Also refactor the code a bit to split switching and notifying based on the (potentially new) state. --- gdb/inferior.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/gdb/inferior.c b/gdb/inferior.c index cc7d1cc4f94..b0112d4885c 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -767,29 +767,25 @@ inferior_command (const char *args, int from_tty) if (inf == NULL) error (_("Inferior ID %d not known."), num); - if (inf->pid != 0) + if (inf->pid == 0) + switch_to_inferior_no_thread (inf); + else if (inf != current_inferior ()) { - if (inf != current_inferior ()) - { - thread_info *tp = any_thread_of_inferior (inf); - if (tp == NULL) - error (_("Inferior has no threads.")); - - switch_to_thread (tp); - } - - notify_user_selected_context_changed - (USER_SELECTED_INFERIOR - | USER_SELECTED_THREAD - | USER_SELECTED_FRAME); + thread_info *tp = any_thread_of_inferior (inf); + if (tp == nullptr) + switch_to_inferior_no_thread (inf); + else + switch_to_thread (tp); } - else - { - switch_to_inferior_no_thread (inf); - notify_user_selected_context_changed - (USER_SELECTED_INFERIOR); - } + if (inferior_ptid == null_ptid) + notify_user_selected_context_changed + (USER_SELECTED_INFERIOR); + else + notify_user_selected_context_changed + (USER_SELECTED_INFERIOR + | USER_SELECTED_THREAD + | USER_SELECTED_FRAME); /* Switching current inferior may have made one of the inferiors prunable, so prune it. */ -- 2.43.0 ________________________________________ Intel Deutschland GmbH Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany Tel: +49 (89) 99143-0 www.intel.de Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman Chairperson of the Supervisory Board: Sonja Pierer Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.