Debugging managed app with SOS - the start

Debugging managed code using windbg is always a headache to me and I kind of avoid doing that by using Visual Studio. It becomes a shame as time going since some people think I know it well. So I decided to learn from scratch - by debugging my own small app.

 

First thing is to load the sos extension. I like .loadby more than .load because it always load the correct version of sos extension. If you are debugging a dump it's easy since you can use ".loadby sos mscorwks". But .loadby doesn't work if you are starting the application with windbg since mscorwks has not been loaded yet. The workaround is a little bit tricky - type following in your debugger "sxe lh:mscorlib" then GO. This tells the debugger to stop execution when mscorlib is loaded, and of course mscorwks is loaded at that time. Afterwards you can load sos successfully using .loadby as above. Details you can refer to this excellent post.

 

Do play around !dumpmodule, !dumpmt and !dumpmd a little bit please. It took me a while to understand and remember what they are intended for given their name and their parameters' name are similar. :) We can tell which method has been jitted using !dumpmt. Powerful, isn't?

 

0:000> !ip2md @eip
MethodDesc: 007131e8
Method Name: TestException.TestFinally.Go2()
Class: 0071145c
MethodTable: 00713200
mdToken: 06000002
Module: 00712d8c
IsJitted: yes
m_CodeOrIL: 00de01c8


0:000> !dumpmt -md 00713200
EEClass: 0071145c
Module: 00712d8c
Name: TestException.TestFinally
mdToken: 02000002  (D:/Work/LearnCSharp/Exception/bin/Debug/Exception.exe)
BaseSize: 0xc
ComponentSize: 0x0
Number of IFaces in IFaceMap: 0
Slots in VTable: 8
--------------------------------------
MethodDesc Table
   Entry MethodDesc      JIT Name
79371278   7914b928   PreJIT System.Object.ToString()
7936b3b0   7914b930   PreJIT System.Object.Equals(System.Object)
7936b3d0   7914b948   PreJIT System.Object.GetHashCode()
793624d0   7914b950   PreJIT System.Object.Finalize()
0071c035   007131e0     NONE TestException.TestFinally.Go1()
00de01c8   007131e8      JIT TestException.TestFinally.Go2()
00de00f0   007131f0      JIT TestException.TestFinally.Go3()
00de00c0   007131f8      JIT TestException.TestFinally..ctor()

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值