Author: Tess | Posted on: 4/28/2008 7:52:18 AM | Views : 862

From time to time I get questions like "our process spawns a lot of threads, how do we know who created them?" or "can I tell how many times we call this method?".  You can answer both of these questions by setting breakpoints, and below is a simple sample of how this is done in windbg with sos...
My demo application (MyApplication.exe) has a class MyThreadClass that has a method CreateAThread, this creates a thread and starts running some method on that thread.  What I am going to show here is how you can set a breakpoint when a thread is started to identify that the method CreateAThread started it, and automate it so that you don't have to click go after each time you hit the breakpoint...
1. Attach to the process with Windbg (File/Attach to process)
2. load sos (.loadby sos mscorwks)
3. Set the breakpoint on System.Threading.Thread..ctor in mscorlib.dll (the constructor for Thread)
0:005> !bpmd mscorlib.dll Sy ...

Go to the complete details ...