惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
J
Java Code Geeks
L
LangChain Blog
V
V2EX
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
博客园 - Franky
Microsoft Azure Blog
Microsoft Azure Blog
Jina AI
Jina AI
Blog — PlanetScale
Blog — PlanetScale
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
博客园 - 司徒正美
B
Blog
G
Google Developers Blog
Stack Overflow Blog
Stack Overflow Blog
罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
Engineering at Meta
Engineering at Meta
MyScale Blog
MyScale Blog
有赞技术团队
有赞技术团队
Hugging Face - Blog
Hugging Face - Blog

博客园 - stone

release 版本dll的调试 dead lock in thread pool Excel C# Automation 如何让iframe 自动适应窗口的高度 自定义Silverlight toolkit 里面的 Column Chart 的data point 二叉树算法题 How to do live debug the Managed code in Windows Phone 7 单链表操作相关算法 BUG: "Old format or invalid type library" error when automating Excel on 64 bit server 2008 - stone enable Assembly Load Trace 不合法的XML字符必须被替换为相应的实体 - stone - 博客园 如何修改 VS 自动生成的 COM interop dll Sql server 2005 connection string - stone Get depth of BTree Quick sort C# code(2) Quick sort C# code use the network trace, from msdn. - stone 字节流编码获取原来这么复杂,但也很简单 通过DataTable获得表的主键 让IE支持自己的协议
VS中Sos调试扩展简介 (转帖)
stone · 2009-04-02 · via 博客园 - stone

VS 提供比较完备的代码调试功能,像F9,F10,F11,Attach这些为大家所熟知的。除此之外,在某些特殊的情况下,或者仅仅是由于好奇(比如我),我们希望跟踪程序运行时候的内存变化,这时我们可以通过载入sos.dll来辅助调试。
 
SOS“Son of Strike”的缩写,应该就是一个代号,没什么具体意思。
 
在使用SOS之前,需要于VS 中做如下设置:
1、需要在项目->属性->调试-〉启用非托管代码调试,为代码打上断点,然后运行代码
2、打开调试-〉窗口-〉即时
3、在即时窗口中输入 !load sos.dll 加载调试模块(如果有必要可以输入sos.dll的全路径,位于C:"WINDOWS"Microsoft.NET"Framework"的相应版本下)
 
