如何在一个命令中禁用 cdb 中显式命名的异常?
sx 系列命令接受异常/事件的名称(如 av)、异常代码或 *。
问题是 * 捕获了所有未命名的异常。如果我想在发生任何异常时执行命令(无论是否显式命名)怎么办?
例如,
sxe -c "bla-bla-bla" -c2 "ku-ku-ku" av
sxe -c "bla-bla-bla" -c2 "ku-ku-ku" dz
sxe -c "bla-bla-bla" -c2 "ku-ku-ku" *
指示调试器:
- 第一次机会执行 bla-bla-bla 命令 访问冲突
- 第二次执行 ku-ku-ku 命令 访问冲突
- 第一次执行 bla-bla-bla 命令 除以零
- 执行 ku -ku-ku 命令对第二次机会 除以零 对
- 任何未命名的第一次机会异常执行 bla-bla-bla 命令
- 对任何未命名的第二次机会异常执行 ku-ku-ku 命令
但是,大约有两打命名异常,并且如果我希望在每个异常上执行这些命令,我似乎需要对每个异常重复相同的 sxe 语句,仅更改异常名称。
有更好的方法吗?
谢谢。
EDIT1
这是实际的 CDB 脚本,我在其中使用命令:
as AdpDumpDir C:\Logs\Crash
!adplusext.adpextstart AdpDumpDir
as /c AdpProcID !adplusext.adpprocid
as /c AdpHostComputer !adplusext.adphostcomputer
as /c AdpTargetComputer !adplusext.adptargetcomputer
as /c AdpProcName !adplusext.adpprocname
.logopen /t ${AdpDumpDir}\${AdpProcName}.log
version
al
.symfix+ C:\Users\markk\AppData\Local\Temp\SymbolCache
.sympath
.reload
as ExcCode av
as ExcName AccessViolation
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode asrt
as ExcName AssertionFailure
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode aph
as ExcName ApplicationHang
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode eh
as ExcName C++EH
sxe -c "gn" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode clr
as ExcName CLR
sxe -c "gn" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode clrn
as ExcName CLRNotification
sxe -c "gn" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode dm
as ExcName DataMisaligned
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode gp
as ExcName GuardPageViolation
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode ii
as ExcName IllegalInstruction
sxe -c "gn" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode ip
as ExcName InPageIOError
sxe -c "gn" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode dz
as ExcName DivideByZero
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode iov
as ExcName IntegerOverflow
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode ch
as ExcName InvalidHandle
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode lsq
as ExcName InvalidLockSequence
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode isc
as ExcName InvalidSystemCall
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode 3c
as ExcName PortDisconnected
sxe -c "gn" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode svh
as ExcName ServiceHang
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode sov
as ExcName StackOverflow
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode vs
as ExcName VerifierStop
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode vcpp
as ExcName VisualC++
sxe -c "gn" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
sxi bpe
sxi wob
sxi e06d7363
sxi e0434352
sxe -c "gn" -c2 @".dump /u /ma /c SecondChance ${AdpDumpDir}\MINIDUMP_SecondChance_${AdpProcName}_.dmp;GN" *
sx
g
.logclose
q
如果可能的话,我正在寻找使其更短、更简单的方法。
The sx family of commands accept either the name of the exception/event, like av, the exception code or *.
The thing is that * catches all the unnamed exceptions. What if I want to execute a command when any exception happens, be it explicitly named or not?
For instance,
sxe -c "bla-bla-bla" -c2 "ku-ku-ku" av
sxe -c "bla-bla-bla" -c2 "ku-ku-ku" dz
sxe -c "bla-bla-bla" -c2 "ku-ku-ku" *
Instructs the debugger to:
- execute bla-bla-bla command on the first chance Access Violation
- execute ku-ku-ku command on the second chance Access Violation
- execute bla-bla-bla command on the first chance Division by Zero
- execute ku-ku-ku command on the second chance Division by Zero
- execute bla-bla-bla command on any unnamed first chance exception
- execute ku-ku-ku command on any unnamed second chance exception
But, there are about two dozens of the named exception and if I want these commands to be executed on each one of them I seem to be expected to repeat the same sxe statement for each of these exceptions, changing just the exception name.
Is there a better way to do it?
Thanks.
EDIT1
Here is the actual CDB script, where I use the commands:
as AdpDumpDir C:\Logs\Crash
!adplusext.adpextstart AdpDumpDir
as /c AdpProcID !adplusext.adpprocid
as /c AdpHostComputer !adplusext.adphostcomputer
as /c AdpTargetComputer !adplusext.adptargetcomputer
as /c AdpProcName !adplusext.adpprocname
.logopen /t ${AdpDumpDir}\${AdpProcName}.log
version
al
.symfix+ C:\Users\markk\AppData\Local\Temp\SymbolCache
.sympath
.reload
as ExcCode av
as ExcName AccessViolation
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode asrt
as ExcName AssertionFailure
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode aph
as ExcName ApplicationHang
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode eh
as ExcName C++EH
sxe -c "gn" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode clr
as ExcName CLR
sxe -c "gn" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode clrn
as ExcName CLRNotification
sxe -c "gn" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode dm
as ExcName DataMisaligned
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode gp
as ExcName GuardPageViolation
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode ii
as ExcName IllegalInstruction
sxe -c "gn" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode ip
as ExcName InPageIOError
sxe -c "gn" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode dz
as ExcName DivideByZero
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode iov
as ExcName IntegerOverflow
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode ch
as ExcName InvalidHandle
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode lsq
as ExcName InvalidLockSequence
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode isc
as ExcName InvalidSystemCall
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode 3c
as ExcName PortDisconnected
sxe -c "gn" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode svh
as ExcName ServiceHang
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode sov
as ExcName StackOverflow
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode vs
as ExcName VerifierStop
sxe -c @".dump /u /ma /c FirstChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_FirstChance_${ExcCode}_${ExcName}_.dmp;GN" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
as ExcCode vcpp
as ExcName VisualC++
sxe -c "gn" -c2 @".dump /u /ma /c SecondChance_${ExcCode}_${ExcName} ${AdpDumpDir}\MINIDUMP_${AdpProcName}_SecondChance_${ExcCode}_${ExcName}_.dmp;GN" ${ExcCode}
sxi bpe
sxi wob
sxi e06d7363
sxi e0434352
sxe -c "gn" -c2 @".dump /u /ma /c SecondChance ${AdpDumpDir}\MINIDUMP_SecondChance_${AdpProcName}_.dmp;GN" *
sx
g
.logclose
q
I am looking for ways to make it shorter and simpler, if possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,没有很好的解决方案,但您可以使用这个技巧:
其中
{sx}
列出所有命名异常代码及其设置(稍后将跳过)。code
只是变量的名称。.foreach(...) {...}
将输出处理为单个单词。sxe ... ${code}
执行预期的命令,.catch{...}
忽略所有错误(即跳过不需要的标记)。使用 PyKD 您可以编写一个更直接的 Python 脚本:
As far as I know, there is no nice solution, but you can use this hack:
where
{sx}
list all named exception codes and their settings (which will be skipped later).code
is just the name of a variable..foreach(...) {...}
processes the output as single words.sxe ... ${code}
performs the expected command and.catch{...}
ignores all errors (i.e. skips unwanted tokens).With PyKD you can write a Python script which does it a bit more straight-forward: