From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18620 invoked by alias); 4 Apr 2009 18:46:18 -0000 Received: (qmail 18612 invoked by uid 22791); 4 Apr 2009 18:46:16 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 04 Apr 2009 18:46:10 +0000 Received: from spaceape13.eur.corp.google.com (spaceape13.eur.corp.google.com [172.28.16.147]) by smtp-out.google.com with ESMTP id n34Ik6E3006052 for ; Sat, 4 Apr 2009 19:46:07 +0100 Received: from localhost (ruffy.mtv.corp.google.com [172.18.118.116]) by spaceape13.eur.corp.google.com with ESMTP id n34Ik5N3019410 for ; Sat, 4 Apr 2009 11:46:05 -0700 Received: by localhost (Postfix, from userid 67641) id 8524C1C759C; Sat, 4 Apr 2009 11:46:04 -0700 (PDT) To: gdb@sourceware.org Subject: improved thread id reporting Message-Id: <20090404184604.8524C1C759C@localhost> Date: Sat, 04 Apr 2009 19:06:00 -0000 From: dje@google.com (Doug Evans) X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-04/txt/msg00046.txt.bz2 Hi. GDB's current reporting of thread ids has (at least) three problems (IMO): 1) Reporting the pthread id (e.g. 0x0xf7e5cbb0) has a very low S/N ratio. 2) When switching to a thread IWBN to also report the thread being switched from, otherwise one has to scrollback through the session to find it (assuming that's even possible). 3) When reporting thread ids the only usable number in the gdb session (gdb's internal thread number) is not included. To fix (1) I'd like to simply remove the pthread id from the output. This would be user selectable of course, and for example when using MI I'd expect that it shouldn't be changed lest the frontend get confused, but friendly reporting of thread ids in frontends is the frontend's job anyway. To fix (2) I propose to change "Switch to Thread ..." to "Switching to Thread ... from Thread ...". To fix (3) I propose to include gdb's thread number in "[New Thread ...]" and "[Switching to Thread ...]" messages. Actually implementing this may be a challenge but I think the improvement is usability for the user warrants it. [E.g. This change shouldn't affect non-threaded targets (e.g. embedded).] Comments? Example: Before: gdb$ ./gdb.prev -nx testsuite/gdb.threads/interrupted-hand-call GNU gdb (GDB) 6.8.50.20090404-cvs Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-linux". For bug reporting instructions, please see: ... (gdb) b thread_entry Breakpoint 1 at 0x8048319: file ../../../../src/gdb/testsuite/gdb.threads/interrupted-hand-call.c, line 77. (gdb) r Starting program: /usr/local/g3/gnu/sourceware/thread-id/build/obj32/gdb/testsuite/gdb.threads/interrupted-hand-call [Thread debugging using libthread_db enabled] [New Thread 0xf7e5cbb0 (LWP 17858)] [Switching to Thread 0xf7e5cbb0 (LWP 17858)] Breakpoint 1, thread_entry (unused=0x0) at ../../../../src/gdb/testsuite/gdb.threads/interrupted-hand-call.c:77 77 incr_thread_count (); (gdb) c Continuing. [New Thread 0xf765bbb0 (LWP 17859)] [Switching to Thread 0xf765bbb0 (LWP 17859)] Breakpoint 1, thread_entry (unused=0x0) at ../../../../src/gdb/testsuite/gdb.threads/interrupted-hand-call.c:77 77 incr_thread_count (); (gdb) i thr [New Thread 0xf6e5abb0 (LWP 17862)] 4 Thread 0xf6e5abb0 (LWP 17862) 0xf7f27748 in clone () from /usr/grte/v1/lib/libc.so.6 * 3 Thread 0xf765bbb0 (LWP 17859) thread_entry (unused=0x0) at ../../../../src/gdb/testsuite/gdb.threads/interrupted-hand-call.c:77 2 Thread 0xf7e5cbb0 (LWP 17858) 0xffffe410 in __kernel_vsyscall () 1 Thread 0xf7e5d6b0 (LWP 17855) 0xf7f27748 in clone () from /usr/grte/v1/lib/libc.so.6 (gdb) After: [slightly different due to different o/s scheduling of threads, but you get the idea] gdb$ ./gdb -nx testsuite/gdb.threads/interrupted-hand-call GNU gdb (GDB) 6.8.50.20090404-cvs Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-linux". For bug reporting instructions, please see: ... (gdb) b thread_entry Breakpoint 1 at 0x8048319: file ../../../../src/gdb/testsuite/gdb.threads/interrupted-hand-call.c, line 77. (gdb) r Starting program: /usr/local/g3/gnu/sourceware/thread-id/build/obj32/gdb/testsuite/gdb.threads/interrupted-hand-call [Thread debugging using libthread_db enabled] [New Thread #2, LWP 17626] [New Thread #3, LWP 17627] [Switching to Thread #2, LWP 17626 from Thread #1, LWP 17626] Breakpoint 1, thread_entry (unused=0x0) at ../../../../src/gdb/testsuite/gdb.threads/interrupted-hand-call.c:77 77 incr_thread_count (); (gdb) c Continuing. [Switching to Thread #3, LWP 17627 from Thread #2, LWP 17627] Breakpoint 1, thread_entry (unused=0x0) at ../../../../src/gdb/testsuite/gdb.threads/interrupted-hand-call.c:77 77 incr_thread_count (); (gdb) i thr [New Thread #4, LWP 17628] 4 LWP 17628 0xffffe410 in __kernel_vsyscall () * 3 LWP 17627 thread_entry (unused=0x0) at ../../../../src/gdb/testsuite/gdb.threads/interrupted-hand-call.c:77 2 LWP 17626 0xffffe410 in __kernel_vsyscall () 1 LWP 17623 0xf7fb9730 in __nptl_create_event () from /usr/grte/v1/lib/libpthread.so.0 (gdb)