完成后我们就可以执行SOS中的命令了,命令以!开始,格式如:![command] [options]。以下表格介绍部分常见的SOS命令:
CLRstack [-p][-l][-a]
显示CLR栈上的内容(常用-a参数
[-p]
显示托管函数的参数
[-l]
 
[-a]
 
Dumpheap [-stat] [-min <size>][-max <size>] [-thinlock] [-mt <MethodTable address>] [-type <partial type name>][start [end]]
显示堆上的内容(常用-stat参数
[-stat]
选项将输出限制为统计类型摘要
[-min <size>]
选项忽略小于 size 参数指定的大小(单位为字节)的对象
[-max <size>]
选项忽略大于 size 参数指定的大小(单位为字节)的对象
[-thinlock]
选项报告 ThinLocks 有关更多信息,请参见 SyncBlk 命令
[-mt <MethodTable address>]
选项仅列出与指定的 MethodTable 结构对应的那些对象
[-type <partial type name>]
选项仅列出其类型名称属于指定字符串的子串的那些对象
[start [end]]
参数从指定的地址处开始列出,end 参数在指定的地址处停止列出
Do/dumpobj <object address>
显示有关指定地址处的对象的信息
Dumpstack [-EE] [top stack [bottom stack]]
显示栈内容
[-EE]
使 DumpStack 命令仅显示托管函数
[top stack [bottom stack]]
使用 top bottom 参数可限制 x86 平台上显示的堆栈帧
Dso/dumpstackobjects [-verify] [top stack [bottom stack]]
显示在当前堆栈的边界内找到的所有托管对象
[-verify]
选项验证对象字段的每个非静态 CLASS 字段
[top stack [bottom stack]]
 
Da/dumparray [-start <startIndex>] [-length <length>] [-details] [-nofields] <array object address>
检查数组对象的元素(常用参数-details
[-start <startIndex>]
选项指定开始显示元素的起始索引
[-length <length>]
选项指定要显示的元素数量
[-details]
选项使用 DumpObj DumpVC 格式显示元素的详细信息
[-nofields]
选项可阻止显示数组。 此选项只有在指定了 -detail 选项之后才可用
DumpMT [-MD] <MethodTable address>
显示有关指定地址处的方法表的信息
[-MD]
选项将显示与对象一起定义的所有方法的列表
DumpVC <MethodTable address> <Address>
显示有关指定地址处的值类字段的信息
help [<command>] [<faq>]
在未指定参数时显示所有可用命令,或者显示有关指定命令的详细帮助信息。
[<command>]
指定要查看的命令
[<faq>]
显示关于此命令的的常见问题回答
 
剩余的命令,你可以通过MSDN导航,查找:
msdn library>>.NET开发>>.net framework 3.5>>.net framework;>>工具(.net framework>>.net framework 工具;>>sos调试扩展。
 
 
下面演示查看DataTable对象在内存中的情况,C#代码如下:
static void Main(string[] args)
{
    DataTable dt = new DataTable();
    dt.Columns.Add("fname");
    dt.Columns.Add("fvalue");
    dt.Rows.Add("zhang san", 100);
    dt.AcceptChanges();//Breakpoint 1
    dt.Rows[0][1] = 112;
}//Breakpoint 2
 
首先F5到达breakpoint 1,然后执行以下命令:
 
!load sos.dll
extension C:"WINDOWS"Microsoft.NET"Framework"v2.0.50727"sos.dll loaded
!dumpstackobjects
PDB symbol for mscorwks.dll not loaded 
OS Thread Id: 0x1180 (4480)
ESP/REG Object   Name
0012f098 0137d27c System.Data.DataTable (1)
0012f0bc 0137d27c System.Data.DataTable
0012f200 0137d27c System.Data.DataTable
0012f208 01367cc4 System.Object[]    (System.Object[])
0012f444 01366a4c System.Object[]    (System.String[])
0012f45c 0137cdc8 System.Object[]    (System.String[])
0012f534 0137cdc8 System.Object[]    (System.String[])
0012f6e0 0137cdc8 System.Object[]    (System.String[])
0012f708 01366a4c System.Object[]    (System.String[])
 
执行dumpstackobjects后的结果列表共三列,第一列esp/reg不知道所指为何,可能是寄存器相关的一些东西;第二列object是对象的指针,在下面的do命令中我们将用到;第三列name为对象类型。除了datatable外,还有向个object[],可能是main方法的参数或者其它的一些东西。
 
!do 0137d27c
Name: System.Data.DataTable
MethodTable: 65407d48
EEClass: 654078f8
Size: 296(0x128) bytes
 (C:"WINDOWS"assembly"GAC_32"System.Data"2.0.0.0__b77a5c561934e089"System.Data.dll)
Fields:
      MT    Field   Offset                 Type VT     Attr    Value Name
7a7567d8 40009a3        4 ...ponentModel.ISite 0 instance 00000000 site
7a755968 40009a4        8 ....EventHandlerList 0 instance 00000000 events
790fd0f0 40009a2      1e8        System.Object 0   static 00000000 EventDisposed
65406ecc 4000799        c System.Data.DataSet 0 instance 00000000 dataSet
65409004 400079a       10 System.Data.DataView 0 instance 00000000 defaultView
79102290 400079b       d0         System.Int32 1 instance        2 nextRowID
654097e8 400079c       14 ...DataRowCollection 0 instance 01367148 rowCollection
654094f4 400079d       18 ...aColumnCollection 0 instance 01366ff8 columnCollection (1)
65409638 400079e       1c ...straintCollection 0 instance 01367110 constraintCollection
79102290 400079f       d4         System.Int32 1 instance        2 elementColumnCount
6540a0e8 40007a0       20 ...elationCollection 0 instance 00000000 parentRelationsCollection
6540a0e8 40007a1       24 ...elationCollection 0 instance 00000000 childRelationsCollection
654093f4 40007a2       28 ...ata.RecordManager 0 instance 01366fb4 recordManager
00000000 40007a3       2c                       0 instance 01367660 indexes
00000000 40007a4       30                       0 instance 00000000 shadowIndexes
79102290 40007a5       d8         System.Int32 1 instance        0 shadowCount
65410fd0 40007a6       34 ...ropertyCollection 0 instance 00000000 extendedProperties
790fd8c4 40007a7       38        System.String 0 instance 01344fa0 tableName
790fd8c4 40007a8       3c        System.String 0 instance 00000000 tableNamespace
790fd8c4 40007a9       40        System.String 0 instance 01344fa0 tablePrefix
6540a93c 40007aa       44 ...ta.DataExpression 0 instance 00000000 displayExpression
7910be50 40007ab       f0       System.Boolean 1 instance        1 fNestedInDataset
791028f4 40007ac       48 ...ation.CultureInfo 0 instance 01344fb4 _culture
7910be50 40007ad       f1       System.Boolean 1 instance        0 _cultureUserSet
7911354c 40007ae       4c ...ation.CompareInfo 0 instance 00000000 _compareInfo
79124788 40007af       dc         System.Int32 1 instance       25 _compareFlags
79103200 40007b0       50 ...m.IFormatProvider 0 instance 00000000 _formatProvider
791168f8 40007b1       54 ...em.StringComparer 0 instance 01367b38 _hashCodeProvider
7910be50 40007b2       f2       System.Boolean 1 instance        0 _caseSensitive
7910be50 40007b3       f3       System.Boolean 1 instance        0 _caseSensitiveUserSet
790fd8c4 40007b4       58        System.String 0 instance 00000000 encodedTableName
654088b4 40007b5       5c ...m.Data.DataColumn 0 instance 00000000 xmlText
654088b4 40007b6       60 ...m.Data.DataColumn 0 instance 00000000 _colUnique
7910be50 40007b7       f4       System.Boolean 1 instance        0 textOnly
7910c52c 40007b8      104       System.Decimal 1 instance 0137d380 minOccurs
7910c52c 40007b9      114       System.Decimal 1 instance 0137d390 maxOccurs
7910be50 40007ba       f5       System.Boolean 1 instance        0 repeatableElement
790fd0f0 40007bb       64        System.Object 0 instance 00000000 typeName
6540b250 40007bf       68 ....UniqueConstraint 0 instance 00000000 primaryKey
65412da4 40007c1       6c ...Data.IndexField[] 0 instance 0137d3d0 _primaryIndex
7912d8f8 40007c2       70      System.Object[] 0 instance 00000000 delayedSetPrimaryKey
65409b14 40007c3       74    System.Data.Index 0 instance 00000000 loadIndex
65409b14 40007c4       78    System.Data.Index 0 instance 00000000 loadIndexwithOriginalAdded
65409b14 40007c5       7c    System.Data.Index 0 instance 00000000 loadIndexwithCurrentDeleted
79102290 40007c6       e0         System.Int32 1 instance        0 _suspendIndexEvents
7910be50 40007c7       f6       System.Boolean 1 instance        0 savedEnforceConstraints
7910be50 40007c8       f7       System.Boolean 1 instance        0 inDataLoad
7910be50 40007c9       f8       System.Boolean 1 instance        0 initialLoad
7910be50 40007ca       f9       System.Boolean 1 instance        0 schemaLoading
7910be50 40007cb       fa       System.Boolean 1 instance        1 enforceConstraints
7910be50 40007cc       fb       System.Boolean 1 instance        0 _suspendEnforceConstraints
7910be50 40007cd       fc       System.Boolean 1 instance        0 fInitInProgress
7910be50 40007ce       fd       System.Boolean 1 instance        0 inLoad
7910be50 40007cf       fe       System.Boolean 1 instance        0 fInLoadDiffgram
79101e20 40007d0       ff          System.Byte 1 instance        2 _isTypedDataTable
7912d8f8 40007d1       80      System.Object[] 0 instance 00000000 EmptyDataRowArray
7a764404 40007d2       84 ...criptorCollection 0 instance 00000000 propertyDescriptorCollectionCache
7912d8f8 40007d4       88      System.Object[] 0 instance 0137d3dc _nestedParentRelations
00000000 40007d5       8c                       0 instance 00000000 dependentColumns
7910be50 40007d6      100       System.Boolean 1 instance        0 mergingData
6541d27c 40007d7       90 ...hangeEventHandler 0 instance 00000000 onRowChangedDelegate
6541d27c 40007d8       94 ...hangeEventHandler 0 instance 00000000 onRowChangingDelegate
6541d27c 40007d9       98 ...hangeEventHandler 0 instance 00000000 onRowDeletingDelegate
6541d27c 40007da       9c ...hangeEventHandler 0 instance 00000000 onRowDeletedDelegate
6541c36c 40007db       a0 ...hangeEventHandler 0 instance 00000000 onColumnChangedDelegate
6541c36c 40007dc       a4 ...hangeEventHandler 0 instance 00000000 onColumnChangingDelegate
6541d8ec 40007dd       a8 ...ClearEventHandler 0 instance 00000000 onTableClearingDelegate
6541d8ec 40007de       ac ...ClearEventHandler 0 instance 00000000 onTableClearedDelegate
6541d97c 40007df       b0 ...ewRowEventHandler 0 instance 00000000 onTableNewRowDelegate
7a7689e4 40007e0       b4 ...angedEventHandler 0 instance 00000000 onPropertyChangingDelegate
791044dc 40007e1       b8 System.EventHandler 0 instance 00000000 onInitialized
65409c7c 40007e2       bc ...ta.DataRowBuilder  0 instance 01367688 rowBuilder
00000000 40007e3       c0                       0 instance 0137d440 delayedViews
00000000 40007e4       c4                       0 instance 0137d468 _dataViewListeners
79101fe4 40007e5       c8 ...ections.Hashtable 0 instance 00000000 rowDiffId
79108ba4 40007e6       cc ....ReaderWriterLock 0 instance 0137d490 indexesLock
79102290 40007e7       e4         System.Int32 1 instance       -1 ukColumnPositionForInference
654116b8 40007e8       e8         System.Int32 1 instance        0 _remotingFormat
79102290 40007ea       ec         System.Int32 1 instance        1 _objectID
7912d7c0 40007bc      15c       System.Int32[] 0   static 0137d3a4 zeroIntegers
7912d8f8 40007bd      160      System.Object[] 0   static 0137d3b0 zeroColumns
7912d8f8 40007be      164      System.Object[] 0   static 0137d3c0 zeroRows
65412da4 40007c0      168 ...Data.IndexField[] 0   static 0137d3d0 zeroIndexField
7912d8f8 40007d3      16c      System.Object[] 0   static 0137d3dc EmptyArrayDataRelation
79102290 40007e9      490         System.Int32 1   static        1 _objectTypeCount
 
通过do命令我们dumpdatatable对象在堆上的状况,从上面可以看出datatable对象比较复杂,除去其它我们不关心的,我们找到了columncollection
 
!do 01366ff8
Name: System.Data.DataColumnCollection
MethodTable: 654094f4
EEClass: 65409484
Size: 56(0x38) bytes
 (C:"WINDOWS"assembly"GAC_32"System.Data"2.0.0.0__b77a5c561934e089"System.Data.dll)
Fields:
      MT    Field   Offset                 Type VT     Attr    Value Name
7a766474 4000686      148 ...onChangeEventArgs 0   static 00000000 RefreshEventArgs
65407d48 40006dc        4 ...em.Data.DataTable 0 instance 0137d27c table
79104368 40006dd        8 ...ections.ArrayList 0 instance 01367030 _list
79102290 40006de       24         System.Int32 1 instance        1 defaultNameIndex
7912d8f8 40006df        c      System.Object[] 0 instance 00000000 delayedAddRangeColumns
79101fe4 40006e0       10 ...ections.Hashtable 0 instance 01367048 columnFromName
7a7664d4 40006e1       14 ...hangeEventHandler 0 instance 00000000 onCollectionChangedDelegate
7a7664d4 40006e2       18 ...hangeEventHandler 0 instance 00000000 onCollectionChangingDelegate
7a7664d4 40006e3       1c ...hangeEventHandler 0 instance 00000000 onColumnPropertyChangedDelegate
7910be50 40006e4       30       System.Boolean 1 instance        0 fInClear
7912d8f8 40006e5       20      System.Object[] 0 instance 0137d3b0 columnsImplementingIChangeTracking
79102290 40006e6       28         System.Int32 1 instance        0 nColumnsImplementingIChangeTracking
79102290 40006e7       2c         System.Int32 1 instance        0 nColumnsImplementingIRevertibleChangeTracking
 
!do 01367030
Name: System.Collections.ArrayList
MethodTable: 79104368
EEClass: 791042bc
Size: 24(0x18) bytes
 (C:"WINDOWS"assembly"GAC_32"mscorlib"2.0.0.0__b77a5c561934e089"mscorlib.dll)
Fields:
      MT    Field   Offset                 Type VT     Attr    Value Name
7912d8f8 40008ea        4      System.Object[] 0 instance 01367c10 _items
79102290 40008eb        c         System.Int32 1 instance        2 _size
79102290 40008ec       10         System.Int32 1 instance        2 _version
790fd0f0 40008ed        8        System.Object 0 instance 00000000 _syncRoot
7912d8f8 40008ee      1c0      System.Object[] 0   shared   static emptyArray
    >> Domain:Value 0015c960:01341748 <<
 
!da -details 01367c10
Name: System.Object[]
MethodTable: 7912d8f8
EEClass: 7912de6c
Size: 32(0x20) bytes
Array: Rank 1, Number of elements 4, Type CLASS
Element Methodtable: 790fd0f0
[0] 01367698
    Name: System.Data.DataColumn
    MethodTable: 654088b4
    EEClass: 6540883c
    Size: 148(0x94) bytes
     (C:"WINDOWS"assembly"GAC_32"System.Data"2.0.0.0__b77a5c561934e089"System.Data.dll)
    Fields:
          MT    Field   Offset                 Type VT     Attr    Value Name
    7a7567d8 40009a3        4 ...ponentModel.ISite 0 instance 00000000 site
    7a755968 40009a4        8 ....EventHandlerList 0 instance 00000000 events
    790fd0f0 40009a2      1e8        System.Object 0   static 00000000 EventDisposed
    7910be50 40006b3       84       System.Boolean 1 instance        1 allowNull
    7910be50 40006b4       85       System.Boolean 1 instance        0 autoIncrement
    790ffcc8 40006b5        c         System.Int64 1 instance 1 autoIncrementStep
    790ffcc8 40006b6       14         System.Int64 1 instance 0 autoIncrementSeed
    790fd8c4 40006b7       24        System.String 0 instance 00000000 caption
    790fd8c4 40006b8       28        System.String 0 instance 0137d21c _columnName
    79106894 40006b9       2c          System.Type 0 instance 0134acf0 dataType
   790fd0f0 40006ba       30        System.Object 0 instance 013677f4 defaultValue
    654118d8 40006bb       68         System.Int32 1 instance        3 _dateTimeMode
    6540a93c 40006bc       34 ...ta.DataExpression 0 instance 00000000 expression
    79102290 40006bd       6c         System.Int32 1 instance       -1 maxLength
    79102290 40006be       70         System.Int32 1 instance        0 _ordinal
    7910be50 40006bf       86       System.Boolean 1 instance        0 readOnly
    65409b14 40006c0       38    System.Data.Index 0 instance 00000000 sortIndex
    65407d48 40006c1       3c ...em.Data.DataTable 0 instance 0137d27c table
    7910be50 40006c2       87       System.Boolean 1 instance        0 unique
    65410da8 40006c3       74         System.Int32 1 instance        1 columnMapping
    79102290 40006c4       78         System.Int32 1 instance 1328915167 _hashCode
    79102290 40006c5       7c         System.Int32 1 instance        0 errors
    7910be50 40006c6       88       System.Boolean 1 instance        0 isSqlType
    7910be50 40006c7       89       System.Boolean 1 instance        0 implementsINullable
    7910be50 40006c8       8a       System.Boolean 1 instance        0 implementsIChangeTracking
    7910be50 40006c9       8b       System.Boolean 1 instance        0 implementsIRevertibleChangeTracking
    7910be50 40006ca       8c       System.Boolean 1 instance        0 implementsIXMLSerializable
    7910be50 40006cb       8d       System.Boolean 1 instance        1 defaultValueIsNull
    00000000 40006cc       40                       0 instance 00000000 dependentColumns
    65410fd0 40006cd       44 ...ropertyCollection 0 instance 00000000 extendedProperties
    7a7689e4 40006ce       48 ...angedEventHandler 0 instance 00000000 onPropertyChangingDelegate
    65401748 40006cf       4c ...ommon.DataStorage 0 instance 01367ce8 _storage
    790ffcc8 40006d0       1c         System.Int64 1 instance 0 autoIncrementCurrent
    790fd8c4 40006d1       50        System.String 0 instance 00000000 _columnUri
    790fd8c4 40006d2       54        System.String 0 instance 01344fa0 _columnPrefix
    790fd8c4 40006d3       58        System.String 0 instance 00000000 encodedColumnName
    790fd8c4 40006d4       5c        System.String 0 instance 01344fa0 description
    790fd8c4 40006d5       60        System.String 0 instance 01344fa0 dttype
    65409d70 40006d6       64 ...m.Data.SimpleType 0 instance 00000000 simpleType
    79102290 40006d8       80         System.Int32 1 instance        1 _objectID
    79102290 40006d7      47c         System.Int32 1   static        2 _objectTypeCount
[1] 01367c30 (1)
    Name: System.Data.DataColumn
    MethodTable: 654088b4
    EEClass: 6540883c
    Size: 148(0x94) bytes
     (C:"WINDOWS"assembly"GAC_32"System.Data"2.0.0.0__b77a5c561934e089"System.Data.dll)
    Fields:
          MT    Field   Offset                 Type VT     Attr    Value Name
    7a7567d8 40009a3        4 ...ponentModel.ISite 0 instance 00000000 site
    7a755968 40009a4        8 ....EventHandlerList 0 instance 00000000 events
    790fd0f0 40009a2      1e8        System.Object 0   static 00000000 EventDisposed
    7910be50 40006b3       84       System.Boolean 1 instance        1 allowNull
    7910be50 40006b4       85       System.Boolean 1 instance        0 autoIncrement
    790ffcc8 40006b5        c         System.Int64 1 instance 1 autoIncrementStep
    790ffcc8 40006b6       14         System.Int64 1 instance 0 autoIncrementSeed
    790fd8c4 40006b7       24        System.String 0 instance 00000000 caption
    790fd8c4 40006b8       28        System.String 0 instance 0137d238 _columnName
    79106894 40006b9       2c          System.Type 0 instance 0134acf0 dataType
    790fd0f0 40006ba       30        System.Object 0 instance 013677f4 defaultValue
    654118d8 40006bb       68         System.Int32 1 instance        3 _dateTimeMode
    6540a93c 40006bc       34 ...ta.DataExpression 0 instance 00000000 expression
    79102290 40006bd       6c         System.Int32 1 instance       -1 maxLength
    79102290 40006be       70         System.Int32 1 instance        1 _ordinal
    7910be50 40006bf       86       System.Boolean 1 instance        0 readOnly
    65409b14 40006c0       38    System.Data.Index 0 instance 00000000 sortIndex
    65407d48 40006c1       3c ...em.Data.DataTable 0 instance 0137d27c table
    7910be50 40006c2       87       System.Boolean 1 instance        0 unique
    65410da8 40006c3       74         System.Int32 1 instance        1 columnMapping
    79102290 40006c4       78         System.Int32 1 instance -1185130635 _hashCode
    79102290 40006c5       7c         System.Int32 1 instance        0 errors
    7910be50 40006c6       88       System.Boolean 1 instance        0 isSqlType
    7910be50 40006c7       89       System.Boolean 1 instance        0 implementsINullable
    7910be50 40006c8       8a       System.Boolean 1 instance        0 implementsIChangeTracking
    7910be50 40006c9       8b       System.Boolean 1 instance        0 implementsIRevertibleChangeTracking
    7910be50 40006ca       8c       System.Boolean 1 instance        0 implementsIXMLSerializable
    7910be50 40006cb       8d       System.Boolean  1 instance        1 defaultValueIsNull
    00000000 40006cc       40                       0 instance 00000000 dependentColumns
    65410fd0 40006cd       44 ...ropertyCollection 0 instance 00000000 extendedProperties
    7a7689e4 40006ce       48 ...angedEventHandler 0 instance 00000000 onPropertyChangingDelegate
    65401748 40006cf       4c ...ommon.DataStorage 0 instance 01367f24 _storage (2)
    790ffcc8 40006d0       1c         System.Int64 1 instance 0 autoIncrementCurrent
    790fd8c4 40006d1       50        System.String 0 instance 00000000 _columnUri
    790fd8c4 40006d2       54        System.String 0 instance 01344fa0 _columnPrefix
    790fd8c4 40006d3       58        System.String 0 instance 00000000 encodedColumnName
    790fd8c4 40006d4       5c        System.String 0 instance 01344fa0 description
    790fd8c4 40006d5       60        System.String 0 instance 01344fa0 dttype
    65409d70 40006d6       64 ...m.Data.SimpleType 0 instance 00000000 simpleType
    79102290 40006d8       80         System.Int32 1 instance        2 _objectID
    79102290 40006d7      47c         System.Int32 1   static        2 _objectTypeCount
[2] null
[3] null
 
(1)由于_items是一个数组,我们通过da命令取得数组的内部情况,数组包含4个元素(由程序代码可知我们只有声明了两列,因此为何出现4个元素待研究)。
(2)datacolumn的内容则存储于_storage中,红色标识行(2)
 
!do 01367f24
Name: System.Data.Common.StringStorage
MethodTable: 6540b09c
EEClass: 65450e8c
Size: 44(0x2c) bytes
 (C:"WINDOWS"assembly"GAC_32"System.Data"2.0.0.0__b77a5c561934e089"System.Data.dll)
Fields:
      MT    Field   Offset                 Type VT     Attr    Value Name
654088b4 4000b2b        4 ...m.Data.DataColumn 0 instance 01367c30 Column
65407d48 4000b2c        8 ...em.Data.DataTable 0 instance 0137d27c Table
79106894 4000b2d        c          System.Type 0 instance 0134acf0 DataType
65420068 4000b2e       1c         System.Int32 1 instance       18 StorageTypeCode
79123930 4000b2f       10 ...lections.BitArray 0 instance 00000000 dbNullBits
790fd0f0 4000b30       14        System.Object 0 instance 790d884c DefaultValue
790fd0f0 4000b31       18        System.Object 0 instance 013677f4 NullValue
7910be50 4000b32       20       System.Boolean 1 instance        0 IsCloneable
7910be50 4000b33       21       System.Boolean 1 instance        0 IsCustomDefinedType
7910be50 4000b34       22       System.Boolean 1 instance        1 IsStringType
7910be50 4000b35       23       System.Boolean 1 instance        0 IsValueType
7912d8f8 4000b2a      1dc      System.Object[] 0   static 01367800 StorageClassType
7912d8f8 4000cb1       24      System.Object[] 0 instance 01367f50 values
 
!da -details 01367f50
Name: System.String[]
MethodTable: 7912d8f8
EEClass: 7912de6c
Size: 528(0x210) bytes
Array: Rank 1, Number of elements 128, Type CLASS
Element Methodtable: 790fd8c4
[0] 01368600 (1)
    Name: System.String
    MethodTable: 790fd8c4
    EEClass: 790fd824
    Size: 24(0x18) bytes
     (C:"WINDOWS"assembly"GAC_32"mscorlib"2.0.0.0__b77a5c561934e089"mscorlib.dll)
    String:     100    (2)
    Fields:
          MT    Field   Offset                 Type VT     Attr    Value Name
    79102290 4000096        4         System.Int32 1 instance        4 m_arrayLength
    79102290 4000097        8         System.Int32 1 instance        3 m_stringLength
    790ff328 4000098        c          System.Char 1 instance       31 m_firstChar
    790fd8c4 4000099       10        System.String 0   shared   static Empty
    >> Domain:Value 0015c960:790d884c <<
    7912dd40 400009a       14        System.Char[] 0   shared   static WhitespaceChars
    >> Domain:Value 0015c960:013414e0 <<
[1] null
[2] null
[3] null
[4] null
[5] null
[6] null
[7] null
[8] null
[9] null
[10] null
[11] null
[12] null
[13] null
[14] null
[15] null
[16] null
[17] null
[18] null
[19] null
[20] null
[21] null
[22] null
[23] null
[24] null
[25] null
[26] null
[27] null
[28] null
[29] null
[30] null
[31] null
[32] null
[33] null
[34] null
[35] null
[36] null
[37] null
[38] null
[39] null
[40] null
[41] null
[42] null
[43] null
[44] null
[45] null
[46] null
[47] null
[48] null
[49] null
[50] null
[51] null
[52] null
[53] null
[54] null
[55] null
[56] null
[57] null
[58] null
[59] null
[60] null
[61] null
[62] null
[63] null
[64] null
[65] null
[66] null
[67] null
[68] null
[69] null
[70] null
[71] null
[72] null
[73] null
[74] null
[75] null
[76] null
[77] null
[78] null
[79] null
[80] null
[81] null
[82] null
[83] null
[84] null
[85] null
[86] null
[87] null
[88] null
[89] null
[90] null
[91] null
[92] null
[93] null
[94] null
[95] null
[96] null
[97] null
[98] null
[99] null
[100] null
[101] null
[102] null
[103] null
[104] null
[105] null
[106] null
[107] null
[108] null
[109] null
[110] null
[111] null
[112] null
[113] null
[114] null
[115] null
[116] null
[117] null
[118] null
[119] null
[120] null
[121] null
[122] null
[123] null
[124] null
[125] null
[126] null
[127] null
 
(1)使用da命令获取values数组的内容,即datatable第二列的所有行的内容(由程序代码可知我们只有添加了一行,因此为何出现多余行待研究)。
(2)查看第一个数组元素的值:100
 
F5到达breakpoint 2,然后执行以下命令:
由于我们仅修改了datatable某一单元格的值,因此不会造成datatabledatacolumn或者其它一些对象的引用发生变化,因此当我们想要查看由于修改了某一单元格的值时,内存中的变化时,可以直接从上面的最后一步开始:
 
!da -details 01367f50
Name: System.String[]
MethodTable: 7912d8f8
EEClass: 7912de6c
Size: 528(0x210) bytes
Array: Rank 1, Number of elements 128, Type CLASS
Element Methodtable: 790fd8c4
[0] 01368600
    Name: System.String
    MethodTable: 790fd8c4
    EEClass: 790fd824
    Size: 24(0x18) bytes
     (C:"WINDOWS"assembly"GAC_32"mscorlib"2.0.0.0__b77a5c561934e089"mscorlib.dll)
    String:     100   
    Fields:
          MT    Field   Offset                 Type VT     Attr    Value Name
    79102290 4000096        4         System.Int32 1 instance        4 m_arrayLength
    79102290 4000097        8         System.Int32 1 instance        3 m_stringLength
    790ff328 4000098        c          System.Char 1 instance       31 m_firstChar
    790fd8c4 4000099       10        System.String 0   shared   static Empty
    >> Domain:Value 0015c960:790d884c <<
    7912dd40 400009a       14        System.Char[] 0   shared   static WhitespaceChars
    >> Domain:Value 0015c960:013414e0 <<
[1] 0137badc
    Name: System.String
    MethodTable: 790fd8c4
    EEClass: 790fd824
    Size: 24(0x18) bytes
     (C:"WINDOWS"assembly"GAC_32"mscorlib"2.0.0.0__b77a5c561934e089"mscorlib.dll)
    String:     112   
    Fields:
          MT    Field   Offset                 Type VT     Attr    Value Name
    79102290 4000096        4         System.Int32 1 instance        4 m_arrayLength
    79102290 4000097        8         System.Int32 1 instance        3 m_stringLength
    790ff328 4000098        c          System.Char 1 instance       31 m_firstChar
    790fd8c4 4000099       10        System.String 0   shared   static Empty
    >> Domain:Value 0015c960:790d884c <<
    7912dd40 400009a       14        System.Char[] 0   shared   static WhitespaceChars
    >> Domain:Value 0015c960:013414e0 <<
[2] null
……
[127] null
 
ps:由上面可见datacolumn中出现了两个元素,其中一个值为100,另一值为112即修改后的值,实际上对于datatable的修改,会导致产生不同的“版本”,由于修改之后未调用datatableacceptchanges()方法,故而表中仍然保留原值(关于datatable的特性描述,将在随后的一篇文章中给出)