我正在使用 WinDbg 和 SOS 分析故障转储(如何在托管应用程序的框架代码中调试 System.ExecutionEngineException)。
我能够在托管堆上列出某种类型的对象:字符串
!DumpHeap -mt 7239afb0 -min 50
I can look at the class:
!DumpObj 0x0a7be6a4
Name:        System.String
...
File:        C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
String:      C:\Program Files (x86)\XSLStylesheets
Fields:
      MT    Field   Offset                 Type VT     Attr    Value Name
7239c770  40000aa        4         System.Int32  1 instance       74 m_stringLength
7239b9a8  40000ab        8          System.Char  1 instance       43 m_firstChar
7239afb0  40000ac        c        System.String  0   shared   static Empty
现在如何读取字符串值?以及当它是类的字段时如何访问字符串?
Fields:
      MT    Field   Offset                 Type VT     Attr    Value Name
...
7239afb0  4000719        c        System.String  0 instance 01182390 m_Name
编辑
因为我在评论中询问后得到了答案,所以我在这里进行了解释。要获取字符串值,只需使用!do address或!do -nofields address(!do =!DumpObj)。结果是以“ String: ”开头的行,并且该行包含所需的值(在我的情况下,它包含一个路径,我不认为这是一个正确的值)。
要访问作为另一个对象的字段的对象,我们使用列中的值Value作为 !do 的地址。因此,对于示例中的字段 m_Name,我们运行!do 0x01182390.