使用Windbg查看内存中DataTable的值时,其实方法和查看普通对象是一样的,唯一要注意的时,DataTable对象中值的存储方式有些特别,DataRow中的值是存存放在DataTable的columnCollection中的,思路如下:
1、使用!dumpheap -stat 查找到DataTable的引用
2、使用!do查找到columnCollection
3、查看columnCollection的items是一个OBJECT[],其中每个对象都是System.Data.DataColumn。
4、数据是存放在System.Data.DataColumn的storage中。

直接看代码和步骤吧。
测试代码如下:

Code
        private DataTable m_dtTable=null;

private void button1_Click(object sender, System.EventArgs e)
        {
            Thread thread=new Thread(new ThreadStart(DoThread));
            thread.Start();
        }

private void DoThread()
        {
            for(int Index=0;Index<100;Index++)
            {
                TestData data=new TestData("test",Index);
                DataRow dr=this.m_dtTable.NewRow();
                dr["Name"]="Test"+Index.ToString();
                dr["Age"]=Index;
                this.m_dtTable.Rows.Add(dr);
            }

GC.Collect();
        }

1.查找到DataTable的引用
0:003> !dumpheap -stat
total 3,790 objects
Statistics:
        MT      Count     TotalSize Class Name
0x7bec812c          1            12 System.Xml.XmlNonNormalizer
0x7bec7e9c          1            12 System.Xml.XmlDownloadManager
....................................................
0x002d6970          1           232 System.Data.DataTable
.......................................

2. 查看DataTable
0:003> !dumpheap -mt 0x002d6970
   Address         MT     Size  Gen
0x01e08a64 0x002d6970      232 1 System.Data.DataTable
total 1 objects
0:003> !dumpobj 0x01e08a64
Name: System.Data.DataTable
MethodTable 0x002d6970
EEClass 0x03df0bd0
Size 232(0xe8) bytes
GC Generation: 1
mdToken: 0x0200003d  (c:\windows\assembly\gac\system.data\1.0.5000.0__b77a5c561934e089\system.data.dll)
FieldDesc*: 0x002d5ab8
        MT      Field     Offset                 Type       Attr      Value Name
0x7b308b0c 0x4000583      0x4                CLASS   instance 0x00000000 site
0x7b308b0c 0x4000584      0x8                CLASS   instance 0x00000000 events
0x7b308b0c 0x4000582     0x44                CLASS     static 0x01e08d50 EventDisposed
0x002d6970 0x40003ee      0xc                CLASS   instance 0x00000000 dataSet
0x002d6970 0x40003ef     0x10                CLASS   instance 0x00000000 defaultView
0x002d6970 0x40003f0     0xa8         System.Int32   instance 101 nextRowID
0x002d6970 0x40003f1     0x14                CLASS   instance 0x01e08e34 rowCollection
0x002d6970 0x40003f2     0x18                CLASS   instance 0x01e09080 columnCollection
0x002d6970 0x40003f3     0x1c                CLASS   instance 0x01e08ec8 constraintCollection
0x002d6970 0x40003f4     0xac         System.Int32   instance 2 elementColumnCount
0x002d6970 0x40003f5     0x20                CLASS   instance 0x01e08f50 parentRelationsCollection
0x002d6970 0x40003f6     0x24                CLASS   instance 0x01e08fe0 childRelationsCollection
0x002d6970 0x40003f7     0x28                CLASS   instance 0x01e08d5c recordManager
0x002d6970 0x40003f8     0x2c                CLASS   instance 0x01e092b0 indexes
0x002d6970 0x40003f9     0x30                CLASS   instance 0x00000000 shadowIndexes
0x002d6970 0x40003fa     0x34                CLASS   instance 0x00000000 extendedProperties
0x002d6970 0x40003fb     0x38                CLASS   instance 0x01dd1200 tableName
0x002d6970 0x40003fc     0x3c                CLASS   instance 0x00000000 tableNamespace
0x002d6970 0x40003fd     0x40                CLASS   instance 0x01dd1200 tablePrefix
0x002d6970 0x40003fe     0xb4       System.Boolean   instance 0 caseSensitive
0x002d6970 0x40003ff     0xb5       System.Boolean   instance 1 caseSensitiveAmbient
0x002d6970 0x4000400     0x44                CLASS   instance 0x00000000 culture
0x002d6970 0x4000401     0x48                CLASS   instance 0x00000000 displayExpression
0x002d6970 0x4000402     0x4c                CLASS   instance 0x01dddac8 compareInfo
0x002d6970 0x4000403     0xb0         System.Int32   instance 25 compareFlags
0x002d6970 0x4000404     0xb6       System.Boolean   instance 1 fNestedInDataset
0x002d6970 0x4000405     0x50                CLASS   instance 0x00000000 encodedTableName
0x002d6970 0x4000406     0x54                CLASS   instance 0x00000000 xmlText
0x002d6970 0x4000407     0x58                CLASS   instance 0x00000000 _colUnique
0x002d6970 0x4000408     0xb7       System.Boolean   instance 0 textOnly
0x002d6970 0x4000409     0xc4            VALUETYPE   instance start at 01e08b28 minOccurs
0x002d6970 0x400040a     0xd4            VALUETYPE   instance start at 01e08b38 maxOccurs
0x002d6970 0x400040b     0xb8       System.Boolean   instance 0 repeatableElement
0x002d6970 0x400040c     0x5c                CLASS   instance 0x01e08b68 typeName
0x002d6970 0x400040f     0x60                CLASS   instance 0x00000000 primaryKey
0x002d6970 0x4000410     0x64                CLASS   instance 0x01e08b4c primaryIndex
0x002d6970 0x4000411     0x68                CLASS   instance 0x00000000 delayedSetPrimaryKey
..................................

