Bug 66115 - attach to multithreaded process does not show threads in Frame Stack
Summary: attach to multithreaded process does not show threads in Frame Stack
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: CPP Debugger (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: KDevelop Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-16 15:42 UTC by Chris Halls
Modified: 2003-10-17 21:21 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Proposed fix for problem (1.14 KB, patch)
2003-10-16 15:43 UTC, Chris Halls
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Halls 2003-10-16 15:42:11 UTC
Version:           unknown (using KDE 3.1.4)
Installed from:     (testing/unstable)
Compiler:          gcc version 3.3.2 20030908 (Debian prerelease)
OS:          Linux (i686) release 2.4.22-1-686-smp

Attaching to an existing program with multiple threads only shows one thread in the Frame Stack.  This is because 'info threads' can only be requested from gdb after the 'backtrace' command 

(gdb) attach 19622 

[previous behaviour requests info thread here.. threads not shown yet]

(gdb) backtrace 
[New Thread 16384 (LWP 19622)]
[New Thread 32769 (LWP 19623)]
[New Thread 16386 (LWP 19624)]
[New Thread 32771 (LWP 19625)]
...

[now we can request info thread.]

(gdb) info thread 
  4 Thread 32771 (LWP 19625)  0x4114f364 in __pthread_sigsuspend () from /lib/libpthread.so.0
  3 Thread 16386 (LWP 19624)  0x4114f364 in __pthread_sigsuspend () from /lib/libpthread.so.0
  2 Thread 32769 (LWP 19623)  0x410e6666 in poll () from /lib/libc.so.6
  1 Thread 16384 (LWP 19622)  0x4114f364 in __pthread_sigsuspend () from /lib/libpthread.so.0
Comment 1 Chris Halls 2003-10-16 15:43:52 UTC
Created attachment 2789 [details]
Proposed fix for problem

This fixes the problem on my system.  Tested with gdb 5.3 and 6.0.
Comment 2 Thiago Macieira 2003-10-17 00:15:03 UTC
Can't confirm your behaviour:

$ gdb /usr/local/kde3/bin/kdeinit
GNU gdb 5.3
[...]
(gdb) attach 131801
[...]
Reading symbols from /lib/libpthread.so.0...done.
[New Thread 16384 (LWP 131801)]
[New Thread 32769 (LWP 131802)]
[New Thread 16386 (LWP 131803)]
Loaded symbols for /lib/libpthread.so.0
[...]
0x415590e1 in select () from /lib/libc.so.6
(gdb) info threads
  3 Thread 16386 (LWP 131803)  0x414b0f56 in sigsuspend () from /lib/libc.so.6
  2 Thread 32769 (LWP 131802)  0x41557173 in poll () from /lib/libc.so.6
  1 Thread 16384 (LWP 131801)  0x415590e1 in select () from /lib/libc.so.6

(I made all non-trivial KDE applications multithreaded)
Comment 3 Chris Halls 2003-10-17 11:12:52 UTC
Yes, you're right - my description of the problem was wrong.  I was debugging an internal program at the time which is why I didn't post the log in the report.  But I can reproduce the problem by attaching to openoffice in the debugger too, so here's how to reproduce:

- Start openoffice
- Open kdevelop and choose attach to process.
- Look at Frame Stack - only one thread is shown, but there should be several.

This is the kdevelop gdb window contents:

/bin/sh -c /home/challs/dev/prjatm/services/model/comms/libtool gdb  -fullname -nx -quiet
(gdb) set edit off 
(gdb) set confirm off 
(gdb) (gdb) 
(gdb) set print static-members off 
(gdb) tty /dev/pts/1 
(gdb) set width 0 
(gdb) set height 0 
(gdb) set stop-on 1 
(gdb) handle SIG32 pass nostop noprint 
(gdb) handle SIG43 pass nostop noprint 
(gdb) set print asm-demangle on 
(gdb) cd /home/challs/dev/prjatm/services/model/comms/modelsrv 
(gdb) attach 13456 
(gdb) backtrace 
(no debugging symbols found)... [repeated lots of times, deleted]
[New Thread 16384 (LWP 11803)]
[New Thread 32769 (LWP 12502)]
[New Thread 16386 (LWP 12503)]
[New Thread 32771 (LWP 12592)]
[New Thread 49156 (LWP 12596)]
[New Thread 65541 (LWP 13456)]
(no debugging symbols found)... [multiple times]
0x410e6666 in poll () from /lib/libc.so.6
#0  0x410e6666 in poll () from /lib/libc.so.6
#1  0x44fd42d5 in ?? () from /usr/lib/openoffice/program/libdtransX11645li.so
#2  0x44fd4433 in ?? () from /usr/lib/openoffice/program/libdtransX11645li.so
#3  0x4136631b in osl_getTextEncodingFromLocale () from /usr/lib/openoffice/program/libsal.so.3
#4  0x4114cc00 in pthread_start_thread () from /lib/libpthread.so.0
#5  0x410eeae7 in clone () from /lib/libc.so.6
(gdb) frame 0 
#0  0x410e6666 in poll () from /lib/libc.so.6
(gdb) frame 5 
#5  0x410eeae7 in clone () from /lib/libc.so.6
(gdb) frame 0 
#0  0x410e6666 in poll () from /lib/libc.so.6

The Frame Stack window should at this point be displaying all of the threads, but it only shows the one that gdb displayed in the 'backtrace' output.  Kdevelop did not switch on s_viewThreads and send an 'info threads' request.

With the patch applied, this happens:

/bin/sh -c /home/challs/dev/prjatm/services/model/comms/libtool gdb  -fullname -nx -quiet
(gdb) set edit off 
(gdb) set confirm off 
(gdb) 
(gdb) 
(gdb) set print static-members off 
(gdb) tty /dev/pts/9 
(gdb) set width 0 
(gdb) set height 0 
(gdb) set stop-on 1 
(gdb) handle SIG32 pass nostop noprint 
(gdb) handle SIG43 pass nostop noprint 
(gdb) set print asm-demangle on 
(gdb) cd /home/challs/dev/prjatm/services/model/comms/modelsrv 
(gdb) attach 12596 
(gdb) backtrace 
(no debugging symbols found)...
[New Thread 16384 (LWP 11803)]
[New Thread 32769 (LWP 12502)]
[New Thread 16386 (LWP 12503)]
[New Thread 32771 (LWP 12592)]
[New Thread 49156 (LWP 12596)]
[New Thread 65541 (LWP 13456)]
(no debugging symbols found)...
0x410e6666 in poll () from /lib/libc.so.6
#0  0x410e6666 in poll () from /lib/libc.so.6
#1  0x425bb3f5 in ICEConnectionWorker () from /usr/lib/openoffice/program/libvcl645li.so
#2  0x4136631b in osl_getTextEncodingFromLocale () from /usr/lib/openoffice/program/libsal.so.3
#3  0x4114cc00 in pthread_start_thread () from /lib/libpthread.so.0
#4  0x410eeae7 in clone () from /lib/libc.so.6
(gdb) info thread 
  6 Thread 65541 (LWP 13456)  0x410e6666 in poll () from /lib/libc.so.6
  5 Thread 49156 (LWP 12596)  0x410e6666 in poll () from /lib/libc.so.6
  4 Thread 32771 (LWP 12592)  0x411532c6 in nanosleep () from /lib/libpthread.so.0
  3 Thread 16386 (LWP 12503)  0x41152cf8 in accept () from /lib/libpthread.so.0
  2 Thread 32769 (LWP 12502)  0x410e6666 in poll () from /lib/libc.so.6
  1 Thread 16384 (LWP 11803)  0x410e8551 in select () from /lib/libc.so.6
(gdb) frame 0 
#0  0x410e6666 in poll () from /lib/libc.so.6

Note the new 'info thread'.  And kdevelop shows all the threads.

I hope that description is a little clearer :)
Comment 4 John Birch 2003-10-17 21:21:33 UTC
Seems very reasonable to me, and a good looking patch

Committed

Thanks :-)