Debug the dependency attribute of WPF by Windbg, and debug wpf by windbg

Source: Internet
Author: User
Tags mscorlib

Debug the dependency attribute of WPF by Windbg, and debug wpf by windbg
When we use wndbg for debugging, we often need to view the dependency attribute values of a control.
For example, we can view the Content dependency attribute of the DataGridColumnHeader. 
 1. The windbg commands we use include :! Do ,! Da-details,. formats2. Use it! Do: view the member variables of the dependent object and find the specific dependency attribute address.0: 000>! Do 00000000039a71d8Name: System. windows. controls. primitives. dataGridColumnHeaderMethodTable: 000007fee7e58090EEClass: 000007fee7885bd8Size: 384 (0x180) bytesFile: C: \ Windows \ Microsoft. net \ assembly \ GAC_MSIL \ PresentationFramework \ v4.0 _ 4.0.0.0 _ 31bf3856ad364e35 \ PresentationFramework. dllFields: MT Field Offset Type VT Attr Value Name000007fef3f2eb00 4000db0 8... eading. dispatcher 0 instance 0000000002dd4e68 _ dispatcher000007fef3bb88 4001321 10... endencyObjectType 0 instance 000000000308a530 _ dType000007fef7825ac8 4001322 18 System. object 0 instance 0000000000000000 _ contextStorage000007fef3f3e898 4001323 20... ctiveValueEntry [] 0 instance 00000000042efb08 _ effectiveValues000007fef7847b70 4001324 28 System. UInt32 1 instance 3680277 _ packeddata000007fef33708 400366f 7c0... ependencyProperty 0 static 10000000002dd5ef0 DirectDependencyProperty ------------------- omitted part ---- 000007fef3f33708 40002ca 950... ependencyProperty 0 static 0000000002dfd820 contentproperty00000000000000000000 40002cb 958 0 static 0000000002dfd908 HasContentPropertyKey000007fef3f33708 40002cc 960... ependencyProperty 0 static 0000000002dfd948 hascontentproperty000007fef33708 40002cd 968... ependencyProperty 0 static 0000000002dfdb00 contenttemplateproperty000007fef33708 40002ce 970... ependencyProperty 0 static 10000000002dfdc80 ContentTemplateSelectorProperty
3. Use it! The do command is used to view the member variable values of the dependency attribute, for example: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 Name000007fef7826970 400133c 8 System. string 0 instance 0000000002dfd630 _ name000007fef78282f8 400133d 10 System. type 0 instance 0000000002d444b0 _ propertyType000007fef78282f8 400133e 18 System. type 0 instance 0000000002dfab80 _ ownerType000007fef3f312a8 400133f 20 .... propertyMetadata 0 instance 0000000002dfd7c0 _ defaultmetadata000007fef31088 4001340 28... dateValueCallback 0 instance 0000000000000000 _ validatevaluecallback000007fef3e750 4001341 30... ndencyPropertyKey 0 instance 0000000000000000 _ readOnlyKey000007fef4194818 4001342 40 System. int32 1 instance 4194530 _ packedData000007fef3f3e408 4001343 48 .... insertionSortMap 1 instance 0000000002dfd868 _ metadataMap000007fef3f30fc8 4001344 38... erceValueCallback 0 instance 0000000000000000 _ designerCoerceValueCallback000007fef7825ac8 400133b 808 System. object 0 static 0000000002d72000 UnsetValue000007fef3f3c6c0 4001345 800... ty, WindowsBase] 1 static listen 12d5bb10 RegisteredPropertyList000007fef7831c38 4001346 810... ections. hashtable 0 static 0000000002d6f3d8 PropertyFromName000007fef782c858 4001347 5c8 System. int32 1 static 868 GlobalIndexCount000007fef7825ac8 4001348 818 System. object 0 static 0000000002d6f430 Synchronized000007fef78282f8 4001349 820 System. type 0 static 10000000002d68808 NullableType
4. Use. formats to obtain the dependency attribute, in two steps1) use. formats 0n to get the _ packedData hexadecimal value. 2) Remove the high value. Decimal describes the storage index of the dependency attribute in the dependent object.
As follows: 0: 000>. formats 0n4194530Evaluate expression: Hex: 00000000 '004000e2 Decimal: 4194530 Octal: 0000000000000020000342 Binary: 00000000 00000000 00000000 00000000 00000000 Chars :..... @.. time: Wed Feb 18 21:08:50 1970 Float: low 5.87779e-039 high 0 Double: 2.07237e-3170: 000>. formats 00e2Evaluate expression: Hex: 00000000 '000000e2 Decimal: 226 Octal: 0000000000000000000342 Binary: 00000000 00000000 00000000 00000000 00000000 00000000 Chars :........ time: Thu Jan 01 08:03:46 1970 Float: low 3.16693e-043 high 0 Double: 1.11659e-321
The index of the ContentProperty dependency attribute in the DataGridColumnHeader is 226.
5. According to the index in step 2, the specific value of the dependency attribute is obtained from _ required tivevalues of the dependent object in step 2, in three steps:1) exploitation! Da-details viewing the values of all elements in the _ effectiveValues array 2) view each element and determine the dependency Attribute Based on _ propertyIndex (that is, the Decimal value obtained in step 3! Do command to view the value of the element's _ value member
For example:
0: 000>! Da-details 00000000042efb08Name: System. windows. effectiveValueEntry [] MethodTable: Clerk: 408 (0x198) bytesArray: Rank 1, Number of elements 24, Type VALUETYPEElement Methodtable: 000007fef3f36120 [0] Comment 0000042efb18 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 0000000002e1c5d8 _ value 000007fef7830940 400136f 8 System. int16 1 instance 3 _ propertyIndex 000007fef41949d0 4001370 a System. int16 1 instance 2 _ source
-------------------------------- Omitted part ------------------------------
[15] 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 _ value 000007fef7830940 400136f 8 System. int16 1 instance 226 _ propertyIndex 000007fef41949d0 4001370 a System. int16 1 instance 65 _ source

It can be seen that ContentProperty is the 16th elements of _ effectiveValues, and its values are stored in _ value.
0: 000>! Do 00000000042efca0 Name: System. windows. modifiedValueMethodTable: 000007fef3f40d58EEClass: 000007fef3e0d000Size: 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 Name000007fef7825ac8 4001387 8 System. object 0 instance 0000000000000000 _ baseValue000007fef7825ac8 4001388 10 System. object 0 instance 0000000000000000 _ expressionValue000007fef7825ac8 4001389 18 System. object 0 instance 0000000000000000 _ animatedValue000007fef7825ac8 400138a 20 System. object 0 instance 0000000002d93618 _ coercedValue
6. Obtain the specific value of the dependency Attribute Based on the member _ coercedValue in step 1. This is a big success!
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 source Fields: MT Field Offset Type VT Attr Value Name000007fef782c858 40000ed 8 System. int32 1 instance 5 m_stringLength000007fef782b398 40000ee c System. char 1 instance 5bfc m_firstChar000007fef7826970 40000ef 10 System. string 0 shared static Empty> Domain: Value 00000000007f85a0: 0000000002d41420 <


Copyright Disclaimer: This article is an original article by the blogger. You are welcome to reprint it. Please sign it only.

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.