WinDbg debugging WPF Dependency Properties

Source: Internet
Author: User

??when we debug with wndbg, we often need to look at the value of a control's dependency property.
For example: We look at the content dependency property of Datagridcolumnheader 
 1. The WinDbg commands we use are:!do,!da-details,. Formats2. Using!do to view the member variables of dependent objects, locate the address of the specific dependency property0:000> !do 00000000039a71d8name:    system.windows.controls.primitives.datagridcolumnheader Methodtable:000007fee7e58090eeclass:     000007fee7885bd8size:        384 (0x180) Bytesfile:        c:\windows\microsoft.net\assembly\gac_msil\presentationframework\v4.0_ 4.0.0.0__31bf3856ad364e35\presentationframework.dllfields:              MT   & nbsp Field   Offset                 Type VT     Attr     &NBSP ;      value name000007fef3f2eb00  4000db0        8 ... eading. Dispatcher  0 instance 0000000002dd4e68 _dispatcher000007fef3f3bb88  4001321       10 ... Endencyobjecttype  0 instance 000000000308a530 _dtype000007fef7825ac8  4001322         & nbsp    system.object  0 Instance 0000000000000000 _contextstorage000007fef3f3e898 4001323 ctivevalueentry[] 0 instance 00000000042efb08 _effectivevalues000007fef7847b70 4001324 System.UInt32 1 instance 3680277 _packeddata000007fef3f33708 400131f 7c0 ependencyproperty 0 Static 0000000002dd5ef0 Directdependencyproperty---------------------omitted part----000007fef3f33708 40002CA 950 ependencyproperty 0 static 0000000002dfd820 Contentproperty0000000000000000 40002CB 958 0 Static 0000000002dfd908 hascontentpropertykey000007fef3f33708 40002CC 960 ependencyproperty 0 static 0000000002dfd948 hascontentproperty000007fef3f33708 40002CD 968 ... ependencyproperty 0 static 0000000002dfdb00 contenttemplateproperty000007fef3f33708 40002ce 970 ... ependencyPr Operty 0 Static 0000000002dfdc80 Contenttemplateselectorproperty
