From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9513 invoked by alias); 4 Feb 2010 11:35:56 -0000 Received: (qmail 9501 invoked by uid 22791); 4 Feb 2010 11:35:55 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00 X-Spam-Check-By: sourceware.org Received: from mail169.messagelabs.com (HELO mail169.messagelabs.com) (85.158.138.179) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Thu, 04 Feb 2010 11:35:51 +0000 X-VirusChecked: Checked X-Env-Sender: scott.harrison@tandberg.com X-Msg-Ref: server-5.tower-169.messagelabs.com!1265283347!44000032!1 X-StarScan-Version: 6.2.4; banners=-,-,- Received: (qmail 24935 invoked from network); 4 Feb 2010 11:35:47 -0000 Received: from unknown (HELO OSLEXCP11.eu.tandberg.int) (62.70.2.252) by server-5.tower-169.messagelabs.com with SMTP; 4 Feb 2010 11:35:47 -0000 Received: from ultra.eu.tandberg.int ([10.47.1.15]) by OSLEXCP11.eu.tandberg.int with Microsoft SMTPSVC(6.0.3790.3959); Thu, 4 Feb 2010 12:35:44 +0100 Received: from ukdev-lin-sha.tandberg.com (ukdev-lin-sha.uk.rd.tandberg.com [10.44.13.146]) by ultra.eu.tandberg.int (8.13.1/8.13.1) with SMTP id o14BZhpD019777 for ; Thu, 4 Feb 2010 12:35:44 +0100 Received: by ukdev-lin-sha.tandberg.com (Postfix, from userid 1000) id AB38A1640; Thu, 4 Feb 2010 11:35:43 +0000 (GMT) Date: Thu, 04 Feb 2010 11:35:00 -0000 From: scott.harrison@tandberg.com To: gdb-patches@sourceware.org Subject: New feature: allow thread command to take a LWPID. Message-ID: <20100204113543.GB2704@tandberg.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="fUYQa+Pmc3FrFX/N" Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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: 2010-02/txt/msg00108.txt.bz2 --fUYQa+Pmc3FrFX/N Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Content-length: 983 All, We script GDB to attach to our application when it crashes and generate a crash report giving lots of valuable information for developers to debug the problem. Before invoking GDB we know the LWPID and the PID so we attach to the PID (--pid), however, currently GDB only knows about its own threadids, we don't know this before invoking GDB but our script is already written, so I have created a small patch to the "thread" command to take a % option, and swtich to that thread. We thought you might be interested. Changelog --------- 2010-02-04 Scott Harrison * gdb/thread.c: Add support for LWPID to the thread command. Patch is attached. I realise that this patch may not be applicable to all platforms that gdb is used on, sorry. Kind regards, Scott Harrison --- TANDBERG Telecom UK Ltd Registered in England and Wales No: 3390345. Registered address: Unit 2 Pine Trees, Chertsey Lane, Staines, Middlesex, TW18 3HR --fUYQa+Pmc3FrFX/N Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="gdb-tid.patch" Content-length: 1075 diff -Nru gdb-7.0.1/gdb/thread.c gdb-7.0.1-1/gdb/thread.c --- gdb-7.0.1/gdb/thread.c 2009-09-13 17:28:28.000000000 +0100 +++ gdb-7.0.1-1/gdb/thread.c 2010-02-03 17:01:26.000000000 +0000 @@ -311,6 +311,18 @@ return NULL; } +struct thread_info * +find_thread_lwp (int num) +{ + struct thread_info *tp; + + for (tp = thread_list; tp; tp = tp->next) + if (tp->ptid.lwp == num) + return tp; + + return NULL; +} + /* Find a thread_info by matching PTID. */ struct thread_info * find_thread_ptid (ptid_t ptid) @@ -1164,11 +1176,19 @@ do_captured_thread_select (struct ui_out *uiout, void *tidstr) { int num; + char *tidstring=(char *)tidstr; struct thread_info *tp; - num = value_as_long (parse_and_eval (tidstr)); - - tp = find_thread_id (num); + if (tidstring[0] == '%') + { + num = value_as_long (parse_and_eval ((void *)(tidstring+1))); + tp = find_thread_lwp (num); + } + else + { + num = value_as_long (parse_and_eval (tidstr)); + tp = find_thread_id (num); + } if (!tp) error (_("Thread ID %d not known."), num); --fUYQa+Pmc3FrFX/N--