From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14900 invoked by alias); 28 Nov 2011 15:40:28 -0000 Received: (qmail 14787 invoked by uid 22791); 28 Nov 2011 15:40:27 -0000 X-SWARE-Spam-Status: Yes, hits=5.5 required=5.0 tests=AWL,BAYES_50,BOTNET,FROM_12LTRDOM,RDNS_DYNAMIC,TW_FC X-Spam-Check-By: sourceware.org Received: from bl22-166-20.dsl.telepac.pt (HELO localhost6.localdomain6) (2.83.166.20) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 28 Nov 2011 15:40:12 +0000 Received: from localhost6.localdomain6 (localhost.localdomain [127.0.0.1]) by localhost6.localdomain6 (8.14.4/8.14.4/Debian-2ubuntu1) with ESMTP id pASFe99r018116 for ; Mon, 28 Nov 2011 15:40:09 GMT Subject: [RFC/WIP PATCH 13/14] Make "thread apply all" only loop over threads in the current set To: gdb-patches@sourceware.org From: Pedro Alves Date: Mon, 28 Nov 2011 15:40:00 -0000 Message-ID: <20111128154009.17761.49348.stgit@localhost6.localdomain6> In-Reply-To: <20111128153742.17761.21459.stgit@localhost6.localdomain6> References: <20111128153742.17761.21459.stgit@localhost6.localdomain6> User-Agent: StGit/0.15 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-11/txt/msg00768.txt.bz2 This makes "thread apply all" only loop over threads in the current set instead of always all threads. That is, [all]> thread apply all printf "current thread is %d\n", $_thread Thread 3 (Thread 0x7ffff7028700 (LWP 30304)): current thread is 3 Thread 2 (Thread 0x7ffff7829700 (LWP 30303)): current thread is 2 Thread 1 (Thread 0x7ffff7fcb720 (LWP 30300)): current thread is 1 vs [all]> [1.1] thread apply all printf "current thread is %d\n", $_thread Thread 1 (Thread 0x7ffff7fcb720 (LWP 30300)): current thread is 1 I think it might make sense to make "info threads" only list threads of the current focus too. WDYT? --- gdb/thread.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gdb/thread.c b/gdb/thread.c index 846d2d3..55a64ac 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -46,6 +46,7 @@ #include "gdb_regex.h" #include "cli/cli-utils.h" #include "continuations.h" +#include "itset.h" /* Definition of struct thread_info exported to gdbthread.h. */ @@ -1199,8 +1200,8 @@ thread_apply_all_command (char *cmd, int from_tty) execute_command. */ saved_cmd = xstrdup (cmd); make_cleanup (xfree, saved_cmd); - for (tp = thread_list; tp; tp = tp->next) - if (thread_alive (tp)) + ALL_THREADS (tp) + if (itset_contains_thread (current_itset, tp) && thread_alive (tp)) { switch_to_thread (tp->ptid);