3. Use the!do command to view the value of a member variable for a dependency property, such as:0:000> !do 0000000002dfd820name:System.Windows.DependencyPropertyMethodtable:000007fef3f33708eeclass:     000007fef3dd7550size:        88 (0x58) bytesfile :        C:\WINDOWS\MICROSOFT.NET\ASSEMBLY\GAC_MSIL\WINDOWSBASE\V4.0_4.0.0.0__31BF3856AD364E35 \windowsbase.dllfields:              MT    field   Offset                 Type VT     Attr            value Name00 0007fef7826970  400133c        8        system.string  0 instance 000000 0002dfd630 _name000007fef78282f8  400133d                system.type &nbsp ; 0 instance 0000000002d444b0 _propertytype000007fef78282f8  400133e             &NBS P  system.type  0 instance 0000000002dfab80 _ownertype000007fef3f312a8  400133f       20 .... PropertyMetadata  0 Instance 0000000002DFD7C0 _defaultmetadata000007fef3f31088  4001340       ... datevaluecallback  0 Instance 0000000000000000 _validatevaluecallback000007fef3f3e750  4001341       30 ... Ndencypropertykey  0 Instance 0000000000000000 _readonlykey000007fef4194818  4001342       +         System.Int32  1 Instance          4194530 _packeddata 000007fef3f3e408  4001343       48 .... Insertionsortmap  1 instance 0000000002dfd868 _metadatamap000007fef3f30fc8  4001344       38 ... ercevaluecallback  0 instance 0000000000000000 _designercoercevaluecallback000007fef7825ac8  400133b      808        system.object  0   static 0000000002d72000 unsetvalue000007f EF3F3C6C0  4001345      800 ... ty, WindowsBase]]  1   static 0000000012D5BB10 Registeredpro Pertylist000007fef7831c38  4001346      810 ... ections. Hashtable  0   Static 0000000002d6f3d8 propertyfromname000007fef782c858  4001347      5C8         System.Int32  1   static              868 Globali Ndexcount000007fef7825ac8  4001348      818        system.object  0   S Tatic 0000000002d6f430 SYNCHROnized000007fef78282f8  4001349      820          system.type  0   Static 0000000002d68808 Nullabletype
4. Take advantage of the. formats to get the dependency property in 2 steps1) using the. Formats 0n to get_packeddataHex 2) Remove High, decimal describes the storage index of the dependency property in the dependent object
The following:0:000> . Formats 0n4194530Evaluate expression:hex:00000000 ' 004000e2decimal:4194530 octal:0000000000000020000342 binary:00000000 00000000 00000000 00000000 00000000 01000000 00000000 11100010 Chars: [email protected] time:wed Feb 21:08:50 1970 Float:low 5.87779e-039 High 0 double:2.072 37e-3170:000> . Formats 00e2evaluate expression:hex:00000000 ' 000000e2 decimal:226octal:0000000000000000000342 binary:00000000 00000000 00000000 00000000 00000000 00000000 00000000 11100010 Chars:  ........ Time:thu Jan 08:03:46 1970 Float:low 3.16693e-043 High 0 double:1.11659e-321
The Contentproperty dependency property has an index of 226 in Datagridcolumnheader
5. According to the 4th step of Index, from the 2nd Step dependent object _effectivevalues get the specific value of the dependency property, in 3 steps:1) Use!da-details View the value of all elements of the _effectivevalues array 2) View each element and determine the dependency property 3 based on the _propertyindex (that is, the decimal value obtained in step 4th) use the!do command to view the value of the _value member of the element
Like what:
0:000> !da-details 00000000042efb08name:        system.windows.effectivevalueentry[]methodtable: 000007fef3f3e898eeclass:     000007fef3e0c8a0size:        408 (0x198) Bytesarray:   & nbsp   Rank 1, number of elements, Type valuetypeelement methodtable:000007fef3f36120[0] 00000000042efb18    Name:        System.Windows.EffectiveValueEntry    methodtable:000007fef3f36120  & nbsp EEClass:     000007fef3dd8c90    Size:        32 (0x20) bytes    File: &N Bsp      c:\windows\microsoft.net\assembly\gac_msil\windowsbase\v4.0_4.0.0.0__31bf3856ad364e35\ windowsbase.dll    fields:                      MT    field   Offset                 Type VT     Attr   &NBSP ;        value name       000007FEF7825AC8  400136e        0            system. Object      0     instance     0000000002E1C5D8     _value    &NBSP ;   000007fef7830940  400136f        8             System.Int16      1     instance                    3     _propertyindex        000007fef41949d0  4001370        a   &NBSP ;         system.int16      1     instance           & nbsp        2     _source
--------------------------------Omit part------------------------------
[00000000042EFC08] Name:System.Windows.EffectiveValueEntry methodtable:000007fef3f36120 eeclass: 000007fef3dd8c90 size:32 (0x20) bytes file:c:\windows\microsoft.net\assembly\gac_msil\windowsbase\v4.     0_4.0.0.0__31bf3856ad364e35\windowsbase.dll fields:mt Field Offset Type VT Attr Value Name 000007fef7825ac8 400136e 0 System.Object 0 Instance 00000000042efca0 _value000007fef7830940 400136f 8 System.Int16 1 Instance 226 _propertyindex000007fef41949d0 4001370 A system.int16 1 instance _source

Contentproperty is the 16th element of _effectivevalues, whose value is stored in _value
0:000> !do 00000000042EFCA0 Name:system.windows.modifiedvaluemethodtable:000007fef3f40d58eeclass:000007fef3e0d000siz e:48 (0x30) bytesfile:c:\windows\microsoft.net\assembly\gac_msil\windowsbase\v4.0_4.0.0.0__31bf3856ad364e35 \WINDOWSBASE.DLLFIELDS:MT Field Offset Type VT Attr Value name000007fef7 825ac8 4001387 8 System.Object 0 Instance 0000000000000000 _basevalue000007fef7825ac8 4001388 System.Object 0 instance 0000000000000000 _expressionvalue000007fef7825ac8 400 1389 System.Object 0 Instance 0000000000000000 _animatedvalue000007fef7825ac8 400138a Sy Stem. Object 0 Instance 0000000002d93618 _coercedvalue
6. According to the 5th step of the member _coercedvalue get the specific value of the dependency property, done!
0:000> !do 0000000002D93618NAME:SYSTEM.STRINGMETHODTABLE:000007FEF7826970EECLASS:000007FEF73AEEC8SIZE:36 (0x24) Bytesfile:c:\windows\microsoft.net\assembly\gac_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dllString: Import data sourceFIELDS:MT Field Offset Type VT Attr Value name000007fef782c858 40000ed 8 System.Int32 1 Instance 5 m_stringlength000007fef782b398 40000ee C syste           M.char 1 Instance 5bfc m_firstchar000007fef7826970 40000ef System.String 0 Shared Static Empty >> domain:value 00000000007f85a0:0000000002d41420 <<


Copyright NOTICE: This article for Bo Master original article, welcome reprint, only please signature

WinDbg debugging WPF Dependency Properties

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.