查看具体的columnCollection
0:003> !do 0x01e09080
Name: System.Data.DataColumnCollection
MethodTable 0x002d71dc
EEClass 0x03df0c98
Size 52(0x34) bytes
GC Generation: 1
mdToken: 0x0200001a  (c:\windows\assembly\gac\system.data\1.0.5000.0__b77a5c561934e089\system.data.dll)
FieldDesc*: 0x002d6e18
        MT      Field     Offset                 Type       Attr      Value Name
0x002d6da0 0x4000331     0x3c                CLASS     static 0x01e08de4 RefreshEventArgs
0x002d71dc 0x4000376      0x4                CLASS   instance 0x01e08a64 table
0x002d71dc 0x4000377      0x8                CLASS   instance 0x01e090b4 list
0x002d71dc 0x4000378     0x28         System.Int32   instance 1 defaultNameIndex
0x002d71dc 0x4000379      0xc                CLASS   instance 0x00000000 delayedAddRangeColumns
0x002d71dc 0x400037a     0x10                CLASS   instance 0x01e09670 columnQueue
0x002d71dc 0x400037b     0x14                CLASS   instance 0x01e0911c columnFromName
0x002d71dc 0x400037c     0x18                CLASS   instance 0x01e091e0 hashCodeProvider
0x002d71dc 0x400037d     0x1c                CLASS   instance 0x00000000 onCollectionChangedDelegate
0x002d71dc 0x400037e     0x20                CLASS   instance 0x00000000 onCollectionChangingDelegate
0x002d71dc 0x400037f     0x24                CLASS   instance 0x00000000 onColumnPropertyChangedDelegate
0x002d71dc 0x4000380     0x2c       System.Boolean   instance 0 fInClear

查看list
0:003> !do 0x01e090b4
Name: System.Collections.ArrayList
MethodTable 0x79ba2f5c
EEClass 0x79ba3098
Size 24(0x18) bytes
GC Generation: 1
mdToken: 0x02000100  (c:\windows\microsoft.net\framework\v1.1.4322\mscorlib.dll)
FieldDesc*: 0x79ba30fc
        MT      Field     Offset                 Type       Attr      Value Name
0x79ba2f5c 0x4000362      0x4                CLASS   instance 0x01e090cc _items
0x79ba2f5c 0x4000363      0xc         System.Int32   instance 2 _size
0x79ba2f5c 0x4000364     0x10         System.Int32   instance 3 _version
0x79ba2f5c 0x4000365      0x8                CLASS   instance 0x00000000 _syncRoot

