From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6234 invoked by alias); 19 Feb 2011 01:26:25 -0000 Received: (qmail 6224 invoked by uid 22791); 19 Feb 2011 01:26:24 -0000 X-SWARE-Spam-Status: No, hits=-4.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,TW_CP,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-outbound-1.vmware.com (HELO smtp-outbound-1.vmware.com) (65.115.85.69) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 19 Feb 2011 01:26:20 +0000 Received: from mailhost2.vmware.com (mailhost2.vmware.com [10.16.67.167]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id F3F6C1E001 for ; Fri, 18 Feb 2011 17:26:18 -0800 (PST) Received: from msnyder-server.eng.vmware.com (promd-2s-dhcp138.eng.vmware.com [10.20.124.138]) by mailhost2.vmware.com (Postfix) with ESMTP id E778E8EEBA for ; Fri, 18 Feb 2011 17:26:18 -0800 (PST) Message-ID: <4D5F1C3A.7000403@vmware.com> Date: Sat, 19 Feb 2011 02:18:00 -0000 From: Michael Snyder User-Agent: Thunderbird 2.0.0.24 (X11/20101201) MIME-Version: 1.0 To: "gdb-patches@sourceware.org" Subject: [commit] Simplify "thread apply" with get_number_or_range Content-Type: multipart/mixed; boundary="------------000203040905090408040906" 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-02/txt/msg00506.txt.bz2 This is a multi-part message in MIME format. --------------000203040905090408040906 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 77 I love this. I'm going to look for other commands to which it could apply. --------------000203040905090408040906 Content-Type: text/plain; name="getnum2.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="getnum2.txt" Content-length: 2384 2011-02-18 Michael Snyder * thread.c (thread_apply_command): Re-implement using get_number_or_range. Index: thread.c =================================================================== RCS file: /cvs/src/src/gdb/thread.c,v retrieving revision 1.134 diff -u -p -u -p -r1.134 thread.c --- thread.c 19 Feb 2011 01:02:56 -0000 1.134 +++ thread.c 19 Feb 2011 01:22:56 -0000 @@ -1212,7 +1212,6 @@ static void thread_apply_command (char *tidlist, int from_tty) { char *cmd; - char *p; struct cleanup *old_chain; char *saved_cmd; @@ -1231,51 +1230,29 @@ thread_apply_command (char *tidlist, int while (tidlist < cmd) { struct thread_info *tp; - int start, end; + int start; + char *p = tidlist; - start = strtol (tidlist, &p, 10); - if (p == tidlist) - error (_("Error parsing %s"), tidlist); - tidlist = p; + start = get_number_or_range (&tidlist); - while (*tidlist == ' ' || *tidlist == '\t') - tidlist++; + make_cleanup_restore_current_thread (); - if (*tidlist == '-') /* Got a range of IDs? */ - { - tidlist++; /* Skip the - */ - end = strtol (tidlist, &p, 10); - if (p == tidlist) - error (_("Error parsing %s"), tidlist); - tidlist = p; + tp = find_thread_id (start); - while (*tidlist == ' ' || *tidlist == '\t') - tidlist++; - } + if (!tp) + warning (_("Unknown thread %d."), start); + else if (!thread_alive (tp)) + warning (_("Thread %d has terminated."), start); else - end = start; - - make_cleanup_restore_current_thread (); - - for (; start <= end; start++) { - tp = find_thread_id (start); + switch_to_thread (tp->ptid); - if (!tp) - warning (_("Unknown thread %d."), start); - else if (!thread_alive (tp)) - warning (_("Thread %d has terminated."), start); - else - { - switch_to_thread (tp->ptid); + printf_filtered (_("\nThread %d (%s):\n"), tp->num, + target_pid_to_str (inferior_ptid)); + execute_command (cmd, from_tty); - printf_filtered (_("\nThread %d (%s):\n"), tp->num, - target_pid_to_str (inferior_ptid)); - execute_command (cmd, from_tty); - - /* Restore exact command used previously. */ - strcpy (cmd, saved_cmd); - } + /* Restore exact command used previously. */ + strcpy (cmd, saved_cmd); } } --------------000203040905090408040906--