sosex查看变量的命令!mdt

本文介绍如何利用Windbg中的!mdt命令来检查指定类型的字段或对象实例的字段,甚至可以递归查看整个对象图。通过几个具体的例子演示了如何对不同类型如System.DateTime、System.Guid等进行分析。

!mdt allows you to dump the fields of a given type by type name or to examine the fields of an object or value type instance.  Not only can you examine the fields of an object or value type instance, but you can also examine an entire object graph by specifying the “-r” (recursive) switch.  Want to examine a local variable or argument?  No problem.  Just enter “!mdt <Var Name>”, and voila!  The best way to demonstrate the power of this command is with a few examples.

0:000> !mdt System.DateTime 003bef0c 
003bef0c (System.DateTime) 2008/01/02 03:04:05.678 VALTYPE (MT=65cd9e98, ADDR=003bef0c)


0:000> !mdt theGuid 
003bef1c (System.Guid) {29b9c9c8-3751-42be-8c7a-8b92ff499588} VALTYPE (MT=65cd6c60, ADDR=003bef1c) 

0:000> !mdt ConsoleTestApp.TestStruct 
TestStruct 
   Member1: uint 
   Member2: uint 

0:000> !mdt ConsoleTestApp.TestStruct 003bef04 
003bef04 (ConsoleTestApp.TestStruct) VALTYPE (MT=001b3198, ADDR=003bef04) 
   Member1:0x162E (System.UInt32) 
   Member2:0x451434E0 (System.UInt32) 

0:000> !mdt 6487ce0 
06487ce0 (System.Runtime.Remoting.Proxies.__TransparentProxy) 
   _rp:06487cb4 (System.Runtime.Remoting.Proxies.RemotingProxy) 
   _stubData:06482a5c (BOXED System.IntPtr) VALTYPE (MT=65cfb114, ADDR=06482a60) 
   _pMT:65cf902c (System.IntPtr) 
   _pInterfaceMT:00000000 (System.IntPtr) 
   _stub:68c71e70 (System.IntPtr) 

0:000> !mdt 6487ce0 -r 
06487ce0 (System.Runtime.Remoting.Proxies.__TransparentProxy) 
   _rp:06487cb4 (System.Runtime.Remoting.Proxies.RemotingProxy) 
      _tp:06487ce0 (System.Runtime.Remoting.Proxies.__TransparentProxy) 
         <RECURSIVE> 
      _identity:06487a98 (System.Runtime.Remoting.Identity) 
         _flags:0x4 (System.Int32) 
         _tpOrObject:06487ce0 (System.Runtime.Remoting.Proxies.__TransparentProxy) 
            <RECURSIVE> 
         _ObjURI:06484c88 (System.String: "/49cf1154_ea17_4f51_b666_8f91a1263a00/0um3p4he0mnsfugppw1z7gkd_1.rem") 
         _URL:NULL (System.String) 
         _objRef:06484e10 (System.Runtime.Remoting.ObjRef) 
            uri:06484c88 (System.String: "/49cf1154_ea17_4f51_b666_8f91a1263a00/0um3p4he0mnsfugppw1z7gkd_1.rem") 
            typeInfo:064850f4 (System.Runtime.Remoting.TypeInfo) 
               serverType:064862d4 (System.String: "System.AppDomain, mscorlib, Version=2.0.0.0, Culture=neutral… 
               serverHierarchy:NULL (System.Object[]) 
               interfacesImplemented:064864bc (System.String[], Elements: 2) 
            envoyInfo:NULL (System.Runtime.Remoting.IEnvoyInfo) 
            channelInfo:06486b5c (System.Runtime.Remoting.ChannelInfo) 
               channelData:06486b68 (System.Object[], Elements: 1) 
            objrefFlags:0x0 (System.Int32) 
            srvIdentity:06484e2c (System.Runtime.InteropServices.GCHandle) VALTYPE (MT=65cfbcb8, ADDR=06484e2c) 
               m_handle:007e11ec (System.IntPtr) 
            domainID:0x2 (System.Int32) 
         _channelSink:06487c90 (System.Runtime.Remoting.Channels.CrossAppDomainSink) 
            _xadData:06483834 (System.Runtime.Remoting.Channels.CrossAppDomainData) 
               _ContextID:06483854 (BOXED System.Int32) BOXEDVAL=0x87C330 
               _DomainID:0x2 (System.Int32) 
               _processGuid:06483530 (System.String: "88866410_d263_4d8a_b901_8278132285be") 
         _envoyChain:06487ca8 (System.Runtime.Remoting.Messaging.EnvoyTerminatorSink) 
         _dph:NULL (System.Runtime.Remoting.Contexts.DynamicPropertyHolder) 
         _lease:NULL (System.Runtime.Remoting.Lifetime.Lease) 
      _serverObject:NULL (System.MarshalByRefObject) 
      _flags:0x3 (System.Runtime.Remoting.Proxies.RealProxyFlags) 
      _srvIdentity:06487cd0 (System.Runtime.InteropServices.GCHandle) VALTYPE (MT=65cfbcb8, ADDR=06487cd0) 
         m_handle:007e11ec (System.IntPtr) 
      _optFlags:0x7000000 (System.Int32) 
      _domainID:0x2 (System.Int32) 
      _ccm:NULL (System.Runtime.Remoting.Messaging.ConstructorCallMessage) 
      _ctorThread:0x0 (System.Int32) 
   _stubData:06482a5c (BOXED System.IntPtr) VALTYPE (MT=65cfb114, ADDR=06482a60) 
      m_value:ffffffff (System.UIntPtr) 
   _pMT:65cf902c (System.IntPtr) 
   _pInterfaceMT:00000000 (System.IntPtr) 
   _stub:68c71e70 (System.IntPtr)

转载于:https://www.cnblogs.com/yuanxiaoping_21cn_com/archive/2012/09/22/2698147.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值