From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SfcrA5w2vmrsLCMAWB0awg (envelope-from ) for ; Thu, 01 Oct 2026 06:31:56 -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=WmszNGUF; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 06DC41E051; Thu, 01 Oct 2026 06:31:56 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.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,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED 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 DD0F81E033 for ; Thu, 01 Oct 2026 06:31:54 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A832A4BB58F1 for ; Thu, 1 Oct 2026 10:31:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A832A4BB58F1 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=WmszNGUF Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by sourceware.org (Postfix) with ESMTPS id 446504BB590E for ; Thu, 1 Oct 2026 10:29:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 446504BB590E 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 446504BB590E Authentication-Results: sourceware.org; arc=none smtp.remote-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790850550; cv=none; b=BrWcYcub2QeG8RdL5CaexBV6BF6Yfbzl/my1A2gHDLeidfXW04m05BH2VDQOyuBKQa/zOV1T3u/1h+K3RycRfXo6Ksioo1rYNhU1dcW0FX2ykuxux6hettDnTadIguMT2qkUgug9fGyeG1RUqgCiqjBNwXu67dlhaxQMp322ErY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790850550; c=relaxed/simple; bh=NEtMEKwP7YOgZMSq8ykyukvntXWK+W24PYBBvWuBJNA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=dueDqYHSyZBMv+5H6P9OLEzm0Sjw5J5ZlJpxk1+lbpJ2NYE6PFHSKMnhY5w2wKS6Qr80GtKHDwJVKJEXnIgEJiznBhxSPNEqvCbuDk/6i68z5/uaZbu/WkoCl9ICMxvCIcYpTjAJbD4lCJV1SLB652twvApW2Gdzwe3VKW11auM= 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=WmszNGUF DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 446504BB590E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1790850551; x=1822386551; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=NEtMEKwP7YOgZMSq8ykyukvntXWK+W24PYBBvWuBJNA=; b=WmszNGUF0hWqUViO1ONSAgFNiBQUlOZ31HbIy5whQyf+pvD9SyW8Oc6k H0qWJbZet0ibh8tvZRXGSz2sVppL/fbzPDDCidxG8keLEork1Qec/yjuc n7LsYCcMZgEsVssqn/CDAsTjsoDzaTbKuYbYJdZ/vOS8RFvbKJY6xCWls Qg1JnUcCe5txxKNvx6iT0FRuT4Cq5wJZr/eP+JPb1Hrls877LY1CENC3W L8a63ZuHp+3jy0FqDuIHpKCurbaIVjnZkYqjnwMN9CpsxDePh3z5CdYB/ kgMm/8qox9fYlFUYO5G2gJIVf9o9FEUN1d9bMPDWH3vXjmU3NNAG5Uu7T g==; X-CSE-ConnectionGUID: GyXbkuJEQYC9VrjB9U9apg== X-CSE-MsgGUID: +y5lgNj3QCC8jgxB5Py5Ug== X-IronPort-AV: E=McAfee;i="6800,10657,11921"; a="91619631" X-IronPort-AV: E=Sophos;i="6.27,134,1787036400"; d="scan'208";a="91619631" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Oct 2026 03:29:04 -0700 X-CSE-ConnectionGUID: Lib+ij4oRUW5JPKdbh7bpA== X-CSE-MsgGUID: yFx/RW4eQGWLCSlK/JHRsA== X-ExtLoop1: 1 Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Oct 2026 03:29:03 -0700 From: Markus Metzger To: gdb-patches@sourceware.org Subject: [RFC PATCH 5/8] gdb, interp: repeat stop event when switching threads Date: Thu, 1 Oct 2026 12:28:44 +0200 Message-ID: <20261001102847.576880-6-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261001102847.576880-1-markus.t.metzger@intel.com> References: <20261001102847.576880-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 When switching threads back and forth and inspecting the state of various threads, one needs to note down the original stop reason or search for it in the console log when switching back to the eventing thread. GDB knows the stop reason, so why not print it again when switching back to the thread? We currently only print breakpoint stops. When the stop reason is printed, the location is printed as part of the stop reason without the frame level, whereas otherwise, the frame level would be printed. The MI interpreter printed thread-selected,id= when either USER_SELECTED_THREAD or USER_SELECTED_FRAME is specified. So it would print this thread information when only USER_SELECTED_FRAME is specified, which seems wrong to me. This behavior is covered by gdb.mi/user-selected-context-sync.exp, so I preserve it. It also printed the stack frame without checking USER_SELECTED_FRAME if the thread isn't running, which also seems wrong. --- gdb/cli/cli-interp.c | 29 ++++++++++++++++++++++++++--- gdb/mi/mi-interp.c | 42 ++++++++++++++++++++++++++++++++---------- 2 files changed, 58 insertions(+), 13 deletions(-) diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index 55892d2ce28..20b2ee906c3 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -166,9 +166,32 @@ cli_interp_base::on_user_selected_context_changed (user_selected_what selection) if (selection & USER_SELECTED_INFERIOR) print_selected_inferior (this->interp_ui_out ()); - if (tp != nullptr - && ((selection & (USER_SELECTED_THREAD | USER_SELECTED_FRAME)))) - print_selected_thread_frame (this->interp_ui_out (), selection); + if (tp == nullptr) + return; + + bool print_stop = false; + if (selection & USER_SELECTED_THREAD) + { + print_selected_thread_frame (this->interp_ui_out (), + USER_SELECTED_THREAD); + + if (selection & USER_SELECTED_FRAME) + { + /* Repeat any previous breakpoint stop notification. */ + print_stop = (bpstat_what (tp->control.stop_bpstat).main_action + == BPSTAT_WHAT_STOP_NOISY); + if (print_stop) + print_stop_event (this->interp_ui_out ()); + } + } + + if (selection & USER_SELECTED_FRAME) + { + /* Printing the stop notification already prints the frame. */ + if (!print_stop) + print_selected_thread_frame (this->interp_ui_out (), + USER_SELECTED_FRAME); + } } /* pre_command_loop implementation. */ diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index 207b1fc97ff..ccf66f7b58a 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -850,19 +850,41 @@ mi_interp::on_user_selected_context_changed (user_selected_what selection) if (selection & USER_SELECTED_INFERIOR) print_selected_inferior (this->cli_uiout); - if (tp != NULL - && (selection & (USER_SELECTED_THREAD | USER_SELECTED_FRAME))) + if (tp != NULL) { - print_selected_thread_frame (this->cli_uiout, selection); - - gdb_printf (this->event_channel, "thread-selected,id=\"%d\"", - tp->global_num); + if (selection & USER_SELECTED_THREAD) + { + print_selected_thread_frame (this->cli_uiout, + USER_SELECTED_THREAD); + + if (selection & USER_SELECTED_FRAME) + { + /* Repeat any previous breakpoint stop notification. */ + if (bpstat_what (tp->control.stop_bpstat).main_action + == BPSTAT_WHAT_STOP_NOISY) + print_stop_event (this->cli_uiout); + else + print_selected_thread_frame (this->cli_uiout, + USER_SELECTED_FRAME); + } + + gdb_printf (this->event_channel, "thread-selected,id=\"%d\"", + tp->global_num); + } - if (tp->state () != THREAD_RUNNING) + if (selection & USER_SELECTED_FRAME) { - if (has_stack_frames ()) - print_stack_frame_to_uiout (mi_uiout, get_selected_frame (), - 1, SRC_AND_LOC, 1); + if (!(selection & USER_SELECTED_THREAD)) + { + print_selected_thread_frame (this->cli_uiout, + USER_SELECTED_FRAME); + + gdb_printf (this->event_channel, "thread-selected,id=\"%d\"", + tp->global_num); + } + + print_selected_thread_frame (mi_uiout, + USER_SELECTED_FRAME); } } -- 2.53.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.