编写 WinDBG 脚本以在每次中断时获取调用堆栈,然后继续(未处理的 ex,或调试者说 debug.break())
我们正在运行一个应用程序,恰好是我们编写的 Web 服务器,并且我们只在生产中提到一些令人讨厌的问题,因此在大约 12 小时内,我们将把它放在 WinDBG 下,并在每次崩溃时获取调用堆栈。
有时它会因为未处理的异常而中断,有时我们会遇到断言,此时我们的代码会说如果在调试器下运行,则中断。
是否有可能以这样的方式挂接到 WinDBG:一旦它中断,它就会获取调用堆栈并立即继续?
We're running an application, happens to be web server we've written, and we're saying some nasty issues only in production, so for about 12 hours we're going to put this under WinDBG and take callstacks every time it breaks.
Sometimes it'll break because of an unhandled exception, and sometimes we'll hit an assert, at which point our code says if running under a debugger, break.
Is it possible to hook into WinDBG in such a way that as soon it breaks, it takes a callstack, and moves on immediately?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将调试器附加到生产环境可能会带来灾难性的后果,(a) 性能 (b) 意外中断调试器
为了安全起见,一定要确保禁用所有您不关心或不想中断调试器的异常。
然后,选择您想要以某种方式处理的异常(获取调用堆栈,然后继续)。
第一个是断点异常处理程序、断言失败和 C++ EH 异常。
您的调试器支持的内容有一个巨大的列表,例如,如果您加载 SOS.dll(WinDBG 的 CLR 扩展),那么您将能够 有关
您可以过滤的异常/事件类型的权威信息,请参阅 WinDbg帮助(搜索 sxe)
Attaching a debugger to a production box can be disastrous, (a) performance (b) unexpected breaks into the debugger
As a safety, definately make sure you disable all exceptions you don't care about or will not want to break into the debugger.
Then, choose the ones you'd like to handle in some fashion (take callstack, and move on)
The first one is a break point exception handler, assert failure, and C++ EH exception.
There's a huge list of what your debugger supports, for example if you load SOS.dll (the CLR extension to WinDBG) then you'll be able to
For authoritative information on types of exception/events you can potentially filter on, see the WinDbg help (search for sxe)
尝试
在 Windbg 的帮助文档中搜索
控制异常和事件以获取更多相关信息。
Try
and
Search Controlling Exceptions and Events in windbg's Help document for more related information.