我能得到所有线程的堆栈跟踪我的C#应用​​程序?

我能得到所有线程的堆栈跟踪我的C#应用​​程序?

问题描述:

我在一个相当大的应用程序,我在工作中破解调试上一个明显的并发问题。有问题的错误只体现在某些性能较低的机器对于很多(12+)小时后运行,我从来没有在调试器中复制它。正因为如此,我的调试工具基本上局限于分析日志文件。

I'm debugging an apparent concurrency issue in a largish app that I hack on at work. The bug in question only manifests on certain lower-performance machines after running for many (12+) hours, and I have never reproduced it in the debugger. Because of this, my debugging tools are basically limited to analyzing log files.

C#可以很容易地获得线程的堆栈跟踪抛出异常,但我喜欢另外获得所有其他线程当前在我的AppDomain在异常被抛出时执行的堆栈跟踪。

C# makes it easy to get the stack trace of the thread throwing the exception, but I'd like to additionally get the stack traces of every other thread currently executing in my AppDomain at the time the exception was thrown.

这可能吗?

有是CodePlex的工具,称为托管堆栈管理器(我认为起源于微软)。它使用的调试和分析API来捕捉正在运行的.NET应用程序的线程的堆栈跟踪,而不需要修改应用程序。

There is a tool on CodePlex called Managed Stack Explorer (that I believe originated from Microsoft). It uses the debugging and profiling API to capture the stack traces of the threads in a running .Net application, without the need to modify the application.

您可以运行应用程序直到你遇到问题,那么使用这个工具来捕获所有正在运行的线程的当前堆栈跟踪分析它。这种方法的好处是,你离开你的应用程序未修改(插装它可能会改变其行为),该工具是免费的。

You could run your application until you experience the issue, then analyse it using this tool to capture the current stack traces of all running threads. The benefit of this approach is that you leave your application unmodified (instrumenting it may change its behaviour), and the tool is free.