@@ -122,14 +122,14 @@ internal override void DumpMethod(R2RMethod method, XmlNode parentNode)
122122 methodNode . AppendChild ( gcNode ) ;
123123 Serialize ( method . GcInfo , gcNode ) ;
124124
125- foreach ( KeyValuePair < int , GcInfo . GcTransition > transition in method . GcInfo . Transitions )
125+ foreach ( GcInfo . GcTransition transition in method . GcInfo . Transitions . Values )
126126 {
127127 Serialize ( transition , gcNode ) ;
128128 }
129129
130130 if ( _raw )
131131 {
132- DumpBytes ( method . GcInfo . Offset , ( uint ) method . GcInfo . Size , methodNode , false ) ;
132+ DumpBytes ( method . GcInfo . Offset , ( uint ) method . GcInfo . Size , gcNode , "Raw" , false ) ;
133133 }
134134 }
135135
@@ -155,8 +155,7 @@ internal override void DumpRuntimeFunction(RuntimeFunction rtf, XmlNode parentNo
155155
156156 if ( _disasm )
157157 {
158- string disassembly = CoreDisTools . GetCodeBlock ( _disassembler , rtf , _r2r . GetOffset ( rtf . StartAddress ) , _r2r . Image ) ;
159- AddXMLNode ( "Disassembly" , disassembly , rtfNode ) ;
158+ DumpDisasm ( _disassembler , rtf , _r2r . GetOffset ( rtf . StartAddress ) , _r2r . Image , rtfNode ) ;
160159 }
161160
162161 if ( _raw )
@@ -177,10 +176,33 @@ internal override void DumpRuntimeFunction(RuntimeFunction rtf, XmlNode parentNo
177176 }
178177 }
179178
179+ internal unsafe override void DumpDisasm ( IntPtr Disasm , RuntimeFunction rtf , int imageOffset , byte [ ] image , XmlNode parentNode )
180+ {
181+ int rtfOffset = 0 ;
182+ int codeOffset = rtf . CodeOffset ;
183+ Dictionary < int , GcInfo . GcTransition > transitions = rtf . Method . GcInfo . Transitions ;
184+ GcSlotTable slotTable = rtf . Method . GcInfo . SlotTable ;
185+ while ( rtfOffset < rtf . Size )
186+ {
187+ string instr ;
188+ int instrSize = CoreDisTools . GetInstruction ( Disasm , rtf , imageOffset , rtfOffset , image , out instr ) ;
189+
190+ AddXMLNode ( "offset" + codeOffset , instr , parentNode ) ;
191+ if ( transitions . ContainsKey ( codeOffset ) )
192+ {
193+ AddXMLNode ( "Transition" , transitions [ codeOffset ] . GetSlotState ( slotTable ) , parentNode ) ;
194+ }
195+
196+ CoreDisTools . ClearOutputBuffer ( ) ;
197+ rtfOffset += instrSize ;
198+ codeOffset += instrSize ;
199+ }
200+ }
201+
180202 /// <summary>
181203 /// Prints a formatted string containing a block of bytes from the relative virtual address and size
182204 /// </summary>
183- internal override void DumpBytes ( int rva , uint size , XmlNode parentNode , bool convertToOffset = true )
205+ internal override void DumpBytes ( int rva , uint size , XmlNode parentNode , string name = "Raw" , bool convertToOffset = true )
184206 {
185207 int start = rva ;
186208 if ( convertToOffset )
@@ -198,29 +220,9 @@ internal override void DumpBytes(int rva, uint size, XmlNode parentNode, bool co
198220 {
199221 sb . Append ( $ " { _r2r . Image [ start + i ] : X2} ") ;
200222 }
201- AddXMLNode ( "Raw" , sb . ToString ( ) , parentNode ) ;
223+ AddXMLNode ( name , sb . ToString ( ) , parentNode ) ;
202224 return ;
203225 }
204-
205- _writer . Write ( " " ) ;
206- if ( rva % 16 != 0 )
207- {
208- int floor = rva / 16 * 16 ;
209- _writer . Write ( $ "{ floor : X8} :") ;
210- _writer . Write ( new String ( ' ' , ( rva - floor ) * 3 ) ) ;
211- }
212- for ( uint i = 0 ; i < size ; i ++ )
213- {
214- if ( ( rva + i ) % 16 == 0 )
215- {
216- _writer . Write ( $ "{ rva + i : X8} :") ;
217- }
218- _writer . Write ( $ " { _r2r . Image [ start + i ] : X2} ") ;
219- if ( ( rva + i ) % 16 == 15 && i != size - 1 )
220- {
221- _writer . Write ( " " ) ;
222- }
223- }
224226 }
225227
226228 internal override void DumpSectionContents ( R2RSection section , XmlNode parentNode )
@@ -259,15 +261,15 @@ internal override void DumpSectionContents(R2RSection section, XmlNode parentNod
259261 {
260262 if ( importSection . SectionRVA != 0 )
261263 {
262- DumpBytes ( importSection . SectionRVA , ( uint ) importSection . SectionSize , contentsNode ) ;
264+ DumpBytes ( importSection . SectionRVA , ( uint ) importSection . SectionSize , contentsNode , "SectionBytes" ) ;
263265 }
264266 if ( importSection . SignatureRVA != 0 )
265267 {
266- DumpBytes ( importSection . SignatureRVA , ( uint ) importSection . Entries . Count * sizeof ( int ) , contentsNode ) ;
268+ DumpBytes ( importSection . SignatureRVA , ( uint ) importSection . Entries . Count * sizeof ( int ) , contentsNode , "SignatureBytes" ) ;
267269 }
268270 if ( importSection . AuxiliaryDataRVA != 0 )
269271 {
270- DumpBytes ( importSection . AuxiliaryDataRVA , ( uint ) importSection . AuxiliaryData . Size , contentsNode ) ;
272+ DumpBytes ( importSection . AuxiliaryDataRVA , ( uint ) importSection . AuxiliaryData . Size , contentsNode , "AuxiliaryDataBytes" ) ;
271273 }
272274 }
273275 foreach ( R2RImportSection . ImportSectionEntry entry in importSection . Entries )
0 commit comments