时间:2021-07-01 10:21:17 帮助过:3人阅读
如果不配置,使用命令的时候会提示错误,比如:
0:000> .loadby sos clrjit 0:000> !tp *** ERROR: Symbol file could not be found. Defaulted to export symbols for clr.dll - ************* Symbol Loading Error Summary ************** Module name Error clr PDB not found : e:\appserver\symbols\dll\clr.pdb
e:\appserver 是我的dmp文件所在的目录,它默认是到symbols 子目录去找符号文件去了。
然后,配置下使用此文件的调试环境。
在菜单命令 File->Symbol path... 打开对话框,选择浏览,找到dmp文件所在目录相关的程序文件目录 E:\AppServer ,该目录下面有程序相关的 exe,pdb 文件。
输入下面的命令:
0:000> .sympath+ c:\symbols Symbol search path is: E:\AppServer;c:\symbols Expanded Symbol search path is: e:\appserver;c:\symbols Error: Attempts to access ‘c:\symbols‘ failed: 0x2 - 系统找不到指定的文件。 ************* Symbol Path validation summary ************** Response Time (ms) Location OK E:\问题\AppServer Error
这里不用管,这个文件夹后面可以生成。
0:000> .symfix 0:000> .symfix+ c:\symbols 0:000> .sympath Symbol search path is: srv* Expanded Symbol search path is: SRV*c:\symbols*http://msdl.microsoft.com/download/symbols ************* Symbol Path validation summary ************** Response Time (ms) Location Deferred
这下对了。
执行下 reload命令:
0:000> .reload ................................................................ ................................................................ ............
接着执行下面:
0:000> .loadby sos clr 0:000> !tp The version of SOS does not match the version of CLR you are debugging. Please load the matching version of SOS for the version of CLR you are debugging. CLR Version: 4.0.30319.296 SOS Version: 4.6.96.0 Failed to load data access DLL, 0x80004005
这里提示说SOS的版本更CLR不匹配,这里需要找到当时生成Dump文件所在的服务器上的 sos.dll,注意,因为服务器程序是64位的,所以必须在 .Net Framework64 目录去找,同时把 mscordacwks.dll 文件一起拷贝过来(先暂时不用,下面马上会讲到)。
刚才这个命令执行后,我们惊喜的发现,c:\symbols 目录自己创建了,并且下载了 clr.pdb等几个目录,这是再将刚才服务器上拷贝的 sos.dll, mscordacwks.dll ,放到本地机器的 c:\symbols 目录下面。
再次执行这几个命令:
0:000> .reload ................................................................ ................................................................ ............ 0:000> .loadby sos clr 0:000> !tp The version of SOS does not match the version of CLR you are debugging. Please load the matching version of SOS for the version of CLR you are debugging. CLR Version: 4.0.30319.296 SOS Version: 4.6.96.0 Failed to load data access DLL, 0x80004005
还是报错,看来 sos.dll 没有加载正确,用下面的命令:
0:000> .load c:\symbols\sos.dll 0:000> .loadby sos clr 0:000> !tp
这里load命令必须带SOS.dll的路径。加载了它,然后执行 .loadby sos clr ,表示调试.NET托管程序。
开始漫长的等待,程序窗口提示:
*BUSY*
Downloading symbols for [clr.pdb] /
等到相关的符号文件全部下载完毕,终于出现了久违的成功界面:
CPU utilization: 11% Worker Thread: Total: 8 Running: 0 Idle: 8 MaxLimit: 32767 MinLimit: 8 Work Request in Queue: 0 -------------------------------------- Number of Timers: 14 -------------------------------------- Completion Port Thread:Total: 1 Free: 1 MaxFree: 16 CurrentLimit: 0 MaxLimit: 1000 MinLimit: 8
有关WinDbg详细的调试命名,可以参考下面文章:
windbg调试命令
http://www.cnblogs.com/kekec/archive/2012/12/02/2798020.html
或者,你也可以随时用帮助,查看如何使用:
0:000> !help ------------------------------------------------------------------------------- SOS is a debugger extension DLL designed to aid in the debugging of managed programs. Functions are listed by category, then roughly in order of importance. Shortcut names for popular functions are listed in parenthesis. Type "!help <functionname>" for detailed info on that function. Object Inspection Examining code and stacks ----------------------------- ----------------------------- DumpObj (do) Threads DumpArray (da) ThreadState DumpStackObjects (dso) IP2MD DumpHeap U DumpVC DumpStack GCRoot EEStack ObjSize CLRStack FinalizeQueue GCInfo PrintException (pe) EHInfo TraverseHeap BPMD COMState Examining CLR data structures Diagnostic Utilities ----------------------------- ----------------------------- DumpDomain VerifyHeap EEHeap VerifyObj Name2EE FindRoots SyncBlk HeapStat DumpMT GCWhere DumpClass ListNearObj (lno) DumpMD GCHandles Token2EE GCHandleLeaks EEVersion FinalizeQueue (fq) DumpModule FindAppDomain ThreadPool SaveModule DumpAssembly ProcInfo DumpSigElem StopOnException (soe) DumpRuntimeTypes DumpLog DumpSig VMMap RCWCleanupList VMStat DumpIL MinidumpMode AnalyzeOOM (ao) Examining the GC history Other ----------------------------- ----------------------------- HistInit FAQ HistRoot HistObj HistObjFind HistClear
也可以使用 .help命令,这个不一样,这里列出部分命令:
0:000> .help . commands: .allow_exec_cmds [0|1] - control execution commands .allow_image_mapping [0|1] - control on-demand image file mapping .apply_dbp [<options>] - add current data breakpoint state to a register context .asm [<options>] - set disassembly options .asm- [<options>] - clear disassembly options .attach <proc> - attach to <proc> at next execution .block { <commands> } - brackets a set of commands for nested execution .break - break out of the enclosing loop
也可使用.hh命令:
Use ".hh <command>" or open debugger.chm in the debuggers directory to get
detailed documentation on a command.
OK,有了dump文件生成,调试环境配置,还有帮助命令,现在总算是入门了。
WinDbg调试.NET程序入门
标签: