1

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.

Sanich
  • 1,739
  • 6
  • 25
  • 43

4 Answers4

2

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.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Yeah I know there is no parent-child relation. Just thought maybe there is a tool that is making some monitoring and holds a record of thread creation and its parent. – Sanich Jan 06 '14 at 12:59
  • [THREAD_BASIC_INFORMATION](http://undocumented.ntinternals.net/UserMode/Structures/THREAD_BASIC_INFORMATION.html) - this is all you have, even undocumented. – Roman R. Jan 06 '14 at 13:03
1

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.

marcinj
  • 48,511
  • 9
  • 79
  • 100
0

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

Angus Connell
  • 419
  • 3
  • 6
0

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.

yosim
  • 503
  • 2
  • 8