简体   繁体   English

Minidebugger工具可在引发异常时捕获异常

[英]Minidebugger tool to catch exceptions as they're being thrown

We have a program that fails with cryptic (exception -sourced text) message. 我们有一个程序失败,并显示神秘消息(源自异常的文本)。 It's really generic and doesn't tell squat. 它真的很通用,不会下蹲。 I could solve this in a minute if I had VS installed on that machine and could run that program with "Catch exceptions as they're being thrown". 如果我在该计算机上安装了VS,并且可以运行该程序并带有“在抛出异常时捕获异常”,那么我可以在一分钟内解决此问题。

Alas, we can't have that on the limited system (remote debugger is no-go as well because firewalls), but a small tool would be ok. las,我们不能在有限的系统上使用它(因为防火墙,远程调试器也不能使用),但是可以使用一个小工具。

So is there a tool that can catch exceptions of CLR (C# origin here) programs as they're thrown, write them down (with all asociated introspected properties with stacktrace) and let the program die it's merry way? 那么,有没有一种工具可以捕获抛出的CLR(此处为C#起源)程序的异常,将其记录下来(以及与stacktrace关联的所有内省属性)并让程序以一种快乐的方式消亡? Notice that generic "handle not handled" exceptions is not acceptable because this exception is handled, albeit badly. 请注意,一般的“未处理的句柄”异常是不可接受的,因为尽管处理异常,但处理得很糟。

Download WinDbg. 下载WinDbg。 After installing it, you can just copy the entire folder to the target machine. 安装后,您可以将整个文件夹复制到目标计算机。 No installation or registry changes are necessary. 无需安装或注册表更改。 Make sure to use the same bit version as your application. 确保使用与您的应用程序相同的位版本。 Attach it to your application. 将其附加到您的应用程序。 Load SOS with .loadby sos clr . .loadby sos clr加载SOS。 (Use .loadby sos mscorwks if it is a prior to .NET 4.) Then enable breaking on all CLR exceptions with sxe clr . (如果它是.NET 4之前的版本,请使用.loadby sos mscorwks )然后使用sxe clr启用对所有CLR异常的sxe clr This will catch both first and second chance exceptions. 这将同时捕获第一次和第二次机会异常。 When it breaks, type !sos.clrstack to get the stack trace. 中断时,键入!sos.clrstack以获取堆栈跟踪。 You may also type .dump /ma c:\\app.dmp to write a dump file for further analysis; 您也可以键入.dump /ma c:\\app.dmp来写入转储文件以进行进一步分析; this could be on another PC at your own pace. 可以按照您自己的步调安装到另一台PC上。 Then type qd to detach and quit. 然后键入qd分离并退出。

Note that if you just take the dump when the exception occurs you can omit loading SOS and dumping the stack until later moving the dump to another machine for offline analysis. 请注意,如果仅在发生异常时进行转储,则可以省略加载SOS和转储堆栈,直到以后将转储移至另一台计算机进行脱机分析为止。 You can delete the WinDbg folder from the target PC after you're done. 完成后,您可以从目标PC删除WinDbg文件夹。

procdump is a great tool for that purpose. procdump是用于此目的的出色工具。 Use the following command line to start ( -x ) the managed executable ( -g ) and write minidump ( -ma ) each time the first and second chance exception occured ( -e 1 ): 每次发生第一次和第二次机会异常( -e 1 )时,使用以下命令行启动( -x )受管理的可执行文件( -g )并写入小型转储( -ma ):

procdump.exe -accepteula -e 1 -ma -g -n 100 -x <path to directory to place dumps> <path to executable being monitored>

-n option specifies the limit of number of dumps to be written before procdump detach (without terminating target process). -n选项指定在procdump分离之前写的转储数限制(不终止目标进程)。 There is a bunch of other options available. 还有很多其他选择。 See procdump site for details. 有关详细信息,请参见procdump网站

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当从finallys抛出异常时,不会评估Catch块 - Catch block is not being evaluated when exceptions are thrown from finallys 如何检查 catch 块中抛出的异常类型? - How to check the types of Exceptions thrown in a catch block? 没有抛出ApplicationException来正确捕获块 - ApplicationException not being thrown to catch block properly 如何&#39;全局&#39;捕获在对象实例中抛出的异常 - How do I 'globally' catch exceptions thrown in object instances 在后台线程中全局捕获WCF异步调用引发的异常 - Globally catch exceptions thrown from WCF async calls in a background thread 如何捕获从 HttpWebRequest.GetResponseAsync 抛出的异常? - How to catch exceptions thrown from HttpWebRequest.GetResponseAsync? 有没有办法捕获给定类抛出的所有未处理的异常? - Is there a way to catch all unhandled exceptions thrown by a given class? 不抛出异常时,try/catch 块是否会影响性能? - Do try/catch blocks hurt performance when exceptions are not thrown? 如何捕获AutoCAD.NET中抛出的未处理异常 - How to catch unhandled exceptions thrown in AutoCAD.NET 未捕获在属性中的Set操作期间抛出的异常 - Exceptions thrown during a Set operation in a Property are not being caught
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM