This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

improved thread id reporting


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 <http://gnu.org/licenses/gpl.html>
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:
<http://www.gnu.org/software/gdb/bugs/>...
(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 <http://gnu.org/licenses/gpl.html>
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:
<http://www.gnu.org/software/gdb/bugs/>...
(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) 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]