From Bugzilla Helper: User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040206 Firefox/0.8 Description of problem: strace cannot trace multithreaded programs. It will only trace the parent thread, which is often not a thread doing any real work. strace is basically useless on multithreaded programs. Version-Release number of selected component (if applicable): strace-4.5.1-1 How reproducible: Always Steps to Reproduce: 1.start multithreaded process 2.strace it 3. Actual Results: Only trace from parent thread is shown. Expected Results: Either strace needs a way to trace individual threads or it should show all of the switching between threads. Additional info: I have no clue how this would work. It's only a problem with NPTL programs that have the same PID for every thread. There is no workaround, but I see no easy solution, either.
Are you using -f? If you are using strace -f and not seeing all threads, for both NPTL and linuxthreads flavors, then please report a specific test scenario with all necessary sources.
Yes, I am. The specific multi-threaded program I'm trying to strace is called Cyclone (http://archive.highwinds-software.com/builds/index.html). The software is proprietary, but the evaluation license is free. When I do an strace -f -p <pid>, all I get is the result of the primary process. I know the process is doing more because it's pushing out over 100Mbps of traffic.
It is important to include in any bug report all the details of how you are using the program. You did not say you were using -p to attach to a running program, which is a critical detail. strace -f attaches to new threads as they are created. When using -p, you are still only attaching to one thread (the initial thread) and if you use -f then you also see new threads created once you are already tracing. strace -p has never before attached to several threads automatically, for either NPTL or linuxthreads. It is now easy enough to implement that for NPTL threads due to 2.6 kernel support in /proc. That seems like a worthwhile enhancement, but lack of it is not really a bug as such. I will implement this upstream, and a new strace rpm might make it in before the FC2 release.
Well, right. The problem was before that you could do strace -f -p on an individual thread because threads got their own PIDs so there wasn't any need to be able to trace from the master, but I should've filed a better bug report. Thanks for grabbing it.
I've made this enhancement upstream.
An errata has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on the solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2004-338.html