@@ -4,164 +4,26 @@ namespace Microsoft.SPOT.Debugger
44{
55 using System ;
66 using System . Diagnostics . Tracing ;
7- using WireProtocol ;
8- using System . Collections . Generic ;
7+ using Microsoft . SPOT . Debugger . WireProtocol ;
98
10- [ EventSource ( Name = "Microsoft -NETMF-Debugger" ) ]
9+ [ EventSource ( Name = "MsOpenTech -NETMF-Debugger" ) ]
1110 internal class DebuggerEventSource : EventSource
1211 {
1312 public static DebuggerEventSource Log { get { return Log_ . Value ; } }
1413 private static readonly Lazy < DebuggerEventSource > Log_ = new Lazy < DebuggerEventSource > ( ( ) => new DebuggerEventSource ( ) ) ;
1514
16- #if TRACE
17- [ Flags ]
18- enum PacketFlags
15+ [ Event ( 1 , Opcode = EventOpcode . Send ) ]
16+ public void WireProtocolTxHeader ( uint cmd , uint flags , ushort seq , ushort seqReply )
1917 {
20- None = 0 ,
21- NonCritical = 0x0001 , // This doesn't need an acknowledge.
22- Reply = 0x0002 , // This is the result of a command.
23- BadHeader = 0x0004 ,
24- BadPayload = 0x0008 ,
25- Spare0010 = 0x0010 ,
26- Spare0020 = 0x0020 ,
27- Spare0040 = 0x0040 ,
28- Spare0080 = 0x0080 ,
29- Spare0100 = 0x0100 ,
30- Spare0200 = 0x0200 ,
31- Spare0400 = 0x0400 ,
32- Spare0800 = 0x0800 ,
33- Spare1000 = 0x1000 ,
34- NoCaching = 0x2000 ,
35- NACK = 0x4000 ,
36- ACK = 0x8000 ,
37- }
38-
39- private static Dictionary < uint , string > CommandNameMap = new Dictionary < uint , string >
40- {
41- [ Commands . c_Monitor_Ping ] = "Ping" ,
42- [ Commands . c_Monitor_Message ] = "Message" ,
43- [ Commands . c_Monitor_ReadMemory ] = "ReadMemory" ,
44- [ Commands . c_Monitor_WriteMemory ] = "WriteMemory" ,
45- [ Commands . c_Monitor_CheckMemory ] = "CheckMemory" ,
46- [ Commands . c_Monitor_EraseMemory ] = "EraseMemory" ,
47- [ Commands . c_Monitor_Execute ] = "Execute" ,
48- [ Commands . c_Monitor_Reboot ] = "Reboot" ,
49- [ Commands . c_Monitor_MemoryMap ] = "MemoryMap" ,
50- [ Commands . c_Monitor_ProgramExit ] = "ProgramExit" ,
51- [ Commands . c_Monitor_CheckSignature ] = "CheckSignature" ,
52- [ Commands . c_Monitor_DeploymentMap ] = "DeploymentMap" ,
53- [ Commands . c_Monitor_FlashSectorMap ] = "FlashSectorMap" ,
54- [ Commands . c_Monitor_SignatureKeyUpdate ] = "SignatureKeyUpdate" ,
55- [ Commands . c_Monitor_OemInfo ] = "OemInfo" ,
56- [ Commands . c_Debugging_Execution_BasePtr ] = "Execution_BasePtr" ,
57- [ Commands . c_Debugging_Execution_ChangeConditions ] = "Execution_ChangeConditions" ,
58- [ Commands . c_Debugging_Execution_SecurityKey ] = "Execution_SecurityKey" ,
59- [ Commands . c_Debugging_Execution_Unlock ] = "Execution_Unlock" ,
60- [ Commands . c_Debugging_Execution_Allocate ] = "Execution_Allocate" ,
61- [ Commands . c_Debugging_Execution_Breakpoints ] = "Execution_Breakpoints" ,
62- [ Commands . c_Debugging_Execution_BreakpointHit ] = "Execution_BreakpointHit" ,
63- [ Commands . c_Debugging_Execution_BreakpointStatus ] = "Execution_BreakpointStatus" ,
64- [ Commands . c_Debugging_Execution_QueryCLRCapabilities ] = "Execution_QueryCLRCapabilities" ,
65- [ Commands . c_Debugging_Execution_SetCurrentAppDomain ] = "Execution_SetCurrentAppDomain" ,
66- [ Commands . c_Debugging_Thread_Create ] = "Thread_Create" ,
67- [ Commands . c_Debugging_Thread_List ] = "Thread_List" ,
68- [ Commands . c_Debugging_Thread_Stack ] = "Thread_Stack" ,
69- [ Commands . c_Debugging_Thread_Kill ] = "Thread_Kill" ,
70- [ Commands . c_Debugging_Thread_Suspend ] = "Thread_Suspend" ,
71- [ Commands . c_Debugging_Thread_Resume ] = "Thread_Resume" ,
72- [ Commands . c_Debugging_Thread_GetException ] = "Thread_GetException" ,
73- [ Commands . c_Debugging_Thread_Unwind ] = "Thread_Unwind" ,
74- [ Commands . c_Debugging_Thread_CreateEx ] = "Thread_CreateEx" ,
75- [ Commands . c_Debugging_Thread_Get ] = "Thread_Get" ,
76- [ Commands . c_Debugging_Stack_Info ] = "Stack_Info" ,
77- [ Commands . c_Debugging_Stack_SetIP ] = "Stack_SetIP" ,
78- [ Commands . c_Debugging_Value_ResizeScratchPad ] = "Value_ResizeScratchPad" ,
79- [ Commands . c_Debugging_Value_GetStack ] = "Value_GetStack" ,
80- [ Commands . c_Debugging_Value_GetField ] = "Value_GetField" ,
81- [ Commands . c_Debugging_Value_GetArray ] = "Value_GetArray" ,
82- [ Commands . c_Debugging_Value_GetBlock ] = "Value_GetBlock" ,
83- [ Commands . c_Debugging_Value_GetScratchPad ] = "Value_GetScratchPad" ,
84- [ Commands . c_Debugging_Value_SetBlock ] = "Value_SetBlock" ,
85- [ Commands . c_Debugging_Value_SetArray ] = "Value_SetArray" ,
86- [ Commands . c_Debugging_Value_AllocateObject ] = "Value_AllocateObject" ,
87- [ Commands . c_Debugging_Value_AllocateString ] = "Value_AllocateString" ,
88- [ Commands . c_Debugging_Value_AllocateArray ] = "Value_AllocateArray" ,
89- [ Commands . c_Debugging_Value_Assign ] = "Value_Assign" ,
90- [ Commands . c_Debugging_TypeSys_Assemblies ] = "TypeSys_Assemblies" ,
91- [ Commands . c_Debugging_TypeSys_AppDomains ] = "TypeSys_AppDomains" ,
92- [ Commands . c_Debugging_Resolve_Assembly ] = "Resolve_Assembly" ,
93- [ Commands . c_Debugging_Resolve_Type ] = "Resolve_Type" ,
94- [ Commands . c_Debugging_Resolve_Field ] = "Resolve_Field" ,
95- [ Commands . c_Debugging_Resolve_Method ] = "Resolve_Method" ,
96- [ Commands . c_Debugging_Resolve_VirtualMethod ] = "Resolve_VirtualMethod" ,
97- [ Commands . c_Debugging_Resolve_AppDomain ] = "Resolve_AppDomain" ,
98- [ Commands . c_Debugging_MFUpdate_Start ] = "MFUpdate_Start" ,
99- [ Commands . c_Debugging_MFUpdate_AddPacket ] = "MFUpdate_AddPacket" ,
100- [ Commands . c_Debugging_MFUpdate_Install ] = "MFUpdate_Install" ,
101- [ Commands . c_Debugging_MFUpdate_AuthCmd ] = "MFUpdate_AuthCmd" ,
102- [ Commands . c_Debugging_MFUpdate_Authenticate ] = "MFUpdate_Authenticate" ,
103- [ Commands . c_Debugging_MFUpdate_GetMissingPkts ] = "MFUpdate_GetMissingPkts" ,
104- [ Commands . c_Debugging_UpgradeToSsl ] = "UpgradeToSsl" ,
105- [ Commands . c_Debugging_Lcd_NewFrame ] = "Lcd_NewFrame" ,
106- [ Commands . c_Debugging_Lcd_NewFrameData ] = "Lcd_NewFrameData" ,
107- [ Commands . c_Debugging_Lcd_GetFrame ] = "Lcd_GetFrame" ,
108- [ Commands . c_Debugging_Button_Report ] = "Button_Report" ,
109- [ Commands . c_Debugging_Button_Inject ] = "Button_Inject" ,
110- [ Commands . c_Debugging_Messaging_Query ] = "Messaging_Query" ,
111- [ Commands . c_Debugging_Messaging_Send ] = "Messaging_Send" ,
112- [ Commands . c_Debugging_Messaging_Reply ] = "Messaging_Reply" ,
113- [ Commands . c_Debugging_Logging_GetNumberOfRecords ] = "Logging_GetNumberOfRecords" ,
114- [ Commands . c_Debugging_Logging_GetRecord ] = "Logging_GetRecord" ,
115- [ Commands . c_Debugging_Logging_Erase ] = "Logging_Erase" ,
116- [ Commands . c_Debugging_Logging_GetRecords ] = "Logging_GetRecords" ,
117- [ Commands . c_Debugging_Deployment_Status ] = "Deployment_Status" ,
118- [ Commands . c_Debugging_Info_SetJMC ] = "Info_SetJMC" ,
119- [ Commands . c_Profiling_Command ] = "Profiling_Command" ,
120- [ Commands . c_Profiling_Stream ] = "Profiling_Stream"
121- } ;
122-
123- string GetCommandName ( uint cmd )
124- {
125- string retVal ;
126- if ( ! CommandNameMap . TryGetValue ( cmd , out retVal ) )
127- retVal = $ "0x{ cmd : X08} ";
128-
129- return retVal ;
130- }
131- #endif
132-
133- [ Event ( 1 , Opcode = EventOpcode . Send ) ]
134- public void WireProtocolTxHeader ( uint crcHeader , uint crcData , uint cmd , uint flags , ushort seq , ushort seqReply , uint length )
135- {
136- #if TRACE
137- Trace . TraceInformation ( "TX: {0} flags=[{1}] hCRC: 0x{2:X08} pCRC: 0x{3:X08} seq: 0x{4:X04} replySeq: 0x{5:X04} len={6}"
138- , GetCommandName ( cmd )
139- , ( PacketFlags ) flags
140- , crcHeader
141- , crcData
142- , seq
143- , seqReply
144- , length
145- ) ;
146- #endif
147- WriteCustomEvent ( 1 , crcHeader , crcData , cmd , flags , seq , seqReply , length ) ;
18+ Trace . TraceInformation ( "TX: {0:X08} {1:X08} {2:X04} {3:X04}" , cmd , flags , seq , seqReply ) ;
19+ WriteCustomEvent ( 1 , cmd , flags , seq , seqReply ) ;
14820 }
14921
15022 [ Event ( 2 , Opcode = EventOpcode . Receive ) ]
151- public void WireProtocolRxHeader ( uint crcHeader , uint crcData , uint cmd , uint flags , ushort seq , ushort seqReply , uint length )
23+ public void WireProtocolRxHeader ( uint cmd , uint flags , ushort seq , ushort seqReply )
15224 {
153- #if TRACE
154- Trace . TraceInformation ( "RX: {0} flags=[{1}] hCRC: 0x{2:X08} pCRC: 0x{3:X08} seq: 0x{4:X04} replySeq: 0x{5:X04} len={6}"
155- , GetCommandName ( cmd )
156- , ( PacketFlags ) flags
157- , crcHeader
158- , crcData
159- , seq
160- , seqReply
161- , length
162- ) ;
163- #endif
164- WriteCustomEvent ( 2 , crcHeader , crcData , cmd , flags , seq , seqReply , length ) ;
25+ Trace . TraceInformation ( "RX: {0:X08} {1:X08} {2:X04} {3:X04}" , cmd , flags , seq , seqReply ) ;
26+ WriteCustomEvent ( 2 , cmd , flags , seq , seqReply ) ;
16527 }
16628
16729 [ Event ( 3 ) ]
@@ -173,47 +35,27 @@ public void WireProtocolReceiveState( MessageReassembler.ReceiveState state )
17335 [ Event ( 4 ) ]
17436 public void EngineEraseMemory ( uint address , uint length )
17537 {
176- Trace . TraceInformation ( "EraseMemory : @0x {0:X08}; LEN=0x {1:X08}" , address , length ) ;
38+ Trace . TraceInformation ( "EreaseMemory : @{0:X08}; LEN={1:X08}" , address , length ) ;
17739 WriteEvent ( 4 , ( int ) address , ( int ) length ) ;
17840 }
17941
180- [ Event ( 5 ) ]
181- public void EngineWriteMemory ( uint address , int length )
182- {
183- Trace . TraceInformation ( "WriteMemory: @0x{0:X08}; LEN=0x{1:X08}" , address , length ) ;
184- WriteEvent ( 5 , ( int ) address , length ) ;
185- }
186-
18742 private DebuggerEventSource ( )
18843 {
18944 }
19045
19146 [ NonEvent ]
192- unsafe void WriteCustomEvent ( int eventId , uint crcHeader , uint crcData , uint cmd , uint flags , ushort seq , ushort seqReply , uint length )
193- {
194- EventData * pDataDesc = stackalloc EventData [ 7 ] ;
195- pDataDesc [ 0 ] . DataPointer = ( IntPtr ) ( & crcHeader ) ;
196- pDataDesc [ 0 ] . Size = sizeof ( uint ) ;
197-
198- pDataDesc [ 1 ] . DataPointer = ( IntPtr ) ( & crcData ) ;
199- pDataDesc [ 1 ] . Size = sizeof ( uint ) ;
200-
201- pDataDesc [ 2 ] . DataPointer = ( IntPtr ) ( & cmd ) ;
202- pDataDesc [ 2 ] . Size = sizeof ( uint ) ;
203-
204- pDataDesc [ 3 ] . DataPointer = ( IntPtr ) ( & flags ) ;
205- pDataDesc [ 3 ] . Size = sizeof ( uint ) ;
206-
207- pDataDesc [ 4 ] . DataPointer = ( IntPtr ) ( & seq ) ;
208- pDataDesc [ 4 ] . Size = sizeof ( ushort ) ;
209-
210- pDataDesc [ 5 ] . DataPointer = ( IntPtr ) ( & seqReply ) ;
211- pDataDesc [ 5 ] . Size = sizeof ( ushort ) ;
212-
213- pDataDesc [ 6 ] . DataPointer = ( IntPtr ) ( & length ) ;
214- pDataDesc [ 6 ] . Size = sizeof ( uint ) ;
215-
216- WriteEventCore ( eventId , 7 , pDataDesc ) ;
47+ unsafe void WriteCustomEvent ( int eventId , uint cmd , uint flags , ushort seq , ushort seqReply )
48+ {
49+ EventData * pDataDesc = stackalloc EventData [ 4 ] ;
50+ pDataDesc [ 0 ] . DataPointer = ( IntPtr ) ( & cmd ) ;
51+ pDataDesc [ 0 ] . Size = sizeof ( int ) ;
52+ pDataDesc [ 1 ] . DataPointer = ( IntPtr ) ( & flags ) ;
53+ pDataDesc [ 1 ] . Size = sizeof ( int ) ;
54+ pDataDesc [ 2 ] . DataPointer = ( IntPtr ) ( & seq ) ;
55+ pDataDesc [ 2 ] . Size = sizeof ( ushort ) ;
56+ pDataDesc [ 3 ] . DataPointer = ( IntPtr ) ( & seqReply ) ;
57+ pDataDesc [ 3 ] . Size = sizeof ( ushort ) ;
58+ WriteEventCore ( eventId , 4 , pDataDesc ) ;
21759 }
21860 }
21961}
0 commit comments