我们知道
0:003> !do -v 0x01e090cc
Name: System.Object[]
MethodTable 0x003f209c
EEClass 0x003f2018
Size 80(0x50) bytes
GC Generation: 1
Array: Rank 1, Type CLASS
Element Type: System.Object
Content: 16 items
------ Will only dump out valid managed objects ----
   Address            MT    Class Name
0x01e0932c    0x002d7bc8    System.Data.DataColumn
0x01e09518    0x002d7bc8    System.Data.DataColumn

----------
所有DataTable的数据都是存放在System.Data.DataColumn中,在System.Data.DataColumn中有一个数组,加上表中有100行数据的话,那么上面这个结合中的每个System.Data.DataColumn都有一个数组来存放这100行的当前列的数据。ok,让我们接到向下看。
以第一列数据为例
0:003> !do 0x01e0932c
Name: System.Data.DataColumn
MethodTable 0x002d7bc8
EEClass 0x03df0cfc
Size 128(0x80) bytes
GC Generation: 1
mdToken: 0x02000017  (c:\windows\assembly\gac\system.data\1.0.5000.0__b77a5c561934e089\system.data.dll)
FieldDesc*: 0x002d7304
        MT      Field     Offset                 Type       Attr      Value Name
0x7b308b0c 0x4000583      0x4                CLASS   instance 0x00000000 site
..............................................
0x002d7bc8 0x4000369     0x40                CLASS   instance 0x00000000 extendedProperties
0x002d7bc8 0x400036a     0x44                CLASS   instance 0x00000000 onPropertyChangingDelegate
0x002d7bc8 0x400036b     0x48                CLASS   instance 0x01e11688 storage
0x002d7bc8 0x400036c     0x1c         System.Int64   instance 0 autoIncrementCurrent

数据就存放在storage中。
0:003> !do 0x01e11688
Name: System.Data.Common.StringStorage
MethodTable 0x040562b4
EEClass 0x03dfc674
Size 24(0x18) bytes
GC Generation: 0
mdToken: 0x020000c6  (c:\windows\assembly\gac\system.data\1.0.5000.0__b77a5c561934e089\system.data.dll)
FieldDesc*: 0x04056198
        MT      Field     Offset                 Type       Attr      Value Name
0x0405557c 0x4000665      0x4                CLASS   instance 0x01dd43c4 type
0x0405557c 0x4000666      0x8                CLASS   instance 0x01e08a64 table
0x0405557c 0x4000667      0xc                CLASS   instance 0x00000000 dbNullBits
0x040562b4 0x4000761     0x10                CLASS   instance 0x01e116c8 values
0x040562b4 0x4000760     0x4c                CLASS     static 0x01e116a0 DBNullObject

使用!do -v 查看数组对象

0:003> !do -v 0x01e116c8
Name: System.Object[]
MethodTable 0x003f209c
EEClass 0x003f2018
Size 528(0x210) bytes
GC Generation: 0
Array: Rank 1, Type CLASS
Element Type: System.Object
Content: 128 items
------ Will only dump out valid managed objects ----
   Address            MT    Class Name
0x01e11da4    0x79b946b0    System.String
0x01e11f18    0x79b946b0    System.String
0x01e11ff4    0x79b946b0    System.String
0x01e120d0    0x79b946b0    System.String
0x01e121ac    0x79b946b0    System.String
0x01e12288    0x79b946b0    System.String
0x01e12364    0x79b946b0    System.String
0x01e12440    0x79b946b0    System.String
0x01e1251c    0x79b946b0    System.String
0x01e125f8    0x79b946b0    System.String
0x01e126d8    0x79b946b0    System.String
0x01e127bc    0x79b946b0    System.String
...........................
顺便找个数据来看看呢
0:003> !do 0x01e11da4
String: Test0

终于找到了他了吧。

转载于:https://www.cnblogs.com/jingzy/archive/2009/08/04/1538882.html

