Making strace multi-threaded

Eugene Syromiatnikov esyr at redhat.com
Sun Dec 5 20:51:25 UTC 2021


On Tue, Nov 23, 2021 at 04:04:36PM +0100, Karaoui mohamed lamine wrote:
> Hi list,
> 
> Can we make strace multi-threaded? This is for when we trace a
> multi-threaded process. Ideally, we want each thread of strace to trace a
> single thread of the application.

I think, in case of strace, it is the only multi-threading mode possible.
It will require some good deal of re-factoring, though, as there are far
too many places that rely on the fact that strace is single-threaded
(and also static buffers sprinkled all over the place).

> How far do we need to go to make it happen?

> Do we need to modify ptrace also?

I do not think so, but I cannot recall any multi-threaded ptrace-based tracer
(or jailer, for that matter), so there could be bugs.  For starters,
I would expect all kinds of shenanigans with non-thread-group-leader exec
and PID recycling.

> Or just modifying strace code base is sufficient?

Should be the case.

> I also tried to have multiple instances of strace attach to a each thread
> of a process. But of course, this does not work! We can only attach to a
> process as a whole not to one of its threads.

Do you have any specific use cases where strace (and not ptrace) is indeed
the bottleneck?

> Regards,
> Mohamed Karaoui



More information about the Strace-devel mailing list