How to know who is the parent thread of a given thread ID

删除回忆录丶 提交于 2019-12-24 16:37:31

问题


I'm debugging a program in vs 2008. There is a thread list with thread IDs. Is the any way or tool that I can use to identify the parent thread of a given thread ID? Thanks.


回答1:


There is no API, at least standard and documented, to obtain a creator thread ID for a given thread. Neither Performance Monitor, Visual Studio IDE, Process Explorer nor Spy++ provide this information. Once started, a thread is not dependent on its creator any longer and runs independently; there is no parent-child relation in particular.




回答2:


I dont think you can do that, but I cant give you good explanation why. Just never heard of it as possible. I looked into Process Explorer, and it can give you only Start Address, but I doubt you can deduce parent thread ID from it.

If you need to do this in your app, then it should not be very difficult to implement, maybe it is even possible to hook system function to do that, but if SysInternals is not doing this then maybe this is not possible.




回答3:


I think Spy++ (it's called spyxx.exe and is located in C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools on my machine) will give such information but it's hard work, however I am sure that sys internals do a much better version of process information




回答4:


are you looking for programmatic way, or an external tool? if the later, try processExplorer. you can download it for free from MS, and it gives you the thread thread hierarchy plus a lot of other cool stuff.



来源:https://stackoverflow.com/questions/20950082/how-to-know-who-is-the-parent-thread-of-a-given-thread-id

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