通过Windbg查看DataTable的值相关推荐

  1. pycharm如何在程序运行后查看变量的值,变量的类型(不通过print和debug的方式)

    文章目录: 1 问题描述 2 ycharm如何在程序运行后查看变量的值,变量的类型 1 问题描述 有时候程序中有很多变量,我们在调试程序的时候需要知道这些变量的的值和变量的类型,如果通过print的方 ...

  2. windbg查看设备栈设备树学习总结

    用windbg寻找设备树根节点 http://blog.csdn.net/lixiangminghate/article/details/51729945 用ReactOS上明确说过,Pnp管理器对每 ...

  3. JVM之盘点家底查看初始默认值和更改值

    JVM之查看初始默认值和更改值 目录 盘点家底查看初始默认值 盘点家底查看更改值 =和 := 解析 1. 盘点家底查看初始默认值 概述 : -XX:+PrintFlagsInitial : 查看初始默 ...

  4. 使用MDB查看变量的值(2)

    使用MDB查看变量的值(2) LW1A2@163.COM 本节描述使用MDB查看core文件中STL变量的知识 一.目的 在<使用MDB查看变量的值(1)>中,我们 探讨了查看变量值的一般 ...

  5. 使用MDB查看变量的值

    本节描述使用MDB查看core文件中变量的基本知识 基本概念: 一般程序发生coredump,80%的可能是由于参数的值不对造成的(其他可能是堆栈溢出.多线程等问题造成的).对于可以复现的问题,一般拿 ...

  6. 服务器异常关机查看dmp文件,服务器无故自动重启,使用WinDbg查看MEMORY.dmp说srvnet.sys错误(附上Bugcheck记录),请各位帮帮忙谢谢~...

    服务器无故自动重启,使用WinDbg查看MEMORY.dmp说srvnet.sys错误(附上Bugcheck记录) 请各位帮帮忙,谢谢~~~~ 服务器有做过集群.这是集群中的一台服务器,无故重启 Lo ...

  7. 使用Windbg查看CrashDump

    使用Windbg查看CrashDump (122条消息) 使用Windbg查看CrashDump_远行的风的博客-CSDN博客_windbg查看dump 本文介绍如何使用Windbg简单查看Windo ...

  8. oracle如何查看sequence的值,Oracle sequence详解

    创建sequence: create sequence seq_test increment by 1 start with 1 noMaxValue noCycle cache 10; create ...

  9. windbg 查看结构体_用WinDbg进行调试

    通往WinDbg的捷径(一) windbg的使用详细: http://wenku.baidu.com/view/f576c31e650e52ea55189832.html 导言 你钟情什么样的调试器? ...

最新文章

  1. 正确设置语言,加速WP应用提交
  2. python自学多久可以找到工作-自学Python的高效方法,学Python多久能找到工作?
  3. 简述可编程控制器硬件组态及网络通信的核心思想_智能硬件设计报价诚信经营...
  4. (十三) 深入浅出TCPIP之setsockopt参数详解
  5. BZOJ 3033 太鼓达人
  6. java对象地址连续_Java面向对象中地址的理解(长期修改)
  7. OpenCV-Python实战(8)——直方图均衡化
  8. 洛谷 3951 小凯的疑惑
  9. Ubuntu安装sqliteman遇到的问题
  10. 冬瓜哥对时间和空间的理解方式—时空参悟(上)
  11. 服务器证书如果不被网站信任怎么办?
  12. python3 collections模块 tree_python3上的ete3模块无法导入TreeStyle、faces、AttrFace、NodeSty...
  13. 向量叉乘计算多边形面积
  14. WIFISON使用及适配
  15. 好玩的读心术猜数字游戏
  16. 6612345免费网页打印浏览器
  17. 读书: 枪炮、病菌与钢铁
  18. maya如何导入多片段动画文件查看和编辑
  19. Goldengate Monitor Agent 安装
  20. Xilinx Zynq-7000嵌入式系统设计与实现 学习教程(1)

热门文章

  1. Visual SVN 非常好的转贴
  2. [转]SupSite页面文件与模块关系说明
  3. linux配置jdk环境
  4. PostgreSQL-JDBC疑似bug:部分接口参数的表名、列名必须全部小写
  5. 深入浅出 SpringMVC - 2 提升篇
  6. (转载)VS2010/MFC编程入门之五十四(Ribbon界面开发:使用更多控件并为控件添加消息处理函数)...
  7. java.net.SocketException: 断开的管道 (Write failed) 错误,数据库隔一段时间就断开的问题...
  8. c# asp.net Pdf 转换图片 在线预览 发布到iis中问题 最终解决篇—_—!
  9. 手机网页 右边的空白区
  10. rpm安装文件制作和使用