Debugging Managed Code with Windbg

Here's a sample session on running Windbg in a test cloud. One afternoon, we kept getting the following email messages saying a service crashes:

 

"BGWatchdog64.exe" crashed on TK1MSG1061705. See d:/Data/MsgrDumps/TK1MSG1061705_BGWatchdog64.exe_2006-09-15_14-49-21-82.dmp on TK1MSG1061705 for more info.

 

That is an old problem. The BG Watchdog failed to handle an exception and the unhandled exception caused the crash. To fix the bug, we need to know more about this exception, using the following steps:

1.      Log on to machine "TK1MSG1061705" (See related wiki pages on how to access a testing cloud)

2.      Open a cmd window, and cd to "d:/Data/MsgrDumps"

3.      Start windbg by running "c:/Debuggers/windbg.exe /z TK1MSG1061705_BGWatchdog64.exe_2006-09-15_14-49-21-82.dmp"

4.      Load Psscor extension DLL (what's that?) using ".load psscor2" in Windbg. You can download Psscor2.dll from http://toolbox/sites/22153/ and copy them to "c:/Debuggers". (See related wiki pages on how to copy files to a testing cloud)

5.      Display all exceptions using Psscor command "!dae".

After step 5, we found the name, message, and stack trace of the unhandled exception, which is sufficient to identify the bug.

Tips:

1.      If ".load" doesn't work, you might need to give the full path (including .dll suffix) of the Psscor extension DLL

2.      For help on Psscor commands, use "!help"

 

 

These are the common commands that would help debugging dumps.

 

  • Loading symbols/Dlls
    • .sympath //symbols/symbols
      Sets the symbols path to the symbol share.
    • .load C:/WINDOWS/Microsoft.NET/Framework64/v2.0.50727/sos.dll
    • .load C:/WINDOWS/Microsoft.NET/Framework64/v2.0.50727/mscorwks.dll
      Load the dlls for SOS (for managed debugging) and .NET libraries
  • Dumping call-stacks
    • !threads            
    • !eestack
    • ~*e !CLRStack
    • ~*kb
  • Dumping heap
    • !dumpheap
    • !dumpheap -stat
    • !eeheap -gc
  • Dumping objects
    • !dumpheap -type <type name>
    • !dumpobj <object address>
    • !dumparray <object address> 

Interesting articles about debugging managed processes

http://blogs.msdn.com/yunjin/archive/2005/08/25/456355.aspx

http://blogs.msdn.com/tess/archive/2005/12/20/505862.aspx

http://blogs.msdn.com/tess/archive/2006/10/16/net-hang-debugging-walkthrough.aspx

 

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值