简体   繁体   English

如何使用 cdb(windbg 命令行)在会话之间保持断点?

[英]How to keep breakpoints between sessions using cdb (windbg command line)?

My goal is to keep breakpoints between debugging sessions in CDB (the command line version of windbg).我的目标是在 CDB(windbg 的命令行版本)中的调试会话之间保持断点。 I am able to correctly restart by using .restart , however I always lose my breakpoints (I am setting my breakpoints by using the bu and/or bm commands.我可以使用.restart正确重新启动,但是我总是丢失断点(我使用bu和/或bm命令设置断点。

Is it even possible when using just cdb?仅使用 cdb 时甚至可能吗?

cdb is not possible use .bpcmds before .restart and save to someplace and reuse it after restart cdb 不可能在 .restart 之前使用 .bpcmds 并保存到某个地方并在重新启动后重新使用它

for windbg you can use workspaces to save breakpoints between sessions对于windbg,您可以使用工作区来保存会话之间的断点

edit a demo编辑演示

suppose you have these breakpoints假设你有这些断点

0:000> bl
 0 e 00007ff6`0fc4109c     0001 (0001)  0:**** calc!wWinMain
 1 e 00007ff6`0fc41820     0001 (0001)  0:**** calc!wWinMainCRTStartup
 2 e 00007ff6`0fc41960     0001 (0001)  0:**** calc!matherr
 3 e 00007ffb`f033d880     0001 (0001)  0:**** ntdll!NtCreateTimer2
 4 e 00007ffb`f033d6a0     0001 (0001)  0:**** ntdll!NtCreateNamedPipeFile
 5 e 00007ffb`f02a2000     0001 (0001)  0:**** ntdll!RtlDefaultNpAcl+0x190
 6 e 00007ffb`ede53000     0001 (0001)  0:**** KERNELBASE!EnumDynamicTimeZoneInformation+0x60

.bpcmds will show you how set them (the last two are symbol less bps based on rva ) .bpcmds 将向您展示如何设置它们(最后两个是基于 rva 的无符号 bps)

and if you had set them using bp they may not work the next time如果您使用 bp 设置它们,它们下次可能无法使用
due to ASLR as the module may be loaded at a different Address由于 ASLR,因为模块可能会加载到不同的地址

0:000> .bpcmds
bu0 calc!wWinMain;
bu1 calc!wWinMainCRTStartup;
bu2 calc!wsetargv;
bu3 ntdll!ZwCreateTimer2;
bu4 ntdll!ZwCreateNamedPipeFile;
bu5 ntdll+2000;
bu6 kernelbase+3000;
0:000>  

copy paste to some scratch space and after .restart copy paste back to cdb console将粘贴复制到一些临时空间,然后在 .restart 复制粘贴回 cdb 控制台

you can use .logopen {some_path_to_some_textfile} do .bpcmds and .restart also你也可以使用.logopen {some_path_to_some_textfile} 做 .bpcmds 和 .restart

in this case you can copy paste the bps from logfile and don't have to open the log file again as windbg/cdb doesn't close the logfile on .restart在这种情况下,您可以从日志文件中复制粘贴 bps,而不必再次打开日志文件,因为 windbg/cdb 不会在 .restart 上关闭日志文件

here is .restart also capturted to logfile这里是 .restart 也被捕获到日志文件

bu6 kernelbase+3000;
0:000> .restart
CommandLine: calc

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM