3

Occasionally when investigating SQL Server issues I find it useful to be able to attach the Visual Studio debugger to it and try and figure out what it is doing by looking at the call stack (the public symbols are available and often it is possible to infer useful information from the method names).

A great example of the type of internals information that can be inferred is in this blog post which inspired my attempts.

This can be quite a time consuming and tedious process however. Generally I run the code of interest in a loop attach the debugger then continually break and continue until I hit a call stack that looks interesting to the matter under investigation. I can then step through the code and look at the method names being called. This takes ages however.

Is there any way of automating this so I can simply log all the methods called for a short period then review the log file afterwards?

2 Answers2

3

If I am not mistaken, you're probably looking for Process Monitor (a.k.a. procmon). You can get it from this Microsoft website.

Specifically the "Stack Summary" menu option has this kind of information. More details in section PM2-6: Unrolling the stack

enter image description here

2

The profiler in higher versions of Visual Studio can be used to do this.

Example Output

Screenshot

(And the answer here shows why this is useful)

Or additionally the Windows Performance Toolkit is free and can also do much the same and more. A good series of videos on this can be found at https://channel9.msdn.com/Search?term=Defrag%20tools%20wpt#ch9Search