测试脚本(main.txt)
$$ main.txt$$ *********************************************************************************************.expr /s masm.load pmext.dllbc*$$ *********************************************************************************************sxn ldsxn udsxi outsxd ehsxd avsxd dmsxd gpsxd ipsxd dzsxd iovsxd ch$$ *********************************************************************************************.bpsync 0bp Debuggee2!CMyTester::SubTestingProc "r $t0=@$t0+1;r $t0;g"bl$$ *********************************************************************************************g$$ *********************************************************************************************
开始测试德bat文件
C:\WinDbg\WinDbg.exe -c "$$< C:\WinDbg\products\MutiThread2\main.txt" c:\WinDbgSample\src\Debuggee2\Debug\Debuggee2.exe
WinDbg的输出结果
Opened log file 'C:\WinDbg\products\Debuggee2_2010-04-20_13-55-07\log\Debuggee2.log'
Microsoft (R) Windows Debugger Version 6.12.0002.633 X86Copyright (c) Microsoft Corporation. All rights reserved.
CommandLine: c:\WinDbgSample\src\Debuggee2\Debug\Debuggee2.exeSymbol search path is: SRV*C:\MyLocalSymbols*http://msdl.microsoft.com/download/symbolsExecutable search path is: Wed Apr 21 13:34:37.524 2010 (UTC + 8:00): ModLoad: 00400000 00430000 Debuggee2.exeWed Apr 21 13:34:37.539 2010 (UTC + 8:00): ModLoad: 7c900000 7c9b0000 ntdll.dllWed Apr 21 13:34:37.586 2010 (UTC + 8:00): ModLoad: 7c800000 7c8f5000 C:\WINDOWS\system32\kernel32.dllWed Apr 21 13:34:37.586 2010 (UTC + 8:00): ModLoad: 7c140000 7c31c000 C:\WINDOWS\system32\MFC70D.DLLWed Apr 21 13:34:37.586 2010 (UTC + 8:00): ModLoad: 10200000 10285000 C:\WINDOWS\system32\MSVCR70D.dllWed Apr 21 13:34:37.586 2010 (UTC + 8:00): ModLoad: 77f10000 77f57000 C:\WINDOWS\system32\GDI32.dllWed Apr 21 13:34:37.602 2010 (UTC + 8:00): ModLoad: 7e410000 7e4a0000 C:\WINDOWS\system32\USER32.dllWed Apr 21 13:34:37.602 2010 (UTC + 8:00): ModLoad: 77f60000 77fd6000 C:\WINDOWS\system32\SHLWAPI.dllWed Apr 21 13:34:37.602 2010 (UTC + 8:00): ModLoad: 77dd0000 77e6b000 C:\WINDOWS\system32\ADVAPI32.dllWed Apr 21 13:34:37.602 2010 (UTC + 8:00): ModLoad: 77e70000 77f01000 C:\WINDOWS\system32\RPCRT4.dllWed Apr 21 13:34:37.602 2010 (UTC + 8:00): ModLoad: 77c10000 77c68000 C:\WINDOWS\system32\msvcrt.dllWed Apr 21 13:34:37.602 2010 (UTC + 8:00): ModLoad: 74c80000 74cac000 C:\WINDOWS\system32\OLEACC.dllWed Apr 21 13:34:37.618 2010 (UTC + 8:00): ModLoad: 76080000 760e5000 C:\WINDOWS\system32\MSVCP60.dllWed Apr 21 13:34:37.618 2010 (UTC + 8:00): ModLoad: 774e0000 7761d000 C:\WINDOWS\system32\ole32.dllWed Apr 21 13:34:37.618 2010 (UTC + 8:00): ModLoad: 77120000 771ac000 C:\WINDOWS\system32\OLEAUT32.dllWed Apr 21 13:34:37.618 2010 (UTC + 8:00): ModLoad: 773d0000 774d3000 C:\WINDOWS\WinSxS\X86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03\COMCTL32.dllWed Apr 21 13:34:37.633 2010 (UTC + 8:00): (a20.6dc): Break instruction exception - code 80000003 (first chance)eax=00261eb4 ebx=7ffde000 ecx=00000004 edx=00000010 esi=00261f48 edi=00261eb4eip=7c901230 esp=0013fb20 ebp=0013fc94 iopl=0 nv up ei pl nz na po nccs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000202ntdll!DbgBreakPoint:7c901230 cc int 3Processing initial command '$$< C:\WinDbg\products\MutiThread2\main.txt'0:000> $$< C:\WinDbg\products\MutiThread2\main.txt0:000> $$ main.txt0:000> $$ *********************************************************************************************0:000> .expr /s masmCurrent expression evaluator: MASM - Microsoft Assembler expressions0:000> .load pmext.dll0:000> bc*0:000> $$ *********************************************************************************************0:000> sxn ld0:000> sxn ud0:000> sxi out0:000> sxd eh0:000> sxd av0:000> sxd dm0:000> sxd gp0:000> sxd ip0:000> sxd dz0:000> sxd iov0:000> sxd ch0:000> $$ *********************************************************************************************0:000> .bpsync 0Breakpoint synchronization disabled0:000> bp Debuggee2!CMyTester::SubTestingProc "r $t0=@$t0+1;r $t0;g"*** WARNING: Unable to verify checksum for Debuggee2.exe0:000> bl 0 e 00414470 0001 (0001) 0:**** Debuggee2!CMyTester::SubTestingProc "r $t0=@$t0+1;r $t0;g"0:000> $$ *********************************************************************************************0:000> gCommand file caused an implicit waitCommand file execution failed, HRESULT 0x80004005 "Unspecified error"Wed Apr 21 13:34:37.711 2010 (UTC + 8:00): ModLoad: 5cb70000 5cb96000 C:\WINDOWS\system32\ShimEng.dllWed Apr 21 13:34:37.727 2010 (UTC + 8:00): ModLoad: 76390000 763ad000 C:\WINDOWS\system32\IMM32.DLLWed Apr 21 13:34:37.727 2010 (UTC + 8:00): ModLoad: 629c0000 629c9000 C:\WINDOWS\system32\LPK.DLLWed Apr 21 13:34:37.727 2010 (UTC + 8:00): ModLoad: 74d90000 74dfb000 C:\WINDOWS\system32\USP10.dllWed Apr 21 13:34:37.743 2010 (UTC + 8:00): ModLoad: 5d360000 5d36e000 C:\WINDOWS\system32\MFC70ENU.DLLWed Apr 21 13:34:37.758 2010 (UTC + 8:00): Unload module C:\WINDOWS\system32\ShimEng.dll at 5cb70000Wed Apr 21 13:34:37.774 2010 (UTC + 8:00): ModLoad: 74720000 7476b000 C:\WINDOWS\system32\MSCTF.dllWed Apr 21 13:34:37.774 2010 (UTC + 8:00): ModLoad: 77c00000 77c08000 C:\WINDOWS\system32\version.dllWed Apr 21 13:34:37.774 2010 (UTC + 8:00): Unload module C:\WINDOWS\system32\version.dll at 77c00000Wed Apr 21 13:34:37.789 2010 (UTC + 8:00): ModLoad: 77b40000 77b62000 C:\WINDOWS\system32\apphelp.dllWed Apr 21 13:34:37.789 2010 (UTC + 8:00): ModLoad: 755c0000 755ee000 C:\WINDOWS\system32\msctfime.imeWed Apr 21 13:34:37.789 2010 (UTC + 8:00): ModLoad: 5ad70000 5ada8000 C:\WINDOWS\system32\UxTheme.dllWed Apr 21 13:34:37.805 2010 (UTC + 8:00): ModLoad: 10000000 10006000 C:\Program Files\Synergy\synrgyhk.dll$t0=00000001$t0=00000002$t0=00000003$t0=00000004$t0=00000005$t0=00000006$t0=00000007$t0=00000008$t0=00000009$t0=0000000a$t0=0000000b$t0=0000000c$t0=0000000d$t0=0000000e$t0=0000000f$t0=00000010......
......
......$t0=000002fe
使用 .bpsync 1 可以解决错过断点的问题,为什么故意禁用这个功能呢?
其实我是试验过这个.bpsync 1命令的。但是发现还是不能完全解决这个问题。
Raymond 老师对此有什么高见或者有建议?
非常感谢。
这里的症结是调试器需要在单步走过断点时,临时删除断点。执行.bpsync 1命令后,调试器会在单步时,冻结其它线程,在断点恢复后,再恢复所有线程,因此应该没有错过断点的问题了啊。不知道“不能完全解决”是什么意思?
如果怀疑.bpsync 1命令,那么可以手工实现类似的功能,就是在断点命中后,执行一次
~. t
也就是将当前线程单步一次。
然后再执行g