From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id YYLrNhGcS2pKvCkAWB0awg (envelope-from ) for ; Mon, 06 Jul 2026 08:14: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=OIISSpTa; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id DCA6C1E098; Mon, 06 Jul 2026 08:14: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 [38.145.34.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 5B0BE1E070 for ; Mon, 06 Jul 2026 08:14:09 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EA2734BA2E16 for ; Mon, 6 Jul 2026 12:14:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EA2734BA2E16 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=OIISSpTa Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) by sourceware.org (Postfix) with ESMTPS id B7E2A4BA2E19 for ; Mon, 6 Jul 2026 12:13:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B7E2A4BA2E19 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 B7E2A4BA2E19 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783340009; cv=none; b=YMvxHMn06aFQ06BCD+9SJxVb1j7hUw3KEFDGA64ocT8T+ijoDhMSULpQzl94jt4G3z7sTtTZzlOhhynm6ogXDjhnghHN4t1bjsyB2yctZzK8qVoG2EaHrWkhC55hvO047cCY2zlR4t20dLiuNBTRUoCBwHpteQLMs2d+H1otbZg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783340009; c=relaxed/simple; bh=8y2IMoGCQM0qFtDKTYGKEyYXcd5+wrppnH05onUTbs8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qc/JGd1yGSXHZzzgqppEKcBFHZwLBl8hGm/3glB0uwodx4xNauJe1JPpuhvCwYCkDUO+Ad6uQbH6UyDf3XyKGACV0NSLipiHHSy+fQInpxQNXVIe4mJBR+e28cS8vO+Ql3MOxoB33CZlN30K9EEmFeUJaag/H+ohr3+tK11zzcY= 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=OIISSpTa DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B7E2A4BA2E19 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1783340009; x=1814876009; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8y2IMoGCQM0qFtDKTYGKEyYXcd5+wrppnH05onUTbs8=; b=OIISSpTa7Xe0P6iJgtsUZE2Y+8e6KmQ6gomrrgyznqtm/xCHYp6KsPPt QFTkI6o/ykOpYIuxCWsdrqb6v7JL0xvWBeEiZDn9pFQV6Tns3CdaQnOa3 sMhyN8l+g7RIbvZ8CQlH9y7sOZn0JkTGwWCcb5GYR7B7I3KdQRN5/6e0i 0C72zwgACU4PBLdH6wF716Y8edTJxrLtE5n3uVEvt01Mc11eZ8BXixJMF BGRbIaGCbtjKHScxs190juuaNK/GndrLQS4KgMFU7BL/J0kw+t827tTA5 FCAUHOz0YHB3HLQQD1KvZqtIjHVrdZDIfh4hPfKr3mzt+7PhzEdoajrTQ A==; X-CSE-ConnectionGUID: IdP71WGaRg2VlNPIGfQTtA== X-CSE-MsgGUID: kI2kSmR9S6q+yV/odgIydQ== X-IronPort-AV: E=McAfee;i="6800,10657,11838"; a="101516741" X-IronPort-AV: E=Sophos;i="6.25,149,1779174000"; d="scan'208";a="101516741" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2026 05:13:27 -0700 X-CSE-ConnectionGUID: 5hkI6wBBQxus90o89A2mQg== X-CSE-MsgGUID: 6XJ08SdeQP6c5KF13lfXxw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,149,1779174000"; d="scan'208";a="251015936" Received: from unknown (HELO localhost) ([10.245.114.180]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2026 05:13:26 -0700 From: Mohamed Bouhaouel To: gdb-patches@sourceware.org Cc: stephan.rohr@intel.com, markus.t.metzger@intel.com, pedro@palves.net, aburgess@redhat.com Subject: [PATCH v3 07/11] gdb, dap: fix DAP events if no thread is selected Date: Mon, 6 Jul 2026 14:11:20 +0200 Message-ID: <20260706121124.18784-8-mohamed.bouhaouel@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260706121124.18784-1-mohamed.bouhaouel@intel.com> References: <20260706121124.18784-1-mohamed.bouhaouel@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 From: "Rohr, Stephan" The DAP protocol requires a thread-id for a continue event. It is optional for the stopped event. If we force the remote target to run in non-stop mode, i.e., "-iex maint set target-non-stop on", GDB does not have a thread selected. Default to '0' for continue events in this case. Omit the 'threadID' for stopped events if no thread is selected. Reproducible when running gdb.dap/remote-dap.exp on unix with target-non-stop enabled. export GDBFLAGS="-iex \"maint set target-non-stop on\"" make check TESTS="gdb.dap/remote-dap.exp" \ RUNTESTFLAGS="--target_board=unix GDBFLAGS='$GDBFLAGS'" --- gdb/python/lib/gdb/dap/events.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/gdb/python/lib/gdb/dap/events.py b/gdb/python/lib/gdb/dap/events.py index 27e3b5ab8bc..85e672b4c9e 100644 --- a/gdb/python/lib/gdb/dap/events.py +++ b/gdb/python/lib/gdb/dap/events.py @@ -138,10 +138,14 @@ def _cont(event): log("_suppress_cont case") _suppress_cont = False else: + thread = gdb.selected_thread() + + # We may not have a selected thread if the target is running in + # non-stop mode. Default to '0' in this case. send_event( "continued", { - "threadId": gdb.selected_thread().global_num, + "threadId": thread.global_num if thread else 0, "allThreadsContinued": True, }, ) @@ -213,9 +217,11 @@ def _on_stop(event): if hasattr(event, "details"): log(" details: " + repr(event.details)) obj = { - "threadId": gdb.selected_thread().global_num, "allThreadsStopped": True, } + # The thread-id parameter is optional for stopped events. + if gdb.selected_thread(): + obj["threadId"] = gdb.selected_thread().global_num if isinstance(event, gdb.BreakpointEvent): obj["hitBreakpointIds"] = [x.number for x in event.breakpoints] if hasattr(event, "details") and "finish-value" in event.details: @@ -266,11 +272,14 @@ def _on_inferior_call(event): if not _infcall_was_running and inferior_running: inferior_running = False obj = { - "threadId": gdb.selected_thread().global_num, "allThreadsStopped": True, # DAP says any string is ok. "reason": "function call", } + # The thread-id parameter is optional for stopped events. + if gdb.selected_thread(): + obj["threadId"] = gdb.selected_thread().global_num + global _expected_pause _expected_pause = False send_event("stopped", obj) -- 2.43.0 Intel Deutschland GmbH Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany Tel: +49 89 991 430, www.intel.de Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell Chairperson of the Supervisory Board: Nicole Lau Registered Seat: Munich Commercial Register: Amtsgericht Muenchen HRB 186928