From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 6RvACerVKmo/tAEAWB0awg (envelope-from ) for ; Thu, 11 Jun 2026 11:36:10 -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=Nz2UH3ez; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 232EF1E070; Thu, 11 Jun 2026 11:36: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=-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 86EC81E070 for ; Thu, 11 Jun 2026 11:36:09 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6A1914BA799F for ; Thu, 11 Jun 2026 15:36:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A1914BA799F 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=Nz2UH3ez Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by sourceware.org (Postfix) with ESMTPS id 4323F4BA23CA for ; Thu, 11 Jun 2026 15:35:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4323F4BA23CA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=tempfail smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4323F4BA23CA Authentication-Results: sourceware.org; arc=none smtp.remote-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1781192108; cv=none; b=JqJVuMzUyKUfCT+Nz74G60lWqPzZ742XTK3KGWMrtF7aysmjzvbhH2PZp4cBWEdmFmkGzVW3G0RWsNTp/QmedUACzgFlp7kjnP71d6DJu7M5CGxLW34ouTwL6Pimcv46g8OgzkYnUWijBuQMKS9TguhuNB8kFdxGoOmPihdBjTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1781192108; c=relaxed/simple; bh=8y2IMoGCQM0qFtDKTYGKEyYXcd5+wrppnH05onUTbs8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=EYOFdMYhxK4IsfIy2vSQaPBwHNNU5E5jMFe9Q5lJ814NN6rA+sd7SWi0Ot0n+Mq49jCoaIfAYm9wY/agnfGkDPQkwJkuv/Kp01yF84fNQXSAxm6pv0I2ol3Nz0PGVDM3iFx8LWanwtuLI60NUNNsbNNjqsJwj67x7k1Qg6u9dIw= 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=Nz2UH3ez DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4323F4BA23CA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1781192103; x=1812728103; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8y2IMoGCQM0qFtDKTYGKEyYXcd5+wrppnH05onUTbs8=; b=Nz2UH3ezVcXT3vGYqcxhWeJY9XubG3gxjI+Pz3mx7Y2uX5+F2UVfYNwQ DbvlGgd3Ux/TVMn9Bi+WZLn6kDETyOe8jsbixRdWjglC4dqqXsnLsbBaO MesLJLMUoQWrYdZ26Hd5v28URNlgQjEtt5lO1ykNfE2Idyxr+e5uO10tg E7f9sxsN0e3URm2qlnZX0gcrFY/LI7HHYPVA+j1+pUr7M7b/e15UH54q3 IAJ+eDuBSHdmPAY/o1axMX3tNj0SiDVaD2xSmTOIOVIPlo67v5h75SeuU mJpCsxiO/vXx9KArp0on12QUOltAErrRjmNIoHWKGYtjHungzP9YnDA55 g==; X-CSE-ConnectionGUID: lI2OnHoiQsKXQZzM66HVnQ== X-CSE-MsgGUID: 2uv1WIKLQUCKILJKj0BRXg== X-IronPort-AV: E=McAfee;i="6800,10657,11813"; a="104675631" X-IronPort-AV: E=Sophos;i="6.24,199,1774335600"; d="scan'208";a="104675631" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2026 08:35:02 -0700 X-CSE-ConnectionGUID: KgqE9sNfSkeRBsQIIrgmsg== X-CSE-MsgGUID: SKWJjqeaSrGe+UCcLvatpg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.24,199,1774335600"; d="scan'208";a="246597021" Received: from womilian-mobl.ger.corp.intel.com (HELO localhost) ([10.245.82.28]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2026 08:35:00 -0700 From: Mohamed Bouhaouel To: gdb-patches@sourceware.org Cc: markus.t.metzger@intel.com, stephan.rohr@intel.com, aburgess@redhat.com, mohamed.bouhaouel@intel.com Subject: [PATCH v2 07/11] gdb, dap: fix DAP events if no thread is selected Date: Thu, 11 Jun 2026 17:32:27 +0200 Message-ID: <20260611153232.3011-8-mohamed.bouhaouel@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260611153232.3011-1-mohamed.bouhaouel@intel.com> References: <20260611153232.3011-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