From patchwork Mon May 18 18:33:02 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bouhaouel, Mohamed" X-Patchwork-Id: 135222 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EF6B14BB3B82 for ; Mon, 18 May 2026 18:35:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EF6B14BB3B82 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=K3zi2216 X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by sourceware.org (Postfix) with ESMTPS id A6EAE4BB24E1 for ; Mon, 18 May 2026 18:35:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A6EAE4BB24E1 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 A6EAE4BB24E1 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1779129307; cv=none; b=iTwPbBXxwJiCRCAlDma7jLZbyGUw1crSQy+govGY9MIwCSYLvWv29qWC2ZilpS5RVY7j2qc7zROQev+J2MPaPlwSHHmeA+zCGaRoegC0gi2zRKzCV58+PN6PApFKRT3rfmmLKAWnU5UQP9zmt4nAb4TFmCqCd/rockONhzxLQms= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1779129307; c=relaxed/simple; bh=rkVe70BV7EsCcU5ZkixZWryRXzQd5asotyDdy83FgSs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=WQH1RYfJVV9rnCcjwJTfb9vfMKsFett4B7rtMpMdCFJwVv3Q+uO3w/cx38Q0GwlsoyAHg7kglx4b8eSDahu4iB2D/zXZv8SNYb/UsEsOx/yTJdligLkD3IMUnMzzmDO8QShqOCnCuVh2sBg81mRCsUEaeO8S3rgONunttP1C45o= 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=K3zi2216 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A6EAE4BB24E1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1779129308; x=1810665308; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rkVe70BV7EsCcU5ZkixZWryRXzQd5asotyDdy83FgSs=; b=K3zi2216JQE/bYLnRDTusIEcEA4NUxwx01GtjN7XHhcp1amesGReCcey h3fxGNLu0/+XRQc6xR12IRTD69jcMN8CQcEYyKUyNAYJKPPIfifSwuFQk tnTxOiQr0xASpX8JJBEm2J81MJs2V33+GPreN3mPtEQTtK2F9q2dT70iy ZBEXjsLVQiALG7HXbe3e6LSzQNZ+unSZPSaUJ8vScqjNpO+tsEv0l0dJQ X0Z+WjyT/cigN8/agngjcwgtxhRY2FdV9BLh2wVVTq0rVLs91aEP753H4 xWJ+Ckgq/3op7q43NExxmAnhTp1LlGKHsbSR156SmcGdFbmr3vHdHT8eJ w==; X-CSE-ConnectionGUID: dNO5vmbnSDKLhqaXOtuNNQ== X-CSE-MsgGUID: +KkGvkVZToyaNj2EIqHljA== X-IronPort-AV: E=McAfee;i="6800,10657,11790"; a="80112189" X-IronPort-AV: E=Sophos;i="6.23,242,1770624000"; d="scan'208";a="80112189" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2026 11:35:07 -0700 X-CSE-ConnectionGUID: EduFaReKT0q+s7gh9Ucanw== X-CSE-MsgGUID: zruPDrGqQHmX4VM2VdbZDg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,242,1770624000"; d="scan'208";a="277619653" Received: from cwhite-mobl.ger.corp.intel.com (HELO localhost) ([10.245.114.180]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2026 11:35:05 -0700 From: Mohamed Bouhaouel To: gdb-patches@sourceware.org Cc: mohamed.bouhaouel@intel.com, stephan.rohr@intel.com, markus.t.metzger@intel.com Subject: [PATCH 06/11] gdb, remote: fix ptid matching for process-wide stop events Date: Mon, 18 May 2026 20:33:02 +0200 Message-ID: <20260518183316.127043-7-mohamed.bouhaouel@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260518183316.127043-1-mohamed.bouhaouel@intel.com> References: <20260518183316.127043-1-mohamed.bouhaouel@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org 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~patchwork=sourceware.org@sourceware.org From: "Rohr, Stephan" If an inferior call results in a process event for a non-stop remote target, GDB does not properly handle the event but is hanging. This reproduces with 'gdb.base/exit-in-condition.exp'. Because GDB is evaluating a breakpoint condition, the corresponding inferior call is evaluated w.r.t. the ptid of the current thread. gdbserver sends a process exit event; the event is not matched by the thread PTID and GDB hangs. Fix this by matching a process event in 'stop_reply_queue' if there is no matching thread event. This ensures a thread event is prioritized if both a thread event and a process event are queued and preserves the current behavior. --- gdb/remote.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gdb/remote.c b/gdb/remote.c index 94ea4466c17..92fe518c6de 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -8363,6 +8363,20 @@ remote_target::remote_notif_remove_queued_reply (ptid_t ptid) { return event->ptid.matches (ptid); }); + + /* Match process events if PTID is a thread and there is no matching event + queued. Prioritize thread events to preserve the existing behavior. */ + if (iter == rs->stop_reply_queue.end () + && ptid != minus_one_ptid + && !ptid.is_pid ()) + iter = std::find_if (rs->stop_reply_queue.begin (), + rs->stop_reply_queue.end (), + [=] (const stop_reply_up &event) + { + return (event->ptid.is_pid () + && event->ptid.pid () == ptid.pid ()); + }); + stop_reply_up result; if (iter != rs->stop_reply_queue.end ()) {