From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id OYziF0MAVmpWiQcAWB0awg (envelope-from ) for ; Tue, 14 Jul 2026 05:24:19 -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=JtwPZaSU; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 571BF1E09E; Tue, 14 Jul 2026 05:24:19 -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 4CDC31E099 for ; Tue, 14 Jul 2026 05:24:18 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B061B4BA2E1D for ; Tue, 14 Jul 2026 09:24:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B061B4BA2E1D 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=JtwPZaSU Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) by sourceware.org (Postfix) with ESMTPS id 475874BA2E05 for ; Tue, 14 Jul 2026 09:22:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 475874BA2E05 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 475874BA2E05 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784020948; cv=none; b=r/AQwmyTslyUzp2rYS+NEfsjmCrAivTLs0L0h7TZJb6HmDmULEZpJiwUVgM8dJrrJpfDHRXc+v+TkTS5fhLp2CmFkPjCqEua/fZSiEanlewLoBOGuUR0qu4qyWP4W372rLbn0RTp7HG5PQRzX/t/eItca2lckNJnp7/TuXdE8qg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784020948; c=relaxed/simple; bh=8y2IMoGCQM0qFtDKTYGKEyYXcd5+wrppnH05onUTbs8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=XnYo7lo+jWdHzPwh/m/7q35kI4Ulgv8Gt/jYRtysp7h8Kb3eGqPy1+YUy9DILzuWZUbLjtkohE74nwG+J21Oi9wwSbR84Is0a/q91lo3cjqX78UmTyHVYyTVNr2KW6dKDI2gWuXuhB9YRCi6j8oltNlT/LDaINJBJWGTrMuqxq8= 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=JtwPZaSU DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 475874BA2E05 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1784020943; x=1815556943; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8y2IMoGCQM0qFtDKTYGKEyYXcd5+wrppnH05onUTbs8=; b=JtwPZaSUN+3JViWVNRL1pO2tt7g5qtZxJlLDgjuI1TTXahwf6/w6JEcb Nkbb6TXVCnpXopzwBLif/Lm34D5uJLtsUnhtV2OpmlLTNpJsRb9T3U5IJ YJRHxwFKS+Zliw7WY5ofmUd9Iq22Zo74iOUXdWDRI7bi/naCUkonNsWft e4/a85Lgn7IPx8z89L5zH7arVOmsKHAesSfGNz2TjXiAitAczaDhJEpqD X6CWjZMpIIFKxeO41IVHw/ADLSRCXBjg64hgeZw7NkLTj6q6vldAaPGMv ZoRIUdpL2LXjkgbFh9KgHXycQBVPyU8WUpe0ooeRrvGriCck5NrxqLvUZ A==; X-CSE-ConnectionGUID: rplQEFL/QcKwWxu0hPzmZw== X-CSE-MsgGUID: Vt6D+Sf7Qkuil5TyFI3Rew== X-IronPort-AV: E=McAfee;i="6800,10657,11846"; a="88537968" X-IronPort-AV: E=Sophos;i="6.25,163,1779174000"; d="scan'208";a="88537968" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2026 02:22:22 -0700 X-CSE-ConnectionGUID: 66PcPajZS3SJxQPiQdR7zQ== X-CSE-MsgGUID: tJxb97rKSFWQz9MZxGoQ3A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,163,1779174000"; d="scan'208";a="293998161" Received: from sguenant-mobl2.ger.corp.intel.com (HELO localhost) ([10.246.18.94]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2026 02:22:20 -0700 From: Mohamed Bouhaouel To: gdb-patches@sourceware.org Cc: markus.t.metzger@intel.com, stephan.rohr@intel.com, eliz@gnu.org, aburgess@redhat.com, pedro@palves.net Subject: [PATCH v4 07/11] gdb, dap: fix DAP events if no thread is selected Date: Tue, 14 Jul 2026 11:21:24 +0200 Message-ID: <20260714092128.12941-8-mohamed.bouhaouel@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260714092128.12941-1-mohamed.bouhaouel@intel.com> References: <20260714092128.12941-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