Tracing pthread scheduling

≯℡__Kan透↙ 提交于 2020-01-01 04:22:09

问题


What I want to do is create some kind of graph detailing the execution of (two) threads in Linux. I don't need to see what the threads do, just when they are scheduled and for how long, a time line basically.

I've spend the last few hours searching the internet for a way to trace the scheduling of pthreads. Unfortunately, the two projects I found require either kernel recompilation (LTTng) or glibc patching (NPTL Trace Tool), both of which I can not do (large, centrally managed system, on which I have no sudo rights).

Is there any other way to do something like this or will I have to resort to finding a laptop on which I can patch/recompile whatever I want?

Best regards

PS: I would have linked to both projects, but the site doesn't allow me (reputation < 10). The first search result on Google for the project names is the correct one though.


回答1:


Superuser privileges are not needed to build an instrumented glibc / libpthread.so. The ptt_trace program that is part of NPTL Trace Tool will run your program using the instrumented library.




回答2:


Maybe something like Intel's VTune?




回答3:


There is also a tool called pthreadw (on sourceforge)

It's a wrapper library which intercepts calls to the usual functions of the pthread library, and reports stats, like typical times spent playing with locks, condition variables, etc... It is not currently able to export traces, only textual summary reports.



来源:https://stackoverflow.com/questions/2163186/tracing-pthread-scheduling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!