From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id AWeYCrV2fGpIlCAAWB0awg (envelope-from ) for ; Wed, 12 Aug 2026 09:35:49 -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=CJnTjl3c; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 270C71E033; Wed, 12 Aug 2026 09:35:49 -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 972461E033 for ; Wed, 12 Aug 2026 09:35:48 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3598B4B9DB70 for ; Wed, 12 Aug 2026 13:35:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3598B4B9DB70 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=CJnTjl3c Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by sourceware.org (Postfix) with ESMTPS id A7D1B4BB3B9D for ; Wed, 12 Aug 2026 13:29:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A7D1B4BB3B9D 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 A7D1B4BB3B9D 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=1786541355; cv=none; b=QvLnnRYv+VK9G5O3zmoNyzfNssk7sGlLc0l5dcPumYvLlfAK6A2NAs471PXd16xlMztlI8ncBnDgH3T8Xyi76D/BISFI/Fdx+hFT7DsfmFjNiNtE+1arcLA7ENqWl3KAcSMaIWd9pAK4vLfXYoAzt6sIgYk0I1cZc5/qdGR+MVU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786541355; c=relaxed/simple; bh=SsFWgIwBBaDeofON64jZelgp7qG6zPCkwBDcpdFxOuk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=wRvF+c2WroJ+PQAGPV8CwD8JiBnrGrJOR9DTnj4ZhiFntrkziwbIhNYWd5f7rNrOogK4HYU0G7AFyap+LOGu8DJ9n0/NS5is1yCWNLry/JuKKH3w0EhwneKO6bREgtlgeVqoH3So/0UKNjbzZSPW33tcBK4i7gwCB7oKnreynHM= 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=CJnTjl3c DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A7D1B4BB3B9D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1786541354; x=1818077354; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=SsFWgIwBBaDeofON64jZelgp7qG6zPCkwBDcpdFxOuk=; b=CJnTjl3cGZnCBF5gegWK4AyCtP1SloAmjdtGJRvnUys/zldNlS3zWYp6 yLTNTYzPMVu8ibKsAAXs4h5CyyyZ3e415SC4qb9NhDKoqjGkWgVlIKYpi wwcaxN4yOe7jDDn86ukJ2x/B5Jlyo8RY8eU223tR58hhuPu5CfH6+wqHS KawFDHJLEA70CSweRFLXZpZemqOvRnhV0BNTu6cDBFBDWrlFQq2hkbsIk AwAGSdQ3ZbMmcM362l0uDRdigivHz4gXpYbFhyagJwNxO2ol9P/ydGLGs ANla72lJwdppmMn5eTBelrCwnhC1yaDg0x8HmMNG8uZMBroX1xnu12GTS g==; X-CSE-ConnectionGUID: J4wPvCuLRgmn21EERHkl8Q== X-CSE-MsgGUID: ld8FDm4cSami+dz66QC7bw== X-IronPort-AV: E=McAfee;i="6800,10657,11872"; a="97757841" X-IronPort-AV: E=Sophos;i="6.25,219,1779174000"; d="scan'208";a="97757841" 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:14 -0700 X-CSE-ConnectionGUID: lSUwm+dlRmGBNMh9QPeaUQ== X-CSE-MsgGUID: JKnlru9yQUmZC5Pb6ZlShw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,219,1779174000"; d="scan'208";a="259817908" 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:13 -0700 From: Markus Metzger To: gdb-patches@sourceware.org Subject: [PATCH v4 21/44] gdb: allow creating and attaching to inferiors without threads Date: Wed, 12 Aug 2026 15:27:41 +0200 Message-ID: <20260812132805.380163-22-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 An Intel GPU device is modeled as an inferior and GPU software threads are modeled as threads. Software threads represent the work that has been dispatched to a GPU device. When a thread completes its work, it exits. When new work is dispatched to a GPU device, new software threads are created. In such a model, when no work is currently dispatched to a GPU device, we are left with the GPU inferior representing the GPU device but no threads. --- gdb/infcmd.c | 46 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 3e943123519..c2a860cb288 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -58,6 +58,7 @@ #include "cli/cli-style.h" #include "gdbsupport/selftest.h" #include "finish-thread-state.h" +#include "event-top.h" /* Local functions: */ @@ -383,18 +384,21 @@ post_create_inferior (int from_tty, bool set_pspace_solib_ops) /* Now that we know the register layout, retrieve current PC. But if the PC is unavailable (e.g., we're opening a core file with missing registers info), ignore it. */ - thread_info *thr = inferior_thread (); - - thr->clear_stop_pc (); - try - { - regcache *rc = get_thread_regcache (thr); - thr->set_stop_pc (regcache_read_pc (rc)); - } - catch (const gdb_exception_error &ex) + if (inferior_ptid != null_ptid) { - if (ex.error != NOT_AVAILABLE_ERROR) - throw; + thread_info *thr = inferior_thread (); + + thr->clear_stop_pc (); + try + { + regcache *rc = get_thread_regcache (thr); + thr->set_stop_pc (regcache_read_pc (rc)); + } + catch (const gdb_exception_error &ex) + { + if (ex.error != NOT_AVAILABLE_ERROR) + throw; + } } if (set_pspace_solib_ops) @@ -2905,6 +2909,26 @@ attach_command (const char *args, int from_tty) finished. */ target_terminal::inferior (); + /* If the attach does not create a thread, there's nothing to stop. + + Also leave setting up any inferior it created to the target. */ + if (inferior_ptid == null_ptid) + { + target_terminal::ours_for_output (); + + /* We disabled stdin in prepare_execution_command (). There won't + be any normal_stop () to enable them again. Do so now. */ + if (async_exec == 0) + { + SWITCH_THRU_ALL_UIS () + { + async_enable_stdin (); + } + } + + return; + } + inferior->needs_setup = true; if (target_is_non_stop_p ()) -- 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.