static void CreateEventDescriptors()
 {
     System.Runtime.Diagnostics.EventDescriptor[] descriptors = new System.Runtime.Diagnostics.EventDescriptor[] {
         new System.Runtime.Diagnostics.EventDescriptor(4201, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Stop, 0xa1d, 0x1000000008000000),
         new System.Runtime.Diagnostics.EventDescriptor(4202, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0xa1d, 0x1000000008000000),
         new System.Runtime.Diagnostics.EventDescriptor(4203, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0x9f9, 0x1000000008000000),
         new System.Runtime.Diagnostics.EventDescriptor(4205, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0xa1d, 0x1000000008000000),
         new System.Runtime.Diagnostics.EventDescriptor(4206, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0x9f9, 0x1000000008000000),
         new System.Runtime.Diagnostics.EventDescriptor(4207, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Info, 0xa1d, 0x1000000008400000),
         new System.Runtime.Diagnostics.EventDescriptor(4208, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Info, 0xa1d, 0x1000000008000000),
         new System.Runtime.Diagnostics.EventDescriptor(4209, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0xa1d, 0x1000000008000000),
         new System.Runtime.Diagnostics.EventDescriptor(4210, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)TraceEventOpcode.Info, 0xa1d, 0x1000000008000000),
         new System.Runtime.Diagnostics.EventDescriptor(4212, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)TraceEventOpcode.Info, 0xa1d, 0x1000000008000000),
         new System.Runtime.Diagnostics.EventDescriptor(4211, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)TraceEventOpcode.Info, 0x9f9, 0x1000000008000000),
         new System.Runtime.Diagnostics.EventDescriptor(4213, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0x9f9, 0x1000000008000000),
         new System.Runtime.Diagnostics.EventDescriptor(4214, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0x9f9, 0x1000000008000000)
     };
     // The hashcodes calculated from PTCop for TD.CreateEventDescriptors are unstable when just declaring
     // a local field of ushort[] if the array is non-empty and contains more than 2 entries, because
     // the c#-compiler is using some private types for optimization. The type name follows the following pattern:
     // <PrivateImplementationDetails>{6BAE93FD-290B-4DE0-BCEE-366B30800FDF} (where the GUID is changing with every build)
     // To scope the change to unblock PTCop as much as possible we wrap the list of End2EndEvents in a List<ushort>
     System.Collections.Generic.List <ushort> e2eEvents = new System.Collections.Generic.List <ushort>(7);
     e2eEvents.Add(4205);
     e2eEvents.Add(4207);
     e2eEvents.Add(4208);
     e2eEvents.Add(4209);
     e2eEvents.Add(4210);
     e2eEvents.Add(4211);
     e2eEvents.Add(4212);
     FxTrace.UpdateEventDefinitions(descriptors, e2eEvents.ToArray());
     eventDescriptors = descriptors;
 }
        internal unsafe bool WriteEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, Guid value1, string value2, string value3)
        {
            const int argumentCount = 3;
            bool status = true;

            //check all strings for null            
            value2 = (value2 ?? string.Empty);
            value3 = (value3 ?? string.Empty);

            fixed (char* string1Bytes = value2, string2Bytes = value3)
            {
                byte* eventData = stackalloc byte[sizeof(UnsafeNativeMethods.EventData) * argumentCount];
                UnsafeNativeMethods.EventData* eventDataPtr = (UnsafeNativeMethods.EventData*)eventData;

                eventDataPtr[0].DataPointer = (ulong)(&value1);
                eventDataPtr[0].Size = (uint)(sizeof(Guid));

                eventDataPtr[1].DataPointer = (ulong)string1Bytes;
                eventDataPtr[1].Size = (uint)(value2.Length + 1) * sizeof(char);
            
                eventDataPtr[2].DataPointer = (ulong)string2Bytes;
                eventDataPtr[2].Size = (uint)(value3.Length + 1) * sizeof(char);                

                status = WriteEvent(ref eventDescriptor, eventTraceActivity, argumentCount, (IntPtr)(eventData));
            }

            return status;
        }
 static void CreateEventDescriptors()
 {
     System.Runtime.Diagnostics.EventDescriptor[] descriptors = new System.Runtime.Diagnostics.EventDescriptor[] {
         new System.Runtime.Diagnostics.EventDescriptor(1420, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0xa00, 0x2000000000400000),
         new System.Runtime.Diagnostics.EventDescriptor(5001, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0xa20, 0x1000000000000002),
         new System.Runtime.Diagnostics.EventDescriptor(5002, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Stop, 0xa20, 0x1000000000000002),
         new System.Runtime.Diagnostics.EventDescriptor(5003, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0xa1f, 0x1000000000000002),
         new System.Runtime.Diagnostics.EventDescriptor(5004, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Stop, 0xa1f, 0x1000000000000002),
         new System.Runtime.Diagnostics.EventDescriptor(5005, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0x9f3, 0x1000000000000002),
         new System.Runtime.Diagnostics.EventDescriptor(5006, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Stop, 0x9f3, 0x1000000000000002),
         new System.Runtime.Diagnostics.EventDescriptor(5007, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0x9e0, 0x1000000000000002),
         new System.Runtime.Diagnostics.EventDescriptor(5008, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0x9f0, 0x1000000000000002),
         new System.Runtime.Diagnostics.EventDescriptor(5009, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Stop, 0x9f0, 0x1000000000000002),
         new System.Runtime.Diagnostics.EventDescriptor(5010, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0x9ef, 0x1000000000000002),
         new System.Runtime.Diagnostics.EventDescriptor(5011, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Stop, 0x9ef, 0x1000000000000002),
         new System.Runtime.Diagnostics.EventDescriptor(5012, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0x9ef, 0x1000000000000002),
         new System.Runtime.Diagnostics.EventDescriptor(5013, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Stop, 0x9ef, 0x1000000000000002),
         new System.Runtime.Diagnostics.EventDescriptor(5014, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0x9f0, 0x1000000000000002),
         new System.Runtime.Diagnostics.EventDescriptor(5015, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Stop, 0x9f0, 0x1000000000000002),
         new System.Runtime.Diagnostics.EventDescriptor(5016, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0x9f1, 0x1000000000000002),
         new System.Runtime.Diagnostics.EventDescriptor(5017, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Stop, 0x9f1, 0x1000000000000002)
     };
     ushort[] e2eEvents = new ushort[0];
     FxTrace.UpdateEventDefinitions(descriptors, e2eEvents);
     eventDescriptors = descriptors;
 }
 static void CreateEventDescriptors()
 {
     System.Runtime.Diagnostics.EventDescriptor[] descriptors = new System.Runtime.Diagnostics.EventDescriptor[] {
         new System.Runtime.Diagnostics.EventDescriptor(57398, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Warning, (byte)TraceEventOpcode.Info, 0xa22, 0x2000000004000000),
         new System.Runtime.Diagnostics.EventDescriptor(3501, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)69, 0x9f4, 0x2000000004000000),
         new System.Runtime.Diagnostics.EventDescriptor(3502, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)70, 0x9f4, 0x2000000004000000),
         new System.Runtime.Diagnostics.EventDescriptor(3503, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Warning, (byte)28, 0x9db, 0x2000000004000000),
         new System.Runtime.Diagnostics.EventDescriptor(3507, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Info, 0x9cb, 0x2000000004000000),
         new System.Runtime.Diagnostics.EventDescriptor(440, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Start, 0xa1c, 0x2000000004080000),
         new System.Runtime.Diagnostics.EventDescriptor(441, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Stop, 0xa1c, 0x2000000004080000),
         new System.Runtime.Diagnostics.EventDescriptor(3550, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)11, 0x9cc, 0x2000000004000000),
         new System.Runtime.Diagnostics.EventDescriptor(3551, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)10, 0x9cc, 0x2000000004000000),
         new System.Runtime.Diagnostics.EventDescriptor(3552, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Warning, (byte)TraceEventOpcode.Info, 0xa00, 0x2000000004400000),
         new System.Runtime.Diagnostics.EventDescriptor(3555, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Start, 0x9de, 0x1000000000000080),
         new System.Runtime.Diagnostics.EventDescriptor(3556, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Stop, 0x9de, 0x1000000000000080),
         new System.Runtime.Diagnostics.EventDescriptor(3557, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Info, 0xa08, 0x2000000004000000),
         new System.Runtime.Diagnostics.EventDescriptor(3508, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Verbose, (byte)124, 0xa25, 0x2000000004000000),
         new System.Runtime.Diagnostics.EventDescriptor(225, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Info, 0x9db, 0x2000000004080000),
         new System.Runtime.Diagnostics.EventDescriptor(2023, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)76, 0x9fa, 0x1000000001000000),
         new System.Runtime.Diagnostics.EventDescriptor(1450, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Send, 0xa2e, 0x1000000004000000),
         new System.Runtime.Diagnostics.EventDescriptor(1449, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Receive, 0xa2e, 0x1000000004000000),
         new System.Runtime.Diagnostics.EventDescriptor(1436, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0xa00, 0x2000000000400000)
     };
     // The hashcodes calculated from PTCop for TD.CreateEventDescriptors are unstable when just declaring
     // a local field of ushort[] if the array is non-empty and contains more than 2 entries, because
     // the c#-compiler is using some private types for optimization. The type name follows the following pattern:
     // <PrivateImplementationDetails>{6BAE93FD-290B-4DE0-BCEE-366B30800FDF} (where the GUID is changing with every build)
     // To scope the change to unblock PTCop as much as possible we wrap the list of End2EndEvents in a List<ushort>
     System.Collections.Generic.List <ushort> e2eEvents = new System.Collections.Generic.List <ushort>(3);
     e2eEvents.Add(1449);
     e2eEvents.Add(1450);
     e2eEvents.Add(3551);
     FxTrace.UpdateEventDefinitions(descriptors, e2eEvents.ToArray());
     eventDescriptors = descriptors;
 }
示例#5
0
 /// <summary>
 /// Creates the event descriptors array
 /// </summary>
 static void CreateEventDescriptors()
 {
     System.Runtime.Diagnostics.EventDescriptor[] descriptors = new System.Runtime.Diagnostics.EventDescriptor[] {
         new System.Runtime.Diagnostics.EventDescriptor(62326, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Info, 0x9de, 0x1000000000000080)
     };
     ushort[] e2eEvents = new ushort[0];
     FxTrace.UpdateEventDefinitions(descriptors, e2eEvents);
     eventDescriptors = descriptors;
 }
 static void CreateEventDescriptors()
 {
     System.Runtime.Diagnostics.EventDescriptor[] descriptors = new System.Runtime.Diagnostics.EventDescriptor[] {
         new System.Runtime.Diagnostics.EventDescriptor(5203, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0x9fb, 0x1000000000001000),
         new System.Runtime.Diagnostics.EventDescriptor(5204, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0x9fc, 0x1000000000001000)
     };
     ushort[] e2eEvents = new ushort[] {
         5204
     };
     FxTrace.UpdateEventDefinitions(descriptors, e2eEvents);
     eventDescriptors = descriptors;
 }
 static void CreateEventDescriptors()
 {
     System.Runtime.Diagnostics.EventDescriptor[] descriptors = new System.Runtime.Diagnostics.EventDescriptor[] {
         new System.Runtime.Diagnostics.EventDescriptor(501, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Start, 0xa13, 0x1000000000000080),
         new System.Runtime.Diagnostics.EventDescriptor(502, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Stop, 0xa13, 0x1000000000000080),
         new System.Runtime.Diagnostics.EventDescriptor(503, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Start, 0xa15, 0x1000000000000080),
         new System.Runtime.Diagnostics.EventDescriptor(504, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Stop, 0xa15, 0x1000000000000080),
         new System.Runtime.Diagnostics.EventDescriptor(505, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Start, 0xa14, 0x1000000000000080),
         new System.Runtime.Diagnostics.EventDescriptor(506, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Stop, 0xa14, 0x1000000000000080),
         new System.Runtime.Diagnostics.EventDescriptor(507, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Start, 0x9f2, 0x1000000000000080),
         new System.Runtime.Diagnostics.EventDescriptor(508, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Stop, 0x9f2, 0x1000000000000080),
         new System.Runtime.Diagnostics.EventDescriptor(513, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Start, 0xa2c, 0x1000000000000080),
         new System.Runtime.Diagnostics.EventDescriptor(514, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Stop, 0xa2c, 0x1000000000000080),
         new System.Runtime.Diagnostics.EventDescriptor(603, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0x0, 0x1000000000008000),
         new System.Runtime.Diagnostics.EventDescriptor(604, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0x0, 0x1000000000008000),
         new System.Runtime.Diagnostics.EventDescriptor(213, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.LogAlways, (byte)TraceEventOpcode.Start, 0xa12, 0x20000000000E0001),
         new System.Runtime.Diagnostics.EventDescriptor(226, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.LogAlways, (byte)TraceEventOpcode.Info, 0xa19, 0x2000000000040080),
         new System.Runtime.Diagnostics.EventDescriptor(601, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0x0, 0x1000000000000000),
         new System.Runtime.Diagnostics.EventDescriptor(602, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0x0, 0x1000000000000000),
         new System.Runtime.Diagnostics.EventDescriptor(3553, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Start, 0xa32, 0x1000000000000080),
         new System.Runtime.Diagnostics.EventDescriptor(3554, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Stop, 0xa32, 0x1000000000000080),
         new System.Runtime.Diagnostics.EventDescriptor(605, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0xa2c, 0x1000000000000080),
         new System.Runtime.Diagnostics.EventDescriptor(606, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Stop, 0xa2c, 0x1000000000000080),
         new System.Runtime.Diagnostics.EventDescriptor(3558, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Start, 0xa0f, 0x2000000000000080),
         new System.Runtime.Diagnostics.EventDescriptor(3559, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Stop, 0xa0f, 0x2000000000000080),
         new System.Runtime.Diagnostics.EventDescriptor(3560, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0xa00, 0x2000000000400000),
         new System.Runtime.Diagnostics.EventDescriptor(3561, 0, (byte)TraceChannel.Operational, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0x0, 0x4000000000000080)
     };
     // The hashcodes calculated from PTCop for TD.CreateEventDescriptors are unstable when just declaring
     // a local field of ushort[] if the array is non-empty and contains more than 2 entries, because
     // the c#-compiler is using some private types for optimization. The type name follows the following pattern:
     // <PrivateImplementationDetails>{6BAE93FD-290B-4DE0-BCEE-366B30800FDF} (where the GUID is changing with every build)
     // To scope the change to unblock PTCop as much as possible we wrap the list of End2EndEvents in a List<ushort>
     System.Collections.Generic.List <ushort> e2eEvents = new System.Collections.Generic.List <ushort>(14);
     e2eEvents.Add(213);
     e2eEvents.Add(226);
     e2eEvents.Add(501);
     e2eEvents.Add(502);
     e2eEvents.Add(503);
     e2eEvents.Add(504);
     e2eEvents.Add(505);
     e2eEvents.Add(506);
     e2eEvents.Add(513);
     e2eEvents.Add(514);
     e2eEvents.Add(602);
     e2eEvents.Add(603);
     e2eEvents.Add(3558);
     e2eEvents.Add(3559);
     FxTrace.UpdateEventDefinitions(descriptors, e2eEvents.ToArray());
     eventDescriptors = descriptors;
 }
示例#8
0
 static void CreateEventDescriptors()
 {
     System.Runtime.Diagnostics.EventDescriptor[] descriptors = new System.Runtime.Diagnostics.EventDescriptor[] {
         new System.Runtime.Diagnostics.EventDescriptor(4800, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)TraceEventOpcode.Info, 0x0, 0x1000000000000000),
         new System.Runtime.Diagnostics.EventDescriptor(4801, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0x9fb, 0x1000000000001000),
         new System.Runtime.Diagnostics.EventDescriptor(4802, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0x9fb, 0x1000000000001000)
     };
     ushort[] e2eEvents = new ushort[] {
         4800,
         4802
     };
     FxTrace.UpdateEventDefinitions(descriptors, e2eEvents);
     eventDescriptors = descriptors;
 }
示例#9
0
		internal unsafe bool WriteEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, Guid value1, string value2, string value3)
		{
			string str = value2;
			string empty = str;
			if (str == null)
			{
				empty = string.Empty;
			}
			value2 = empty;
			string str1 = value3;
			string empty1 = str1;
			if (str1 == null)
			{
				empty1 = string.Empty;
			}
			value3 = empty1;
			fixed (string str2 = value2)
			{
				string* strPointers = &str2;
				char* offsetToStringData = (char*)(&str2);
				if (&str2 != null)
				{
					offsetToStringData = (char*)(strPointers + RuntimeHelpers.OffsetToStringData);
				}
				char* chrPointer = offsetToStringData;
				fixed (string str3 = value3)
				{
					string* strPointers1 = &str3;
					char* offsetToStringData1 = (char*)(&str3);
					if (&str3 != null)
					{
						offsetToStringData1 = (char*)(strPointers1 + RuntimeHelpers.OffsetToStringData);
					}
					byte* length = (byte*)sizeof(UnsafeNativeMethods.EventData) * 3;
					(*((UnsafeNativeMethods.EventData*)length)).DataPointer = (ulong)(&value1);
					(*((UnsafeNativeMethods.EventData*)length)).Size = sizeof(Guid);
					((UnsafeNativeMethods.EventData*)length + sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer;
					((UnsafeNativeMethods.EventData*)length + sizeof(UnsafeNativeMethods.EventData)).Size = (value2.Length + 1) * 2;
					((UnsafeNativeMethods.EventData*)length + 2 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)offsetToStringData1;
					((UnsafeNativeMethods.EventData*)length + 2 * sizeof(UnsafeNativeMethods.EventData)).Size = (value3.Length + 1) * 2;
					bool flag = base.WriteEvent(ref eventDescriptor, eventTraceActivity, 3, (IntPtr)length);
					return flag;
				}
			}
		}
示例#10
0
 /// <summary>
 /// Creates the event descriptors array
 /// </summary>
 static void CreateEventDescriptors()
 {
     System.Runtime.Diagnostics.EventDescriptor[] descriptors = new System.Runtime.Diagnostics.EventDescriptor[] {
         new System.Runtime.Diagnostics.EventDescriptor(4801, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)30, 0x9e1, 0x1000000000004000),
         new System.Runtime.Diagnostics.EventDescriptor(4802, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)29, 0x9e1, 0x1000000000004000),
         new System.Runtime.Diagnostics.EventDescriptor(4803, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)31, 0x9e1, 0x1000000000004000),
         new System.Runtime.Diagnostics.EventDescriptor(4804, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)45, 0x9e3, 0x1000000000004000),
         new System.Runtime.Diagnostics.EventDescriptor(4805, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)37, 0x9e3, 0x1000000000004000),
         new System.Runtime.Diagnostics.EventDescriptor(4806, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)38, 0x9e3, 0x1000000000004000),
         new System.Runtime.Diagnostics.EventDescriptor(4807, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)39, 0x9e3, 0x1000000000004000),
         new System.Runtime.Diagnostics.EventDescriptor(4808, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)40, 0x9e3, 0x1000000000004000),
         new System.Runtime.Diagnostics.EventDescriptor(4809, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)41, 0x9e3, 0x1000000000004000),
         new System.Runtime.Diagnostics.EventDescriptor(4810, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)42, 0x9e3, 0x1000000000004000),
         new System.Runtime.Diagnostics.EventDescriptor(4811, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)43, 0x9e3, 0x1000000000004000),
         new System.Runtime.Diagnostics.EventDescriptor(4812, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)44, 0x9e3, 0x1000000000004000),
         new System.Runtime.Diagnostics.EventDescriptor(4813, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)36, 0x9e3, 0x1000000000004000),
         new System.Runtime.Diagnostics.EventDescriptor(4814, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)58, 0x9e6, 0x1000000000004000),
         new System.Runtime.Diagnostics.EventDescriptor(4815, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)59, 0x9e6, 0x1000000000004000),
         new System.Runtime.Diagnostics.EventDescriptor(4816, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)33, 0x9e2, 0x1000000000004000),
         new System.Runtime.Diagnostics.EventDescriptor(4817, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)32, 0x9e2, 0x1000000000004000),
         new System.Runtime.Diagnostics.EventDescriptor(4818, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)34, 0x9e2, 0x1000000000004000),
         new System.Runtime.Diagnostics.EventDescriptor(4819, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)35, 0x9e2, 0x1000000000004000),
         new System.Runtime.Diagnostics.EventDescriptor(4820, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)46, 0x9e4, 0x1000000000004000),
         new System.Runtime.Diagnostics.EventDescriptor(4821, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)47, 0x9e4, 0x1000000000004000)
     };
     ushort[] e2eEvents = new ushort[] {
         4804,
         4805,
         4806,
         4807,
         4808,
         4809,
         4811,
         4812,
         4813
     };
     FxTrace.UpdateEventDefinitions(descriptors, e2eEvents);
     eventDescriptors = descriptors;
 }
        internal protected bool WriteEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, int dataCount, IntPtr data)
        {
            uint status = 0;

            if (eventTraceActivity != null)
            {
                SetActivityId(ref eventTraceActivity.ActivityId);
            }

            unsafe
            {
                status = UnsafeNativeMethods.EventWrite(this.traceRegistrationHandle, ref eventDescriptor, (uint)dataCount, (UnsafeNativeMethods.EventData*)data);
            }
            if (status != 0)
            {
                SetLastError((int)status);
                return false;
            }
            return true;
        }
        public bool WriteEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, params object[] eventPayload)
        {
            uint status = 0;

            if (IsEnabled(eventDescriptor.Level, eventDescriptor.Keywords))
            {
                int argCount = 0;

                if (eventTraceActivity != null)
                {
                    SetActivityId(ref eventTraceActivity.ActivityId);
                }

                unsafe
                {
                    if ((eventPayload == null)
                        || (eventPayload.Length == 0)
                        || (eventPayload.Length == 1))
                    {
                        string dataString = null;
                        UnsafeNativeMethods.EventData userData;

                        byte* dataBuffer = stackalloc byte[basicTypeAllocationBufferSize]; // Assume a max of 16 chars for non-string argument

                        userData.Size = 0;
                        if ((eventPayload != null) && (eventPayload.Length != 0))
                        {
                            //
                            // Figure out the type and fill the data descriptor
                            //
                            dataString = EncodeObject(ref eventPayload[0], &userData, dataBuffer);
                            argCount = 1;
                        }

                        if (userData.Size > traceEventMaximumSize)
                        {
                            //
                            // Maximum size of the event payload plus header is 64k
                            //
                            errorCode = WriteEventErrorCode.EventTooBig;
                            return false;
                        }

                        if (dataString != null)
                        {
                            fixed (char* pdata = dataString)
                            {
                                userData.DataPointer = (ulong)pdata;
                                status = UnsafeNativeMethods.EventWrite(this.traceRegistrationHandle, ref eventDescriptor, (uint)argCount, &userData);
                            }
                        }
                        else
                        {
                            if (argCount == 0)
                            {
                                status = UnsafeNativeMethods.EventWrite(this.traceRegistrationHandle, ref eventDescriptor, 0, null);
                            }
                            else
                            {
                                status = UnsafeNativeMethods.EventWrite(this.traceRegistrationHandle, ref eventDescriptor, (uint)argCount, &userData);
                            }

                        }
                    }
                    else
                    {

                        argCount = eventPayload.Length;

                        if (argCount > etwMaxNumberArguments)
                        {
                            //
                            //too many arguments to log
                            //
                            throw Fx.Exception.AsError(new ArgumentOutOfRangeException("eventPayload",
                                InternalSR.EtwMaxNumberArgumentsExceeded(etwMaxNumberArguments)));
                        }

                        uint totalEventSize = 0;
                        int index;
                        int stringIndex = 0;
                        int[] stringPosition = new int[etwAPIMaxStringCount];
                        string[] dataString = new string[etwAPIMaxStringCount];
                        UnsafeNativeMethods.EventData* userData = stackalloc UnsafeNativeMethods.EventData[argCount];
                        UnsafeNativeMethods.EventData* userDataPtr = (UnsafeNativeMethods.EventData*)userData;
                        byte* dataBuffer = stackalloc byte[basicTypeAllocationBufferSize * argCount]; // Assume 16 chars for non-string argument
                        byte* currentBuffer = dataBuffer;

                        //
                        // The loop below goes through all the arguments and fills in the data 
                        // descriptors. For strings save the location in the dataString array.
                        // Caculates the total size of the event by adding the data descriptor
                        // size value set in EncodeObjec method.
                        //
                        for (index = 0; index < eventPayload.Length; index++)
                        {
                            if (eventPayload[index] != null)
                            {
                                string isString;
                                isString = EncodeObject(ref eventPayload[index], userDataPtr, currentBuffer);
                                currentBuffer += basicTypeAllocationBufferSize;
                                totalEventSize += userDataPtr->Size;
                                userDataPtr++;
                                if (isString != null)
                                {
                                    if (stringIndex < etwAPIMaxStringCount)
                                    {
                                        dataString[stringIndex] = isString;
                                        stringPosition[stringIndex] = index;
                                        stringIndex++;
                                    }
                                    else
                                    {
                                        throw Fx.Exception.AsError(new ArgumentOutOfRangeException("eventPayload",
                                            InternalSR.EtwAPIMaxStringCountExceeded(etwAPIMaxStringCount))); 
                                    }
                                }
                            }
                        }

                        if (totalEventSize > traceEventMaximumSize)
                        {
                            errorCode = WriteEventErrorCode.EventTooBig;
                            return false;
                        }

                        //
                        // now fix any string arguments and set the pointer on the data descriptor 
                        //
                        fixed (char* v0 = dataString[0], v1 = dataString[1], v2 = dataString[2], v3 = dataString[3],
                                v4 = dataString[4], v5 = dataString[5], v6 = dataString[6], v7 = dataString[7])
                        {
                            userDataPtr = (UnsafeNativeMethods.EventData*)userData;
                            if (dataString[0] != null)
                            {
                                userDataPtr[stringPosition[0]].DataPointer = (ulong)v0;
                            }
                            if (dataString[1] != null)
                            {
                                userDataPtr[stringPosition[1]].DataPointer = (ulong)v1;
                            }
                            if (dataString[2] != null)
                            {
                                userDataPtr[stringPosition[2]].DataPointer = (ulong)v2;
                            }
                            if (dataString[3] != null)
                            {
                                userDataPtr[stringPosition[3]].DataPointer = (ulong)v3;
                            }
                            if (dataString[4] != null)
                            {
                                userDataPtr[stringPosition[4]].DataPointer = (ulong)v4;
                            }
                            if (dataString[5] != null)
                            {
                                userDataPtr[stringPosition[5]].DataPointer = (ulong)v5;
                            }
                            if (dataString[6] != null)
                            {
                                userDataPtr[stringPosition[6]].DataPointer = (ulong)v6;
                            }
                            if (dataString[7] != null)
                            {
                                userDataPtr[stringPosition[7]].DataPointer = (ulong)v7;
                            }

                            status = UnsafeNativeMethods.EventWrite(this.traceRegistrationHandle, ref eventDescriptor, (uint)argCount, userData);
                        }

                    }
                }
            }

            if (status != 0)
            {
                SetLastError((int)status);
                return false;
            }

            return true;
        }
示例#13
0
 static void CreateEventDescriptors()
 {
     System.Runtime.Diagnostics.EventDescriptor[] descriptors = new System.Runtime.Diagnostics.EventDescriptor[] {
             new System.Runtime.Diagnostics.EventDescriptor(39456, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)125, 0xa26, 0x1000000000000040),
             new System.Runtime.Diagnostics.EventDescriptor(39457, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)126, 0xa26, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(39458, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)127, 0xa26, 0x1000000000000040),
             new System.Runtime.Diagnostics.EventDescriptor(39459, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0xa25, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1223, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Info, 0x9e7, 0x1000000002000000),
             new System.Runtime.Diagnostics.EventDescriptor(2576, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)131, 0xa29, 0x1000000002000000),
             new System.Runtime.Diagnostics.EventDescriptor(2577, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)129, 0xa29, 0x1000000002000000),
             new System.Runtime.Diagnostics.EventDescriptor(2578, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)130, 0xa29, 0x1000000002000000),
             new System.Runtime.Diagnostics.EventDescriptor(1023, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)21, 0x9d6, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1019, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)22, 0x9d6, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1016, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)23, 0x9d6, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1013, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)24, 0x9d6, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1031, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)25, 0x9d6, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1034, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)26, 0x9d6, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1028, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)27, 0x9d6, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1020, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0x9dc, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1024, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0x9dc, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1038, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0x9ff, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1039, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0x9ff, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1040, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0x9e7, 0x1000000002000000),
             new System.Runtime.Diagnostics.EventDescriptor(1037, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)104, 0xa08, 0x1000000004000000),
             new System.Runtime.Diagnostics.EventDescriptor(1036, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)105, 0xa08, 0x1000000004000000),
             new System.Runtime.Diagnostics.EventDescriptor(1035, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)106, 0xa08, 0x1000000004000000),
             new System.Runtime.Diagnostics.EventDescriptor(1021, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)107, 0xa0a, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1017, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)108, 0xa0a, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1014, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)109, 0xa0a, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1011, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)110, 0xa0a, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1029, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)111, 0xa0a, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1032, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)112, 0xa0a, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1026, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)113, 0xa0a, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1022, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)117, 0xa1e, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1018, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)118, 0xa1e, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1015, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)119, 0xa1e, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1012, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)120, 0xa1e, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1030, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)121, 0xa1e, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1033, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)122, 0xa1e, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1027, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)123, 0xa1e, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1025, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0x9f5, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1104, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Resume, 0xa2f, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1101, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Start, 0xa2f, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1102, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Stop, 0xa2f, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1103, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Suspend, 0xa2f, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1010, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Info, 0x9d5, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1009, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Info, 0xa09, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1004, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)136, 0xa2d, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1003, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)137, 0xa2d, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1001, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)134, 0xa2d, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1005, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)135, 0xa2d, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1041, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)138, 0xa2d, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1007, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)139, 0xa2d, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1002, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)140, 0xa2d, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1006, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Error, (byte)141, 0xa2d, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1008, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)142, 0xa2d, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1124, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)73, 0x9f7, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1125, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)72, 0x9f7, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1126, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)74, 0x9f7, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1131, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)75, 0x9f7, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1132, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)71, 0x9f7, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(1140, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)11, 0x9e8, 0x1000000002000000),
             new System.Runtime.Diagnostics.EventDescriptor(1141, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)60, 0x9e8, 0x1000000002000000),
             new System.Runtime.Diagnostics.EventDescriptor(1143, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)61, 0x9e8, 0x1000000002000000),
             new System.Runtime.Diagnostics.EventDescriptor(1146, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)62, 0x9e8, 0x1000000002000000),
             new System.Runtime.Diagnostics.EventDescriptor(1147, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)64, 0x9e8, 0x1000000002000000),
             new System.Runtime.Diagnostics.EventDescriptor(1148, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)63, 0x9e8, 0x1000000002000000),
             new System.Runtime.Diagnostics.EventDescriptor(1150, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Info, 0x9d4, 0x1000000002000000),
             new System.Runtime.Diagnostics.EventDescriptor(39460, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)TraceEventOpcode.Info, 0xa25, 0x1000000000000040),
             new System.Runtime.Diagnostics.EventDescriptor(2021, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0x9e9, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(2022, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Stop, 0x9e9, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(2024, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0x9f6, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(2025, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Stop, 0x9f6, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(2026, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0xa2a, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(2029, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Stop, 0xa2a, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(2027, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0x9ce, 0x1000000001000000),
             new System.Runtime.Diagnostics.EventDescriptor(2028, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Stop, 0x9ce, 0x1000000001000000)};
     ushort[] e2eEvents = new ushort[0];
     FxTrace.UpdateEventDefinitions(descriptors, e2eEvents);
     eventDescriptors = descriptors;
 }
示例#14
0
 /// <summary>
 /// Creates the event descriptors array
 /// </summary>
 static void CreateEventDescriptors()
 {
     System.Runtime.Diagnostics.EventDescriptor[] descriptors = new System.Runtime.Diagnostics.EventDescriptor[] {
             new System.Runtime.Diagnostics.EventDescriptor(4801, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)30, 0x9e1, 0x1000000000004000),
             new System.Runtime.Diagnostics.EventDescriptor(4802, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)29, 0x9e1, 0x1000000000004000),
             new System.Runtime.Diagnostics.EventDescriptor(4803, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)31, 0x9e1, 0x1000000000004000),
             new System.Runtime.Diagnostics.EventDescriptor(4804, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)45, 0x9e3, 0x1000000000004000),
             new System.Runtime.Diagnostics.EventDescriptor(4805, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)37, 0x9e3, 0x1000000000004000),
             new System.Runtime.Diagnostics.EventDescriptor(4806, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)38, 0x9e3, 0x1000000000004000),
             new System.Runtime.Diagnostics.EventDescriptor(4807, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)39, 0x9e3, 0x1000000000004000),
             new System.Runtime.Diagnostics.EventDescriptor(4808, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)40, 0x9e3, 0x1000000000004000),
             new System.Runtime.Diagnostics.EventDescriptor(4809, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)41, 0x9e3, 0x1000000000004000),
             new System.Runtime.Diagnostics.EventDescriptor(4810, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)42, 0x9e3, 0x1000000000004000),
             new System.Runtime.Diagnostics.EventDescriptor(4811, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)43, 0x9e3, 0x1000000000004000),
             new System.Runtime.Diagnostics.EventDescriptor(4812, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)44, 0x9e3, 0x1000000000004000),
             new System.Runtime.Diagnostics.EventDescriptor(4813, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)36, 0x9e3, 0x1000000000004000),
             new System.Runtime.Diagnostics.EventDescriptor(4814, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)58, 0x9e6, 0x1000000000004000),
             new System.Runtime.Diagnostics.EventDescriptor(4815, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)59, 0x9e6, 0x1000000000004000),
             new System.Runtime.Diagnostics.EventDescriptor(4816, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)33, 0x9e2, 0x1000000000004000),
             new System.Runtime.Diagnostics.EventDescriptor(4817, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)32, 0x9e2, 0x1000000000004000),
             new System.Runtime.Diagnostics.EventDescriptor(4818, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)34, 0x9e2, 0x1000000000004000),
             new System.Runtime.Diagnostics.EventDescriptor(4819, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)35, 0x9e2, 0x1000000000004000),
             new System.Runtime.Diagnostics.EventDescriptor(4820, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)46, 0x9e4, 0x1000000000004000),
             new System.Runtime.Diagnostics.EventDescriptor(4821, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)47, 0x9e4, 0x1000000000004000)};
     ushort[] e2eEvents = new ushort[] {
             4804,
             4805,
             4806,
             4807,
             4808,
             4809,
             4811,
             4812,
             4813};
     FxTrace.UpdateEventDefinitions(descriptors, e2eEvents);
     eventDescriptors = descriptors;
 }
示例#15
0
        internal unsafe bool WriteEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, Guid value1, long value2, long value3, string value4,
            string value5, string value6, string value7, string value8, string value9, string value10, string value11, string value12,
            bool value13, string value14, string value15, string value16, string value17)
        {
            const int argumentCount = 17;
            bool status = true;

            //check all strings for null           
            value4 = (value4 ?? string.Empty);
            value5 = (value5 ?? string.Empty);
            value6 = (value6 ?? string.Empty);
            value7 = (value7 ?? string.Empty);
            value8 = (value8 ?? string.Empty);
            value9 = (value9 ?? string.Empty);
            value10 = (value10 ?? string.Empty);
            value11 = (value11 ?? string.Empty);
            value12 = (value12 ?? string.Empty);
            //value13 is not string            
            value14 = (value14 ?? string.Empty);
            value15 = (value15 ?? string.Empty);
            value16 = (value16 ?? string.Empty);
            value17 = (value17 ?? string.Empty);

            fixed (char* string1Bytes = value4, string2Bytes = value5, string3Bytes = value6, string4Bytes = value7, string5Bytes = value8, string6Bytes = value9,
            string7Bytes = value10, string8Bytes = value11, string9Bytes = value12, string10Bytes = value14, string11Bytes = value15, 
            string12Bytes = value16, string13Bytes = value17)
            {
                byte* eventData = stackalloc byte[sizeof(UnsafeNativeMethods.EventData) * argumentCount];
                UnsafeNativeMethods.EventData* eventDataPtr = (UnsafeNativeMethods.EventData*)eventData;                

                eventDataPtr[0].DataPointer = (ulong)(&value1);
                eventDataPtr[0].Size = (uint)(sizeof(Guid));

                eventDataPtr[1].DataPointer = (ulong)(&value2);
                eventDataPtr[1].Size = (uint)(sizeof(long));

                eventDataPtr[2].DataPointer = (ulong)(&value3);
                eventDataPtr[2].Size = (uint)(sizeof(long));
               
                eventDataPtr[3].DataPointer = (ulong)string1Bytes;
                eventDataPtr[3].Size = (uint)(value4.Length + 1) * sizeof(char);
           
                eventDataPtr[4].DataPointer = (ulong)string2Bytes;
                eventDataPtr[4].Size = (uint)(value5.Length + 1) * sizeof(char);
           
                eventDataPtr[5].DataPointer = (ulong)string3Bytes;
                eventDataPtr[5].Size = (uint)(value6.Length + 1) * sizeof(char);
           
                eventDataPtr[6].DataPointer = (ulong)string4Bytes;
                eventDataPtr[6].Size = (uint)(value7.Length + 1) * sizeof(char);
           
                eventDataPtr[7].DataPointer = (ulong)string5Bytes;
                eventDataPtr[7].Size = (uint)(value8.Length + 1) * sizeof(char);
           
                eventDataPtr[8].DataPointer = (ulong)string6Bytes;
                eventDataPtr[8].Size = (uint)(value9.Length + 1) * sizeof(char);
            
                eventDataPtr[9].DataPointer = (ulong)string7Bytes;
                eventDataPtr[9].Size = (uint)(value10.Length + 1) * sizeof(char);
            
                eventDataPtr[10].DataPointer = (ulong)string8Bytes;
                eventDataPtr[10].Size = (uint)(value11.Length + 1) * sizeof(char);
           
                eventDataPtr[11].DataPointer = (ulong)string9Bytes;
                eventDataPtr[11].Size = (uint)(value12.Length + 1) * sizeof(char);
               
                eventDataPtr[12].DataPointer = (ulong)(&value13);
                eventDataPtr[12].Size = (uint)(sizeof(bool));
               
                eventDataPtr[13].DataPointer = (ulong)string10Bytes;
                eventDataPtr[13].Size = (uint)(value14.Length + 1) * sizeof(char);
           
                eventDataPtr[14].DataPointer = (ulong)string11Bytes;
                eventDataPtr[14].Size = (uint)(value15.Length + 1) * sizeof(char);
           
                eventDataPtr[15].DataPointer = (ulong)string12Bytes;
                eventDataPtr[15].Size = (uint)(value16.Length + 1) * sizeof(char);
           
                eventDataPtr[16].DataPointer = (ulong)string13Bytes;
                eventDataPtr[16].Size = (uint)(value17.Length + 1) * sizeof(char);
               
                status = WriteEvent(ref eventDescriptor, eventTraceActivity, argumentCount, (IntPtr)(eventData));
            }

            return status;

        }
示例#16
0
        public unsafe bool WriteTransferEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, Guid relatedActivityId, object[] eventPayload)
        {
            if (eventTraceActivity == null)
            {
                eventTraceActivity = EventTraceActivity.Empty;
            }
            uint num = 0;

            if (this.IsEnabled(eventDescriptor.Level, eventDescriptor.Keywords))
            {
                if (eventPayload == null || (int)eventPayload.Length == 0)
                {
                    num = UnsafeNativeMethods.EventWriteTransfer(this.traceRegistrationHandle, ref eventDescriptor, ref eventTraceActivity.ActivityId, ref relatedActivityId, 0, 0);
                }
                else
                {
                    int length = (int)eventPayload.Length;
                    if (length <= 32)
                    {
                        uint     size      = 0;
                        int      num1      = 0;
                        int[]    numArray  = new int[8];
                        string[] strArrays = new string[8];
                        UnsafeNativeMethods.EventData *eventDataPointer  = (UnsafeNativeMethods.EventData *)length * sizeof(UnsafeNativeMethods.EventData);
                        UnsafeNativeMethods.EventData *eventDataPointer1 = eventDataPointer;
                        byte *numPointer  = (byte *)16 * length;
                        byte *numPointer1 = numPointer;
                        for (int i = 0; i < (int)eventPayload.Length; i++)
                        {
                            if (eventPayload[i] != null)
                            {
                                string str = DiagnosticsEventProvider.EncodeObject(ref eventPayload[i], eventDataPointer1, numPointer1);
                                numPointer1       = numPointer1 + 16;
                                size              = size + (*(eventDataPointer1)).Size;
                                eventDataPointer1 = (UnsafeNativeMethods.EventData *)(eventDataPointer1 + sizeof(UnsafeNativeMethods.EventData));
                                if (str != null)
                                {
                                    if (num1 >= 8)
                                    {
                                        throw Fx.Exception.AsError(new ArgumentOutOfRangeException("eventPayload", InternalSR.EtwAPIMaxStringCountExceeded(8)));
                                    }
                                    else
                                    {
                                        strArrays[num1] = str;
                                        numArray[num1]  = i;
                                        num1++;
                                    }
                                }
                            }
                        }
                        if (size <= 0xffca)
                        {
                            fixed(string str1 = strArrays[0])
                            {
                                string *strPointers        = &str1;
                                char *  offsetToStringData = (char *)(&str1);

                                if (&str1 != null)
                                {
                                    offsetToStringData = (char *)(strPointers + RuntimeHelpers.OffsetToStringData);
                                }
                                char *chrPointer = offsetToStringData;

                                fixed(string str2 = strArrays[1])
                                {
                                    string *strPointers1        = &str2;
                                    char *  offsetToStringData1 = (char *)(&str2);

                                    if (&str2 != null)
                                    {
                                        offsetToStringData1 = (char *)(strPointers1 + RuntimeHelpers.OffsetToStringData);
                                    }
                                    char *chrPointer1 = offsetToStringData1;

                                    fixed(string str3 = strArrays[2])
                                    {
                                        string *strPointers2        = &str3;
                                        char *  offsetToStringData2 = (char *)(&str3);

                                        if (&str3 != null)
                                        {
                                            offsetToStringData2 = (char *)(strPointers2 + RuntimeHelpers.OffsetToStringData);
                                        }
                                        char *chrPointer2 = offsetToStringData2;

                                        fixed(string str4 = strArrays[3])
                                        {
                                            string *strPointers3        = &str4;
                                            char *  offsetToStringData3 = (char *)(&str4);

                                            if (&str4 != null)
                                            {
                                                offsetToStringData3 = (char *)(strPointers3 + RuntimeHelpers.OffsetToStringData);
                                            }
                                            char *chrPointer3 = offsetToStringData3;

                                            fixed(string str5 = strArrays[4])
                                            {
                                                string *strPointers4        = &str5;
                                                char *  offsetToStringData4 = (char *)(&str5);

                                                if (&str5 != null)
                                                {
                                                    offsetToStringData4 = (char *)(strPointers4 + RuntimeHelpers.OffsetToStringData);
                                                }
                                                char *chrPointer4 = offsetToStringData4;

                                                fixed(string str6 = strArrays[5])
                                                {
                                                    string *strPointers5        = &str6;
                                                    char *  offsetToStringData5 = (char *)(&str6);

                                                    if (&str6 != null)
                                                    {
                                                        offsetToStringData5 = (char *)(strPointers5 + RuntimeHelpers.OffsetToStringData);
                                                    }
                                                    char *chrPointer5 = offsetToStringData5;

                                                    fixed(string str7 = strArrays[6])
                                                    {
                                                        string *strPointers6        = &str7;
                                                        char *  offsetToStringData6 = (char *)(&str7);

                                                        if (&str7 != null)
                                                        {
                                                            offsetToStringData6 = (char *)(strPointers6 + RuntimeHelpers.OffsetToStringData);
                                                        }
                                                        char *chrPointer6 = offsetToStringData6;

                                                        fixed(string str8 = strArrays[7])
                                                        {
                                                            string *strPointers7        = &str8;
                                                            char *  offsetToStringData7 = (char *)(&str8);

                                                            if (&str8 != null)
                                                            {
                                                                offsetToStringData7 = (char *)(strPointers7 + RuntimeHelpers.OffsetToStringData);
                                                            }
                                                            char *chrPointer7 = offsetToStringData7;

                                                            eventDataPointer1 = eventDataPointer;
                                                            if (strArrays[0] != null)
                                                            {
                                                                (eventDataPointer1 + numArray[0] * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer;
                                                            }
                                                            if (strArrays[1] != null)
                                                            {
                                                                (eventDataPointer1 + numArray[1] * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer1;
                                                            }
                                                            if (strArrays[2] != null)
                                                            {
                                                                (eventDataPointer1 + numArray[2] * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer2;
                                                            }
                                                            if (strArrays[3] != null)
                                                            {
                                                                (eventDataPointer1 + numArray[3] * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer3;
                                                            }
                                                            if (strArrays[4] != null)
                                                            {
                                                                (eventDataPointer1 + numArray[4] * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer4;
                                                            }
                                                            if (strArrays[5] != null)
                                                            {
                                                                (eventDataPointer1 + numArray[5] * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer5;
                                                            }
                                                            if (strArrays[6] != null)
                                                            {
                                                                (eventDataPointer1 + numArray[6] * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer6;
                                                            }
                                                            if (strArrays[7] != null)
                                                            {
                                                                (eventDataPointer1 + numArray[7] * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer7;
                                                            }
                                                            num = UnsafeNativeMethods.EventWriteTransfer(this.traceRegistrationHandle, ref eventDescriptor, ref eventTraceActivity.ActivityId, ref relatedActivityId, length, eventDataPointer);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            DiagnosticsEventProvider.errorCode = DiagnosticsEventProvider.WriteEventErrorCode.EventTooBig;
                            return(false);
                        }
                    }
                    else
                    {
                        throw Fx.Exception.AsError(new ArgumentOutOfRangeException("eventPayload", InternalSR.EtwMaxNumberArgumentsExceeded(32)));
                    }
                }
            }
            if (num == 0)
            {
                return(true);
            }
            else
            {
                DiagnosticsEventProvider.SetLastError(num);
                return(false);
            }
        }
示例#17
0
 public void WriteTraceSource(ref EventDescriptor eventDescriptor, string description, TracePayload payload)
 {
 }
示例#18
0
		internal unsafe bool WriteEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, Guid value1, long value2, long value3, string value4, string value5, string value6, string value7, string value8, string value9, string value10, string value11, string value12, bool value13, string value14, string value15, string value16, string value17)
		{
			string str = value4;
			string empty = str;
			if (str == null)
			{
				empty = string.Empty;
			}
			value4 = empty;
			string str1 = value5;
			string empty1 = str1;
			if (str1 == null)
			{
				empty1 = string.Empty;
			}
			value5 = empty1;
			string str2 = value6;
			string empty2 = str2;
			if (str2 == null)
			{
				empty2 = string.Empty;
			}
			value6 = empty2;
			string str3 = value7;
			string empty3 = str3;
			if (str3 == null)
			{
				empty3 = string.Empty;
			}
			value7 = empty3;
			string str4 = value8;
			string empty4 = str4;
			if (str4 == null)
			{
				empty4 = string.Empty;
			}
			value8 = empty4;
			string str5 = value9;
			string empty5 = str5;
			if (str5 == null)
			{
				empty5 = string.Empty;
			}
			value9 = empty5;
			string str6 = value10;
			string empty6 = str6;
			if (str6 == null)
			{
				empty6 = string.Empty;
			}
			value10 = empty6;
			string str7 = value11;
			string empty7 = str7;
			if (str7 == null)
			{
				empty7 = string.Empty;
			}
			value11 = empty7;
			string str8 = value12;
			string empty8 = str8;
			if (str8 == null)
			{
				empty8 = string.Empty;
			}
			value12 = empty8;
			string str9 = value14;
			string empty9 = str9;
			if (str9 == null)
			{
				empty9 = string.Empty;
			}
			value14 = empty9;
			string str10 = value15;
			string empty10 = str10;
			if (str10 == null)
			{
				empty10 = string.Empty;
			}
			value15 = empty10;
			string str11 = value16;
			string empty11 = str11;
			if (str11 == null)
			{
				empty11 = string.Empty;
			}
			value16 = empty11;
			string str12 = value17;
			string empty12 = str12;
			if (str12 == null)
			{
				empty12 = string.Empty;
			}
			value17 = empty12;
			fixed (string str13 = value4)
			{
				string* strPointers = &str13;
				char* offsetToStringData = (char*)(&str13);
				if (&str13 != null)
				{
					offsetToStringData = (char*)(strPointers + RuntimeHelpers.OffsetToStringData);
				}
				char* chrPointer = offsetToStringData;
				fixed (string str14 = value5)
				{
					string* strPointers1 = &str14;
					char* offsetToStringData1 = (char*)(&str14);
					if (&str14 != null)
					{
						offsetToStringData1 = (char*)(strPointers1 + RuntimeHelpers.OffsetToStringData);
					}
					char* chrPointer1 = offsetToStringData1;
					fixed (string str15 = value6)
					{
						string* strPointers2 = &str15;
						char* offsetToStringData2 = (char*)(&str15);
						if (&str15 != null)
						{
							offsetToStringData2 = (char*)(strPointers2 + RuntimeHelpers.OffsetToStringData);
						}
						char* chrPointer2 = offsetToStringData2;
						fixed (string str16 = value7)
						{
							string* strPointers3 = &str16;
							char* offsetToStringData3 = (char*)(&str16);
							if (&str16 != null)
							{
								offsetToStringData3 = (char*)(strPointers3 + RuntimeHelpers.OffsetToStringData);
							}
							char* chrPointer3 = offsetToStringData3;
							fixed (string str17 = value8)
							{
								string* strPointers4 = &str17;
								char* offsetToStringData4 = (char*)(&str17);
								if (&str17 != null)
								{
									offsetToStringData4 = (char*)(strPointers4 + RuntimeHelpers.OffsetToStringData);
								}
								char* chrPointer4 = offsetToStringData4;
								fixed (string str18 = value9)
								{
									string* strPointers5 = &str18;
									char* offsetToStringData5 = (char*)(&str18);
									if (&str18 != null)
									{
										offsetToStringData5 = (char*)(strPointers5 + RuntimeHelpers.OffsetToStringData);
									}
									char* chrPointer5 = offsetToStringData5;
									fixed (string str19 = value10)
									{
										string* strPointers6 = &str19;
										char* offsetToStringData6 = (char*)(&str19);
										if (&str19 != null)
										{
											offsetToStringData6 = (char*)(strPointers6 + RuntimeHelpers.OffsetToStringData);
										}
										char* chrPointer6 = offsetToStringData6;
										fixed (string str20 = value11)
										{
											string* strPointers7 = &str20;
											char* offsetToStringData7 = (char*)(&str20);
											if (&str20 != null)
											{
												offsetToStringData7 = (char*)(strPointers7 + RuntimeHelpers.OffsetToStringData);
											}
											char* chrPointer7 = offsetToStringData7;
											fixed (string str21 = value12)
											{
												string* strPointers8 = &str21;
												char* offsetToStringData8 = (char*)(&str21);
												if (&str21 != null)
												{
													offsetToStringData8 = (char*)(strPointers8 + RuntimeHelpers.OffsetToStringData);
												}
												char* chrPointer8 = offsetToStringData8;
												fixed (string str22 = value14)
												{
													string* strPointers9 = &str22;
													char* offsetToStringData9 = (char*)(&str22);
													if (&str22 != null)
													{
														offsetToStringData9 = (char*)(strPointers9 + RuntimeHelpers.OffsetToStringData);
													}
													char* chrPointer9 = offsetToStringData9;
													fixed (string str23 = value15)
													{
														string* strPointers10 = &str23;
														char* offsetToStringData10 = (char*)(&str23);
														if (&str23 != null)
														{
															offsetToStringData10 = (char*)(strPointers10 + RuntimeHelpers.OffsetToStringData);
														}
														char* chrPointer10 = offsetToStringData10;
														fixed (string str24 = value16)
														{
															string* strPointers11 = &str24;
															char* offsetToStringData11 = (char*)(&str24);
															if (&str24 != null)
															{
																offsetToStringData11 = (char*)(strPointers11 + RuntimeHelpers.OffsetToStringData);
															}
															char* chrPointer11 = offsetToStringData11;
															fixed (string str25 = value17)
															{
																string* strPointers12 = &str25;
																char* offsetToStringData12 = (char*)(&str25);
																if (&str25 != null)
																{
																	offsetToStringData12 = (char*)(strPointers12 + RuntimeHelpers.OffsetToStringData);
																}
																/*
																byte* length = (byte*)sizeof(UnsafeNativeMethods.EventData) * 17;
																(*((UnsafeNativeMethods.EventData*)length)).DataPointer = (ulong)(&value1);
																(*((UnsafeNativeMethods.EventData*)length)).Size = sizeof(Guid);
																((UnsafeNativeMethods.EventData*)length + sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)(&value2);
																((UnsafeNativeMethods.EventData*)length + sizeof(UnsafeNativeMethods.EventData)).Size = 8;
																((UnsafeNativeMethods.EventData*)length + 2 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)(&value3);
																((UnsafeNativeMethods.EventData*)length + 2 * sizeof(UnsafeNativeMethods.EventData)).Size = 8;
																((UnsafeNativeMethods.EventData*)length + 3 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer;
																((UnsafeNativeMethods.EventData*)length + 3 * sizeof(UnsafeNativeMethods.EventData)).Size = (value4.Length + 1) * 2;
																((UnsafeNativeMethods.EventData*)length + 4 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer1;
																((UnsafeNativeMethods.EventData*)length + 4 * sizeof(UnsafeNativeMethods.EventData)).Size = (value5.Length + 1) * 2;
																((UnsafeNativeMethods.EventData*)length + 5 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer2;
																((UnsafeNativeMethods.EventData*)length + 5 * sizeof(UnsafeNativeMethods.EventData)).Size = (value6.Length + 1) * 2;
																((UnsafeNativeMethods.EventData*)length + 6 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer3;
																((UnsafeNativeMethods.EventData*)length + 6 * sizeof(UnsafeNativeMethods.EventData)).Size = (value7.Length + 1) * 2;
																((UnsafeNativeMethods.EventData*)length + 7 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer4;
																((UnsafeNativeMethods.EventData*)length + 7 * sizeof(UnsafeNativeMethods.EventData)).Size = (value8.Length + 1) * 2;
																((UnsafeNativeMethods.EventData*)length + 8 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer5;
																((UnsafeNativeMethods.EventData*)length + 8 * sizeof(UnsafeNativeMethods.EventData)).Size = (value9.Length + 1) * 2;
																((UnsafeNativeMethods.EventData*)length + 9 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer6;
																((UnsafeNativeMethods.EventData*)length + 9 * sizeof(UnsafeNativeMethods.EventData)).Size = (value10.Length + 1) * 2;
																((UnsafeNativeMethods.EventData*)length + 10 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer7;
																((UnsafeNativeMethods.EventData*)length + 10 * sizeof(UnsafeNativeMethods.EventData)).Size = (value11.Length + 1) * 2;
																((UnsafeNativeMethods.EventData*)length + 11 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer8;
																((UnsafeNativeMethods.EventData*)length + 11 * sizeof(UnsafeNativeMethods.EventData)).Size = (value12.Length + 1) * 2;
																((UnsafeNativeMethods.EventData*)length + 12 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)(&value13);
																((UnsafeNativeMethods.EventData*)length + 12 * sizeof(UnsafeNativeMethods.EventData)).Size = 1;
																((UnsafeNativeMethods.EventData*)length + 13 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer9;
																((UnsafeNativeMethods.EventData*)length + 13 * sizeof(UnsafeNativeMethods.EventData)).Size = (value14.Length + 1) * 2;
																((UnsafeNativeMethods.EventData*)length + 14 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer10;
																((UnsafeNativeMethods.EventData*)length + 14 * sizeof(UnsafeNativeMethods.EventData)).Size = (value15.Length + 1) * 2;
																((UnsafeNativeMethods.EventData*)length + 15 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer11;
																((UnsafeNativeMethods.EventData*)length + 15 * sizeof(UnsafeNativeMethods.EventData)).Size = (value16.Length + 1) * 2;
																((UnsafeNativeMethods.EventData*)length + 16 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)offsetToStringData12;
																((UnsafeNativeMethods.EventData*)length + 16 * sizeof(UnsafeNativeMethods.EventData)).Size = (value17.Length + 1) * 2; 
																 */
																bool flag = base.WriteEvent(ref eventDescriptor, eventTraceActivity, 17, IntPtr.Zero); //TODO: REVIEW: (IntPtr)length);
																return flag;
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
示例#19
0
 public bool IsEtwEventEnabled(ref EventDescriptor eventDescriptor, bool fullCheck)
 {
     return(false);
 }
示例#20
0
 internal static extern unsafe uint EventWriteTransfer(long registrationHandle, ref System.Runtime.Diagnostics.EventDescriptor eventDescriptor, ref Guid activityId, ref Guid relatedActivityId, uint userDataCount, UnsafeNativeMethods.EventData *userData);
示例#21
0
 internal static extern unsafe uint EventWrite(long registrationHandle, ref System.Runtime.Diagnostics.EventDescriptor eventDescriptor, uint userDataCount, UnsafeNativeMethods.EventData *userData);
示例#22
0
 /// <summary>
 /// Creates the event descriptors array
 /// </summary>
 static void CreateEventDescriptors()
 {
     System.Runtime.Diagnostics.EventDescriptor[] descriptors = new System.Runtime.Diagnostics.EventDescriptor[] {
         new System.Runtime.Diagnostics.EventDescriptor(4001, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Receive, 0x9c4, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4002, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Critical, (byte)TraceEventOpcode.Info, 0xa2b, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4003, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0x9c9, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4008, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0x9c4, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4010, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Warning, (byte)TraceEventOpcode.Info, 0x9c4, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4011, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0x9fd, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4014, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0x9fd, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4015, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Info, 0x9fd, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4012, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0x9fd, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4013, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Stop, 0x9fd, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4016, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0x9c4, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4019, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Stop, 0x9c4, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4020, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0x9ca, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4021, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Stop, 0x9ca, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4022, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0xa2b, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4023, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Stop, 0xa2b, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4024, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Stop, 0xa2b, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4025, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0xa2b, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4026, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Verbose, (byte)132, 0xa2b, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4027, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Verbose, (byte)133, 0xa2b, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4028, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0x9c7, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4029, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Stop, 0x9c7, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4030, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Stop, 0x9c4, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4031, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0x9c4, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4032, 0, (byte)TraceChannel.Analytic, (byte)TraceEventLevel.Critical, (byte)TraceEventOpcode.Info, 0xa2b, 0x2000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4033, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0x9c8, 0x1000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4034, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Stop, 0x9c8, 0x1000000000000800),
         new System.Runtime.Diagnostics.EventDescriptor(4035, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0xa00, 0x1000000000400000)
     };
     ushort[] e2eEvents = new ushort[] {
         4001,
         4002,
         4008,
         4010,
         4011,
         4012,
         4013,
         4014,
         4015,
         4016,
         4019,
         4020,
         4021,
         4022,
         4023,
         4024,
         4025,
         4026,
         4027,
         4028,
         4029,
         4030,
         4031,
         4032
     };
     FxTrace.UpdateEventDefinitions(descriptors, e2eEvents);
     eventDescriptors = descriptors;
 }
 public bool IsEtwEventEnabled(ref EventDescriptor eventDescriptor)
 {
     return(IsEtwEventEnabled(ref eventDescriptor, true));
 }
示例#24
0
		internal unsafe bool WriteEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, string value1, long value2, string value3, string value4)
		{
			string str = value1;
			string empty = str;
			if (str == null)
			{
				empty = string.Empty;
			}
			value1 = empty;
			string str1 = value3;
			string empty1 = str1;
			if (str1 == null)
			{
				empty1 = string.Empty;
			}
			value3 = empty1;
			string str2 = value4;
			string empty2 = str2;
			if (str2 == null)
			{
				empty2 = string.Empty;
			}
			value4 = empty2;
			fixed (string str3 = value1)
			{
				string* strPointers = &str3;
				char* offsetToStringData = (char*)(&str3);
				if (&str3 != null)
				{
					offsetToStringData = (char*)(strPointers + RuntimeHelpers.OffsetToStringData);
				}
				char* chrPointer = offsetToStringData;
				fixed (string str4 = value3)
				{
					string* strPointers1 = &str4;
					char* offsetToStringData1 = (char*)(&str4);
					if (&str4 != null)
					{
						offsetToStringData1 = (char*)(strPointers1 + RuntimeHelpers.OffsetToStringData);
					}
					char* chrPointer1 = offsetToStringData1;
					fixed (string str5 = value4)
					{
						string* strPointers2 = &str5;
						char* offsetToStringData2 = (char*)(&str5);
						if (&str5 != null)
						{
							offsetToStringData2 = (char*)(strPointers2 + RuntimeHelpers.OffsetToStringData);
						}
						/*
						byte* length = (byte*)sizeof(UnsafeNativeMethods.EventData) * 4;
						(*((UnsafeNativeMethods.EventData*)length)).DataPointer = (ulong)chrPointer;
						(*((UnsafeNativeMethods.EventData*)length)).Size = (value1.Length + 1) * 2;
						((UnsafeNativeMethods.EventData*)length + sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)(&value2);
						((UnsafeNativeMethods.EventData*)length + sizeof(UnsafeNativeMethods.EventData)).Size = 8;
						((UnsafeNativeMethods.EventData*)length + 2 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer1;
						((UnsafeNativeMethods.EventData*)length + 2 * sizeof(UnsafeNativeMethods.EventData)).Size = (value3.Length + 1) * 2;
						((UnsafeNativeMethods.EventData*)length + 3 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)offsetToStringData2;
						((UnsafeNativeMethods.EventData*)length + 3 * sizeof(UnsafeNativeMethods.EventData)).Size = (value4.Length + 1) * 2; */
						bool flag = base.WriteEvent(ref eventDescriptor, eventTraceActivity, 4, IntPtr.Zero); //TODO: REVIEW: (IntPtr)length);
						return flag;
					}
				}
			}
		}
示例#25
0
 public bool IsEtwEventEnabled(ref EventDescriptor eventDescriptor, bool fullCheck)
 {
     return false;
 }
示例#26
0
		internal unsafe bool WriteTransferEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, Guid relatedActivityId, string value1, string value2)
		{
			string str = value1;
			string empty = str;
			if (str == null)
			{
				empty = string.Empty;
			}
			value1 = empty;
			string str1 = value2;
			string empty1 = str1;
			if (str1 == null)
			{
				empty1 = string.Empty;
			}
			value2 = empty1;
			fixed (string str2 = value1)
			{
				string* strPointers = &str2;
				char* offsetToStringData = (char*)(&str2);
				if (&str2 != null)
				{
					offsetToStringData = (char*)(strPointers + RuntimeHelpers.OffsetToStringData);
				}
				char* chrPointer = offsetToStringData;
				fixed (string str3 = value2)
				{
					string* strPointers1 = &str3;
					char* offsetToStringData1 = (char*)(&str3);
					if (&str3 != null)
					{
						offsetToStringData1 = (char*)(strPointers1 + RuntimeHelpers.OffsetToStringData);
					}
					/*
					byte* length = (byte*)sizeof(UnsafeNativeMethods.EventData) * 2;
					(*((UnsafeNativeMethods.EventData*)length)).DataPointer = (ulong)chrPointer;
					(*((UnsafeNativeMethods.EventData*)length)).Size = (value1.Length + 1) * 2;
					((UnsafeNativeMethods.EventData*)length + sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)offsetToStringData1;
					((UnsafeNativeMethods.EventData*)length + sizeof(UnsafeNativeMethods.EventData)).Size = (value2.Length + 1) * 2;
					*/
					bool flag = base.WriteTransferEvent(ref eventDescriptor, eventTraceActivity, relatedActivityId, 2, IntPtr.Zero); //TODO: REVIEW: (IntPtr)length);
					return flag;
				}
			}
		}
示例#27
0
        internal unsafe bool WriteEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, string value1, string value2, string value3, string value4,
            string value5, string value6, string value7, string value8, string value9, string value10)
        {
            const int argumentCount = 10;
            bool status = true;

            //check all strings for null
            value1 = (value1 ?? string.Empty);
            value2 = (value2 ?? string.Empty);
            value3 = (value3 ?? string.Empty);
            value4 = (value4 ?? string.Empty);
            value5 = (value5 ?? string.Empty);
            value6 = (value6 ?? string.Empty);
            value7 = (value7 ?? string.Empty);
            value8 = (value8 ?? string.Empty);
            value9 = (value9 ?? string.Empty);
            value10 = (value10 ?? string.Empty);

            fixed (char* string1Bytes = value1, string2Bytes = value2, string3Bytes = value3, string4Bytes = value4, string5Bytes = value5, string6Bytes = value6,
            string7Bytes = value7, string8Bytes = value8, string9Bytes = value9, string10Bytes = value10)
            {
                byte* eventData = stackalloc byte[sizeof(UnsafeNativeMethods.EventData) * argumentCount];
                UnsafeNativeMethods.EventData* eventDataPtr = (UnsafeNativeMethods.EventData*)eventData;
                
                eventDataPtr[0].DataPointer = (ulong)string1Bytes;
                eventDataPtr[0].Size = (uint)(value1.Length + 1) * sizeof(char);
            
                eventDataPtr[1].DataPointer = (ulong)string2Bytes;
                eventDataPtr[1].Size = (uint)(value2.Length + 1) * sizeof(char);
            
                eventDataPtr[2].DataPointer = (ulong)string3Bytes;
                eventDataPtr[2].Size = (uint)(value3.Length + 1) * sizeof(char);
            
                eventDataPtr[3].DataPointer = (ulong)string4Bytes;
                eventDataPtr[3].Size = (uint)(value4.Length + 1) * sizeof(char);
            
                eventDataPtr[4].DataPointer = (ulong)string5Bytes;
                eventDataPtr[4].Size = (uint)(value5.Length + 1) * sizeof(char);
            
                eventDataPtr[5].DataPointer = (ulong)string6Bytes;
                eventDataPtr[5].Size = (uint)(value6.Length + 1) * sizeof(char);
            
                eventDataPtr[6].DataPointer = (ulong)string7Bytes;
                eventDataPtr[6].Size = (uint)(value7.Length + 1) * sizeof(char);
            
                eventDataPtr[7].DataPointer = (ulong)string8Bytes;
                eventDataPtr[7].Size = (uint)(value8.Length + 1) * sizeof(char);
            
                eventDataPtr[8].DataPointer = (ulong)string9Bytes;
                eventDataPtr[8].Size = (uint)(value9.Length + 1) * sizeof(char);
            
                eventDataPtr[9].DataPointer = (ulong)string10Bytes;
                eventDataPtr[9].Size = (uint)(value10.Length + 1) * sizeof(char);                

                status = WriteEvent(ref eventDescriptor, eventTraceActivity, argumentCount, (IntPtr)(eventData));
            }

            return status;
        }
示例#28
0
		internal unsafe bool WriteEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, string value1, string value2, string value3, string value4, string value5, string value6)
		{
			string str = value1;
			string empty = str;
			if (str == null)
			{
				empty = string.Empty;
			}
			value1 = empty;
			string str1 = value2;
			string empty1 = str1;
			if (str1 == null)
			{
				empty1 = string.Empty;
			}
			value2 = empty1;
			string str2 = value3;
			string empty2 = str2;
			if (str2 == null)
			{
				empty2 = string.Empty;
			}
			value3 = empty2;
			string str3 = value4;
			string empty3 = str3;
			if (str3 == null)
			{
				empty3 = string.Empty;
			}
			value4 = empty3;
			string str4 = value5;
			string empty4 = str4;
			if (str4 == null)
			{
				empty4 = string.Empty;
			}
			value5 = empty4;
			string str5 = value6;
			string empty5 = str5;
			if (str5 == null)
			{
				empty5 = string.Empty;
			}
			value6 = empty5;
			fixed (string str6 = value1)
			{
				string* strPointers = &str6;
				char* offsetToStringData = (char*)(&str6);
				if (&str6 != null)
				{
					offsetToStringData = (char*)(strPointers + RuntimeHelpers.OffsetToStringData);
				}
				char* chrPointer = offsetToStringData;
				fixed (string str7 = value2)
				{
					string* strPointers1 = &str7;
					char* offsetToStringData1 = (char*)(&str7);
					if (&str7 != null)
					{
						offsetToStringData1 = (char*)(strPointers1 + RuntimeHelpers.OffsetToStringData);
					}
					char* chrPointer1 = offsetToStringData1;
					fixed (string str8 = value3)
					{
						string* strPointers2 = &str8;
						char* offsetToStringData2 = (char*)(&str8);
						if (&str8 != null)
						{
							offsetToStringData2 = (char*)(strPointers2 + RuntimeHelpers.OffsetToStringData);
						}
						char* chrPointer2 = offsetToStringData2;
						fixed (string str9 = value4)
						{
							string* strPointers3 = &str9;
							char* offsetToStringData3 = (char*)(&str9);
							if (&str9 != null)
							{
								offsetToStringData3 = (char*)(strPointers3 + RuntimeHelpers.OffsetToStringData);
							}
							char* chrPointer3 = offsetToStringData3;
							fixed (string str10 = value5)
							{
								string* strPointers4 = &str10;
								char* offsetToStringData4 = (char*)(&str10);
								if (&str10 != null)
								{
									offsetToStringData4 = (char*)(strPointers4 + RuntimeHelpers.OffsetToStringData);
								}
								char* chrPointer4 = offsetToStringData4;
								fixed (string str11 = value6)
								{
									string* strPointers5 = &str11;
									char* offsetToStringData5 = (char*)(&str11);
									if (&str11 != null)
									{
										offsetToStringData5 = (char*)(strPointers5 + RuntimeHelpers.OffsetToStringData);
									}
									byte* length = (byte*)sizeof(UnsafeNativeMethods.EventData) * 6;
									(*((UnsafeNativeMethods.EventData*)length)).DataPointer = (ulong)chrPointer;
									(*((UnsafeNativeMethods.EventData*)length)).Size = (value1.Length + 1) * 2;
									((UnsafeNativeMethods.EventData*)length + sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer1;
									((UnsafeNativeMethods.EventData*)length + sizeof(UnsafeNativeMethods.EventData)).Size = (value2.Length + 1) * 2;
									((UnsafeNativeMethods.EventData*)length + 2 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer2;
									((UnsafeNativeMethods.EventData*)length + 2 * sizeof(UnsafeNativeMethods.EventData)).Size = (value3.Length + 1) * 2;
									((UnsafeNativeMethods.EventData*)length + 3 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer3;
									((UnsafeNativeMethods.EventData*)length + 3 * sizeof(UnsafeNativeMethods.EventData)).Size = (value4.Length + 1) * 2;
									((UnsafeNativeMethods.EventData*)length + 4 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer4;
									((UnsafeNativeMethods.EventData*)length + 4 * sizeof(UnsafeNativeMethods.EventData)).Size = (value5.Length + 1) * 2;
									((UnsafeNativeMethods.EventData*)length + 5 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)offsetToStringData5;
									((UnsafeNativeMethods.EventData*)length + 5 * sizeof(UnsafeNativeMethods.EventData)).Size = (value6.Length + 1) * 2;
									bool flag = base.WriteEvent(ref eventDescriptor, eventTraceActivity, 6, (IntPtr)length);
									return flag;
								}
							}
						}
					}
				}
			}
		}
示例#29
0
        internal unsafe bool WriteEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, long value1, long value2, long value3)
        {
            const int argumentCount = 3;
            bool status = true;

            {
                byte* eventData = stackalloc byte[sizeof(UnsafeNativeMethods.EventData) * argumentCount];
                UnsafeNativeMethods.EventData* eventDataPtr = (UnsafeNativeMethods.EventData*)eventData;

                eventDataPtr[0].DataPointer = (UInt64)(&value1);
                eventDataPtr[0].Size = (uint)(sizeof(long));

                eventDataPtr[1].DataPointer = (UInt64)(&value2);
                eventDataPtr[1].Size = (uint)(sizeof(long));

                eventDataPtr[2].DataPointer = (UInt64)(&value3);
                eventDataPtr[2].Size = (uint)(sizeof(long));

                status = WriteEvent(ref eventDescriptor, eventTraceActivity, argumentCount, (IntPtr)(eventData));
            }

            return status;
        }
        protected bool WriteTransferEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, Guid relatedActivityId, int dataCount, IntPtr data)
        {
            // ActivityId is required when writing transfer event
            if (eventTraceActivity == null)
            {
                throw Fx.Exception.ArgumentNull("eventTraceActivity");
            }

            uint status = 0;
            unsafe
            {
                status = UnsafeNativeMethods.EventWriteTransfer(this.traceRegistrationHandle,
                                                ref eventDescriptor,
                                                ref eventTraceActivity.ActivityId,
                                                ref relatedActivityId,
                                                (uint)dataCount,
                                                (UnsafeNativeMethods.EventData*)data);
            }

            if (status != 0)
            {
                SetLastError((int)status);
                return false;
            }
            return true;
        }
 public bool Equals(EventDescriptor other)
 {
     if ((m_id != other.m_id) ||
         (m_version != other.m_version) ||
         (m_channel != other.m_channel) ||
         (m_level != other.m_level) ||
         (m_opcode != other.m_opcode) ||
         (m_task != other.m_task) ||
         (m_keywords != other.m_keywords))
     {
         return false;
     }
     return true;
 }
        public void WriteTraceSource(ref EventDescriptor eventDescriptor, string description, TracePayload payload)
        {
            if (this.TracingEnabled)
            {
                XPathNavigator navigator = null;
                try
                {
                    string msdnTraceCode;
                    int legacyEventId;
                    EtwDiagnosticTrace.GenerateLegacyTraceCode(ref eventDescriptor, out msdnTraceCode, out legacyEventId);

                    string traceString = BuildTrace(ref eventDescriptor, description, payload, msdnTraceCode);
                    XmlDocument traceDocument = new XmlDocument();
                    traceDocument.LoadXml(traceString);
                    navigator = traceDocument.CreateNavigator();
                    this.TraceSource.TraceData(TraceLevelHelper.GetTraceEventType(eventDescriptor.Level, eventDescriptor.Opcode), legacyEventId, navigator);

                    if (this.CalledShutdown)
                    {
                        this.TraceSource.Flush();
                    }
                }
                catch (Exception exception)
                {
                    if (Fx.IsFatal(exception))
                    {
                        throw;
                    }

                    LogTraceFailure(navigator == null ? string.Empty : navigator.ToString(), exception);
                }
            }
        }
示例#33
0
 public static void UpdateEventDefinitions(EventDescriptor[] descriptors, ushort[] e2EEvents)
 {
 }
        static void GenerateLegacyTraceCode(ref EventDescriptor eventDescriptor, out string msdnTraceCode, out int legacyEventId)
        {
            // To avoid breaking changes between 4.0 and 4.5 we have to use the same values for EventID and TraceCode like in 4.0
            // The mapping between legacy trace code and the new ETW event ids has to be done manually - for example
            // because there was only one event for HandledException in system.diagnostics. For ETW there are multiple events
            // because you have to specify the verbosity level per event in the manifest.

            switch (eventDescriptor.EventId)
            {
                case EventIdsWithMsdnTraceCode.AppDomainUnload:
                    msdnTraceCode = GenerateMsdnTraceCode(DiagnosticTraceSource, TraceCodes.AppDomainUnload);
                    legacyEventId = LegacyTraceEventIds.AppDomainUnload;
                    break;
                case EventIdsWithMsdnTraceCode.HandledExceptionError:
                case EventIdsWithMsdnTraceCode.HandledExceptionWarning:
                case EventIdsWithMsdnTraceCode.HandledExceptionInfo:
                case EventIdsWithMsdnTraceCode.HandledExceptionVerbose:
                    msdnTraceCode = GenerateMsdnTraceCode(DiagnosticTraceSource, TraceCodes.TraceHandledException);
                    legacyEventId = LegacyTraceEventIds.TraceHandledException;
                    break;    
                case EventIdsWithMsdnTraceCode.ThrowingExceptionVerbose:
                case EventIdsWithMsdnTraceCode.ThrowingExceptionWarning:
                    msdnTraceCode = GenerateMsdnTraceCode(DiagnosticTraceSource, TraceCodes.ThrowingException);
                    legacyEventId = LegacyTraceEventIds.ThrowingException;
                    break; 
                case EventIdsWithMsdnTraceCode.UnhandledException:
                    msdnTraceCode = GenerateMsdnTraceCode(DiagnosticTraceSource, TraceCodes.UnhandledException);
                    legacyEventId = LegacyTraceEventIds.UnhandledException;
                    break; 
                default:
                    msdnTraceCode = eventDescriptor.EventId.ToString(CultureInfo.InvariantCulture);
                    legacyEventId = eventDescriptor.EventId;
                    break;
            }
        }
示例#35
0
 /// <summary>
 /// Creates the event descriptors array
 /// </summary>
 static void CreateEventDescriptors()
 {
     System.Runtime.Diagnostics.EventDescriptor[] descriptors = new System.Runtime.Diagnostics.EventDescriptor[] {
             new System.Runtime.Diagnostics.EventDescriptor(62326, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Informational, (byte)TraceEventOpcode.Info, 0x9de, 0x1000000000000080)};
     ushort[] e2eEvents = new ushort[0];
     FxTrace.UpdateEventDefinitions(descriptors, e2eEvents);
     eventDescriptors = descriptors;
 }
        public bool IsEtwEventEnabled(ref EventDescriptor eventDescriptor, bool fullCheck)
        {
            // A full check queries ETW via a p/invoke call to see if the event is really enabled.
            // Checking against the level and keywords passed in the ETW callback can provide false positives,
            // but never a false negative.
            // The only code which specifies false is two generated classes, System.Runtime.TraceCore and 
            // System.Activities.EtwTrackingParticipantTrackRecords, and the method EtwDiagnosticTrace.TraceTransfer().
            // FxTrace uses IsEtwEventEnabled without the boolean, which then calls this method specifying true.
            if (fullCheck)
            {
                return (this.EtwTracingEnabled && this.etwProvider.IsEventEnabled(ref eventDescriptor));
            }

            return (this.EtwTracingEnabled && this.etwProvider.IsEnabled(eventDescriptor.Level, eventDescriptor.Keywords));
        }
        public bool WriteEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, string data)
        {
            uint status = 0;
            //check all strings for null
            data = (data ?? string.Empty);

            if (IsEnabled(eventDescriptor.Level, eventDescriptor.Keywords))
            {
                if (data.Length > traceEventMaximumStringSize)
                {
                    errorCode = WriteEventErrorCode.EventTooBig;
                    return false;
                }

                if (eventTraceActivity != null)
                {
                    SetActivityId(ref eventTraceActivity.ActivityId);
                }

                UnsafeNativeMethods.EventData userData;

                userData.Size = (uint)((data.Length + 1) * 2);
                userData.Reserved = 0;

                unsafe
                {
                    fixed (char* pdata = data)
                    {
                        userData.DataPointer = (ulong)pdata;
                        status = UnsafeNativeMethods.EventWrite(this.traceRegistrationHandle, ref eventDescriptor, 1, &userData);
                    }
                }
            }

            if (status != 0)
            {
                SetLastError((int)status);
                return false;
            }
            return true;
        }
        public bool WriteTransferEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, Guid relatedActivityId, params object[] eventPayload)
        {
            // ActivityId is required when writing transfer event
            if (eventTraceActivity == null)
            {
                Fx.Assert(false, "eventTraceActivity should not be null for WriteTransferEvent");
                eventTraceActivity = EventTraceActivity.Empty;
            }

            uint status = 0;

            if (IsEnabled(eventDescriptor.Level, eventDescriptor.Keywords))
            {
                unsafe
                {
                    if ((eventPayload != null) && (eventPayload.Length != 0))
                    {
                        int argCount = eventPayload.Length;
                        if (argCount > etwMaxNumberArguments)
                        {
                            //
                            //too many arguments to log
                            //
                            throw Fx.Exception.AsError(new ArgumentOutOfRangeException("eventPayload",
                                                                                       InternalSR.EtwMaxNumberArgumentsExceeded(etwMaxNumberArguments)));
                        }

                        uint     totalEventSize = 0;
                        int      index;
                        int      stringIndex    = 0;
                        int[]    stringPosition = new int[etwAPIMaxStringCount];                                         //used to keep the position of strings in the eventPayload parameter
                        string[] dataString     = new string[etwAPIMaxStringCount];                                      // string arrays from the eventPayload parameter
                        UnsafeNativeMethods.EventData *userData    = stackalloc UnsafeNativeMethods.EventData[argCount]; // allocation for the data descriptors
                        UnsafeNativeMethods.EventData *userDataPtr = (UnsafeNativeMethods.EventData *)userData;
                        byte *dataBuffer    = stackalloc byte[basicTypeAllocationBufferSize * argCount];                 // 16 byte for unboxing non-string argument
                        byte *currentBuffer = dataBuffer;

                        //
                        // The loop below goes through all the arguments and fills in the data
                        // descriptors. For strings save the location in the dataString array.
                        // Caculates the total size of the event by adding the data descriptor
                        // size value set in EncodeObjec method.
                        //
                        for (index = 0; index < eventPayload.Length; index++)
                        {
                            if (eventPayload[index] != null)
                            {
                                string isString;
                                isString        = EncodeObject(ref eventPayload[index], userDataPtr, currentBuffer);
                                currentBuffer  += basicTypeAllocationBufferSize;
                                totalEventSize += userDataPtr->Size;
                                userDataPtr++;
                                if (isString != null)
                                {
                                    if (stringIndex < etwAPIMaxStringCount)
                                    {
                                        dataString[stringIndex]     = isString;
                                        stringPosition[stringIndex] = index;
                                        stringIndex++;
                                    }
                                    else
                                    {
                                        throw Fx.Exception.AsError(new ArgumentOutOfRangeException("eventPayload",
                                                                                                   InternalSR.EtwAPIMaxStringCountExceeded(etwAPIMaxStringCount)));
                                    }
                                }
                            }
                        }

                        if (totalEventSize > traceEventMaximumSize)
                        {
                            errorCode = WriteEventErrorCode.EventTooBig;
                            return(false);
                        }

                        fixed(char *v0 = dataString[0], v1 = dataString[1], v2 = dataString[2], v3 = dataString[3],
                              v4       = dataString[4], v5 = dataString[5], v6 = dataString[6], v7 = dataString[7])
                        {
                            userDataPtr = (UnsafeNativeMethods.EventData *)userData;
                            if (dataString[0] != null)
                            {
                                userDataPtr[stringPosition[0]].DataPointer = (ulong)v0;
                            }
                            if (dataString[1] != null)
                            {
                                userDataPtr[stringPosition[1]].DataPointer = (ulong)v1;
                            }
                            if (dataString[2] != null)
                            {
                                userDataPtr[stringPosition[2]].DataPointer = (ulong)v2;
                            }
                            if (dataString[3] != null)
                            {
                                userDataPtr[stringPosition[3]].DataPointer = (ulong)v3;
                            }
                            if (dataString[4] != null)
                            {
                                userDataPtr[stringPosition[4]].DataPointer = (ulong)v4;
                            }
                            if (dataString[5] != null)
                            {
                                userDataPtr[stringPosition[5]].DataPointer = (ulong)v5;
                            }
                            if (dataString[6] != null)
                            {
                                userDataPtr[stringPosition[6]].DataPointer = (ulong)v6;
                            }
                            if (dataString[7] != null)
                            {
                                userDataPtr[stringPosition[7]].DataPointer = (ulong)v7;
                            }

                            status = UnsafeNativeMethods.EventWriteTransfer(this.traceRegistrationHandle, ref eventDescriptor, ref eventTraceActivity.ActivityId, ref relatedActivityId, (uint)argCount, userData);
                        }
                    }
                    else
                    {
                        status = UnsafeNativeMethods.EventWriteTransfer(this.traceRegistrationHandle, ref eventDescriptor, ref eventTraceActivity.ActivityId, ref relatedActivityId, 0, null);
                    }
                }
            }

            if (status != 0)
            {
                SetLastError((int)status);
                return(false);
            }

            return(true);
        }
        public bool WriteTransferEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, Guid relatedActivityId, params object[] eventPayload)
        {
            // ActivityId is required when writing transfer event
            if (eventTraceActivity == null)
            {
                Fx.Assert(false, "eventTraceActivity should not be null for WriteTransferEvent");
                eventTraceActivity = EventTraceActivity.Empty;
            }

            uint status = 0;
            if (IsEnabled(eventDescriptor.Level, eventDescriptor.Keywords))
            {
                unsafe
                {
                    if ((eventPayload != null) && (eventPayload.Length != 0))
                    {
                        int argCount = eventPayload.Length;
                        if (argCount > etwMaxNumberArguments)
                        {
                            //
                            //too many arguments to log
                            //
                            throw Fx.Exception.AsError(new ArgumentOutOfRangeException("eventPayload",
                                InternalSR.EtwMaxNumberArgumentsExceeded(etwMaxNumberArguments)));
                        }

                        uint totalEventSize = 0;
                        int index;
                        int stringIndex = 0;
                        int[] stringPosition = new int[etwAPIMaxStringCount]; //used to keep the position of strings in the eventPayload parameter
                        string[] dataString = new string[etwAPIMaxStringCount]; // string arrays from the eventPayload parameter
                        UnsafeNativeMethods.EventData* userData = stackalloc UnsafeNativeMethods.EventData[argCount]; // allocation for the data descriptors
                        UnsafeNativeMethods.EventData* userDataPtr = (UnsafeNativeMethods.EventData*)userData;
                        byte* dataBuffer = stackalloc byte[basicTypeAllocationBufferSize * argCount]; // 16 byte for unboxing non-string argument
                        byte* currentBuffer = dataBuffer;

                        //
                        // The loop below goes through all the arguments and fills in the data 
                        // descriptors. For strings save the location in the dataString array.
                        // Caculates the total size of the event by adding the data descriptor
                        // size value set in EncodeObjec method.
                        //
                        for (index = 0; index < eventPayload.Length; index++)
                        {
                            if (eventPayload[index] != null)
                            {
                                string isString;
                                isString = EncodeObject(ref eventPayload[index], userDataPtr, currentBuffer);
                                currentBuffer += basicTypeAllocationBufferSize;
                                totalEventSize += userDataPtr->Size;
                                userDataPtr++;
                                if (isString != null)
                                {
                                    if (stringIndex < etwAPIMaxStringCount)
                                    {
                                        dataString[stringIndex] = isString;
                                        stringPosition[stringIndex] = index;
                                        stringIndex++;
                                    }
                                    else
                                    {                                        
                                        throw Fx.Exception.AsError(new ArgumentOutOfRangeException("eventPayload",
                                            InternalSR.EtwAPIMaxStringCountExceeded(etwAPIMaxStringCount)));  
                                    }
                                }
                            }
                        }

                        if (totalEventSize > traceEventMaximumSize)
                        {
                            errorCode = WriteEventErrorCode.EventTooBig;
                            return false;
                        }

                        fixed (char* v0 = dataString[0], v1 = dataString[1], v2 = dataString[2], v3 = dataString[3],
                                v4 = dataString[4], v5 = dataString[5], v6 = dataString[6], v7 = dataString[7])
                        {
                            userDataPtr = (UnsafeNativeMethods.EventData*)userData;
                            if (dataString[0] != null)
                            {
                                userDataPtr[stringPosition[0]].DataPointer = (ulong)v0;
                            }
                            if (dataString[1] != null)
                            {
                                userDataPtr[stringPosition[1]].DataPointer = (ulong)v1;
                            }
                            if (dataString[2] != null)
                            {
                                userDataPtr[stringPosition[2]].DataPointer = (ulong)v2;
                            }
                            if (dataString[3] != null)
                            {
                                userDataPtr[stringPosition[3]].DataPointer = (ulong)v3;
                            }
                            if (dataString[4] != null)
                            {
                                userDataPtr[stringPosition[4]].DataPointer = (ulong)v4;
                            }
                            if (dataString[5] != null)
                            {
                                userDataPtr[stringPosition[5]].DataPointer = (ulong)v5;
                            }
                            if (dataString[6] != null)
                            {
                                userDataPtr[stringPosition[6]].DataPointer = (ulong)v6;
                            }
                            if (dataString[7] != null)
                            {
                                userDataPtr[stringPosition[7]].DataPointer = (ulong)v7;
                            }

                            status = UnsafeNativeMethods.EventWriteTransfer(this.traceRegistrationHandle, ref eventDescriptor, ref eventTraceActivity.ActivityId, ref relatedActivityId, (uint)argCount, userData);
                        }
                    }
                    else
                    {
                        status = UnsafeNativeMethods.EventWriteTransfer(this.traceRegistrationHandle, ref eventDescriptor, ref eventTraceActivity.ActivityId, ref relatedActivityId, 0, null);
                    }
                }
            }

            if (status != 0)
            {
                SetLastError((int)status);
                return false;
            }

            return true;
        }
 public bool IsEtwEventEnabled(ref EventDescriptor eventDescriptor)
 {
     return(this.EtwTracingEnabled && this.etwProvider.IsEnabled(eventDescriptor.Level, eventDescriptor.Keywords));
 }
 public void Event(ref EventDescriptor eventDescriptor, string description)
 {
     if (this.TracingEnabled)
     {
         TracePayload tracePayload = this.GetSerializedPayload(null, null, null);
         this.WriteTraceSource(ref eventDescriptor, description, tracePayload);
     }
 }
示例#42
0
		internal unsafe bool WriteEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, string value1, string value2, string value3, string value4, string value5, string value6, string value7, string value8, string value9)
		{
			string str = value1;
			string empty = str;
			if (str == null)
			{
				empty = string.Empty;
			}
			value1 = empty;
			string str1 = value2;
			string empty1 = str1;
			if (str1 == null)
			{
				empty1 = string.Empty;
			}
			value2 = empty1;
			string str2 = value3;
			string empty2 = str2;
			if (str2 == null)
			{
				empty2 = string.Empty;
			}
			value3 = empty2;
			string str3 = value4;
			string empty3 = str3;
			if (str3 == null)
			{
				empty3 = string.Empty;
			}
			value4 = empty3;
			string str4 = value5;
			string empty4 = str4;
			if (str4 == null)
			{
				empty4 = string.Empty;
			}
			value5 = empty4;
			string str5 = value6;
			string empty5 = str5;
			if (str5 == null)
			{
				empty5 = string.Empty;
			}
			value6 = empty5;
			string str6 = value7;
			string empty6 = str6;
			if (str6 == null)
			{
				empty6 = string.Empty;
			}
			value7 = empty6;
			string str7 = value8;
			string empty7 = str7;
			if (str7 == null)
			{
				empty7 = string.Empty;
			}
			value8 = empty7;
			string str8 = value9;
			string empty8 = str8;
			if (str8 == null)
			{
				empty8 = string.Empty;
			}
			value9 = empty8;
			fixed (string str9 = value1)
			{
				string* strPointers = &str9;
				char* offsetToStringData = (char*)(&str9);
				if (&str9 != null)
				{
					offsetToStringData = (char*)(strPointers + RuntimeHelpers.OffsetToStringData);
				}
				char* chrPointer = offsetToStringData;
				fixed (string str10 = value2)
				{
					string* strPointers1 = &str10;
					char* offsetToStringData1 = (char*)(&str10);
					if (&str10 != null)
					{
						offsetToStringData1 = (char*)(strPointers1 + RuntimeHelpers.OffsetToStringData);
					}
					char* chrPointer1 = offsetToStringData1;
					fixed (string str11 = value3)
					{
						string* strPointers2 = &str11;
						char* offsetToStringData2 = (char*)(&str11);
						if (&str11 != null)
						{
							offsetToStringData2 = (char*)(strPointers2 + RuntimeHelpers.OffsetToStringData);
						}
						char* chrPointer2 = offsetToStringData2;
						fixed (string str12 = value4)
						{
							string* strPointers3 = &str12;
							char* offsetToStringData3 = (char*)(&str12);
							if (&str12 != null)
							{
								offsetToStringData3 = (char*)(strPointers3 + RuntimeHelpers.OffsetToStringData);
							}
							char* chrPointer3 = offsetToStringData3;
							fixed (string str13 = value5)
							{
								string* strPointers4 = &str13;
								char* offsetToStringData4 = (char*)(&str13);
								if (&str13 != null)
								{
									offsetToStringData4 = (char*)(strPointers4 + RuntimeHelpers.OffsetToStringData);
								}
								char* chrPointer4 = offsetToStringData4;
								fixed (string str14 = value6)
								{
									string* strPointers5 = &str14;
									char* offsetToStringData5 = (char*)(&str14);
									if (&str14 != null)
									{
										offsetToStringData5 = (char*)(strPointers5 + RuntimeHelpers.OffsetToStringData);
									}
									char* chrPointer5 = offsetToStringData5;
									fixed (string str15 = value7)
									{
										string* strPointers6 = &str15;
										char* offsetToStringData6 = (char*)(&str15);
										if (&str15 != null)
										{
											offsetToStringData6 = (char*)(strPointers6 + RuntimeHelpers.OffsetToStringData);
										}
										char* chrPointer6 = offsetToStringData6;
										fixed (string str16 = value8)
										{
											string* strPointers7 = &str16;
											char* offsetToStringData7 = (char*)(&str16);
											if (&str16 != null)
											{
												offsetToStringData7 = (char*)(strPointers7 + RuntimeHelpers.OffsetToStringData);
											}
											char* chrPointer7 = offsetToStringData7;
											fixed (string str17 = value9)
											{
												string* strPointers8 = &str17;
												char* offsetToStringData8 = (char*)(&str17);
												if (&str17 != null)
												{
													offsetToStringData8 = (char*)(strPointers8 + RuntimeHelpers.OffsetToStringData);
												}
												/*
												byte* length = (byte*)sizeof(UnsafeNativeMethods.EventData) * 9;
												(*((UnsafeNativeMethods.EventData*)length)).DataPointer = (ulong)chrPointer;
												(*((UnsafeNativeMethods.EventData*)length)).Size = (value1.Length + 1) * 2;
												((UnsafeNativeMethods.EventData*)length + sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer1;
												((UnsafeNativeMethods.EventData*)length + sizeof(UnsafeNativeMethods.EventData)).Size = (value2.Length + 1) * 2;
												((UnsafeNativeMethods.EventData*)length + 2 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer2;
												((UnsafeNativeMethods.EventData*)length + 2 * sizeof(UnsafeNativeMethods.EventData)).Size = (value3.Length + 1) * 2;
												((UnsafeNativeMethods.EventData*)length + 3 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer3;
												((UnsafeNativeMethods.EventData*)length + 3 * sizeof(UnsafeNativeMethods.EventData)).Size = (value4.Length + 1) * 2;
												((UnsafeNativeMethods.EventData*)length + 4 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer4;
												((UnsafeNativeMethods.EventData*)length + 4 * sizeof(UnsafeNativeMethods.EventData)).Size = (value5.Length + 1) * 2;
												((UnsafeNativeMethods.EventData*)length + 5 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer5;
												((UnsafeNativeMethods.EventData*)length + 5 * sizeof(UnsafeNativeMethods.EventData)).Size = (value6.Length + 1) * 2;
												((UnsafeNativeMethods.EventData*)length + 6 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer6;
												((UnsafeNativeMethods.EventData*)length + 6 * sizeof(UnsafeNativeMethods.EventData)).Size = (value7.Length + 1) * 2;
												((UnsafeNativeMethods.EventData*)length + 7 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)chrPointer7;
												((UnsafeNativeMethods.EventData*)length + 7 * sizeof(UnsafeNativeMethods.EventData)).Size = (value8.Length + 1) * 2;
												((UnsafeNativeMethods.EventData*)length + 8 * sizeof(UnsafeNativeMethods.EventData)).DataPointer = (ulong)offsetToStringData8;
												((UnsafeNativeMethods.EventData*)length + 8 * sizeof(UnsafeNativeMethods.EventData)).Size = (value9.Length + 1) * 2;
												*/
												bool flag = base.WriteEvent(ref eventDescriptor, eventTraceActivity, 9, IntPtr.Zero); //TODO: REVIEW:  (IntPtr)length);
												return flag;
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
        static string BuildTrace(ref EventDescriptor eventDescriptor, string description, TracePayload payload, string msdnTraceCode)
        {
            StringBuilder sb = StringBuilderPool.Take();
            try
            {
                using (StringWriter stringWriter = new StringWriter(sb, CultureInfo.CurrentCulture))
                {
                    using (XmlTextWriter writer = new XmlTextWriter(stringWriter))
                    {
                        writer.WriteStartElement(DiagnosticStrings.TraceRecordTag);
                        writer.WriteAttributeString(DiagnosticStrings.NamespaceTag, EtwDiagnosticTrace.TraceRecordVersion);
                        writer.WriteAttributeString(DiagnosticStrings.SeverityTag,
                            TraceLevelHelper.LookupSeverity((TraceEventLevel)eventDescriptor.Level, (TraceEventOpcode)eventDescriptor.Opcode));
                        writer.WriteAttributeString(DiagnosticStrings.ChannelTag, EtwDiagnosticTrace.LookupChannel((TraceChannel)eventDescriptor.Channel));

                        writer.WriteElementString(DiagnosticStrings.TraceCodeTag, msdnTraceCode);
                        writer.WriteElementString(DiagnosticStrings.DescriptionTag, description);
                        writer.WriteElementString(DiagnosticStrings.AppDomain, payload.AppDomainFriendlyName);

                        if (!string.IsNullOrEmpty(payload.EventSource))
                        {
                            writer.WriteElementString(DiagnosticStrings.SourceTag, payload.EventSource);
                        }

                        if (!string.IsNullOrEmpty(payload.ExtendedData))
                        {
                            writer.WriteRaw(payload.ExtendedData);
                        }

                        if (!string.IsNullOrEmpty(payload.SerializedException))
                        {
                            writer.WriteRaw(payload.SerializedException);
                        }

                        writer.WriteEndElement();
                        writer.Flush();
                        stringWriter.Flush();

                        return sb.ToString();
                    }
                }
            }
            finally
            {
                StringBuilderPool.Return(sb);
            }
        }
示例#44
0
 static void CreateEventDescriptors()
 {
     System.Runtime.Diagnostics.EventDescriptor[] descriptors = new System.Runtime.Diagnostics.EventDescriptor[] {
             new System.Runtime.Diagnostics.EventDescriptor(5406, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0xa35, 0x1000000000000010),
             new System.Runtime.Diagnostics.EventDescriptor(5405, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0xa35, 0x1000000000000010),
             new System.Runtime.Diagnostics.EventDescriptor(5404, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Error, (byte)TraceEventOpcode.Info, 0xa34, 0x1000000000000010),
             new System.Runtime.Diagnostics.EventDescriptor(5402, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0xa34, 0x1000000000000010),
             new System.Runtime.Diagnostics.EventDescriptor(5403, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Info, 0xa34, 0x1000000000000010)};
     // The hashcodes calculated from PTCop for TD.CreateEventDescriptors are unstable when just declaring
     // a local field of ushort[] if the array is non-empty and contains more than 2 entries, because
     // the c#-compiler is using some private types for optimization. The type name follows the following pattern:
     // <PrivateImplementationDetails>{6BAE93FD-290B-4DE0-BCEE-366B30800FDF} (where the GUID is changing with every build)
     // To scope the change to unblock PTCop as much as possible we wrap the list of End2EndEvents in a List<ushort>
     System.Collections.Generic.List<ushort> e2eEvents = new System.Collections.Generic.List<ushort>(5);
     e2eEvents.Add(5402);
     e2eEvents.Add(5403);
     e2eEvents.Add(5404);
     e2eEvents.Add(5405);
     e2eEvents.Add(5406);
     FxTrace.UpdateEventDefinitions(descriptors, e2eEvents.ToArray());
     eventDescriptors = descriptors;
 }
 public bool IsEtwEventEnabled(ref EventDescriptor eventDescriptor)
 {
     return IsEtwEventEnabled(ref eventDescriptor, true);
 }
示例#46
0
 public void WriteTraceSource(ref EventDescriptor eventDescriptor, string description, TracePayload payload)
 {
 }
示例#47
0
 static void CreateEventDescriptors()
 {
     System.Runtime.Diagnostics.EventDescriptor[] descriptors = new System.Runtime.Diagnostics.EventDescriptor[] {
             new System.Runtime.Diagnostics.EventDescriptor(4800, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Warning, (byte)TraceEventOpcode.Info, 0x0, 0x1000000000000000),
             new System.Runtime.Diagnostics.EventDescriptor(4801, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0x9fb, 0x1000000000001000),
             new System.Runtime.Diagnostics.EventDescriptor(4802, 0, (byte)TraceChannel.Debug, (byte)TraceEventLevel.Verbose, (byte)TraceEventOpcode.Start, 0x9fb, 0x1000000000001000)};
     ushort[] e2eEvents = new ushort[] {
             4800,
             4802};
     FxTrace.UpdateEventDefinitions(descriptors, e2eEvents);
     eventDescriptors = descriptors;
 }
        public bool WriteEvent(ref EventDescriptor eventDescriptor, EventTraceActivity eventTraceActivity, params object[] eventPayload)
        {
            uint status = 0;

            if (IsEnabled(eventDescriptor.Level, eventDescriptor.Keywords))
            {
                int argCount = 0;

                if (eventTraceActivity != null)
                {
                    SetActivityId(ref eventTraceActivity.ActivityId);
                }

                unsafe
                {
                    if ((eventPayload == null) ||
                        (eventPayload.Length == 0) ||
                        (eventPayload.Length == 1))
                    {
                        string dataString = null;
                        UnsafeNativeMethods.EventData userData;

                        byte *dataBuffer = stackalloc byte[basicTypeAllocationBufferSize]; // Assume a max of 16 chars for non-string argument

                        userData.Size = 0;
                        if ((eventPayload != null) && (eventPayload.Length != 0))
                        {
                            //
                            // Figure out the type and fill the data descriptor
                            //
                            dataString = EncodeObject(ref eventPayload[0], &userData, dataBuffer);
                            argCount   = 1;
                        }

                        if (userData.Size > traceEventMaximumSize)
                        {
                            //
                            // Maximum size of the event payload plus header is 64k
                            //
                            errorCode = WriteEventErrorCode.EventTooBig;
                            return(false);
                        }

                        if (dataString != null)
                        {
                            fixed(char *pdata = dataString)
                            {
                                userData.DataPointer = (ulong)pdata;
                                status = UnsafeNativeMethods.EventWrite(this.traceRegistrationHandle, ref eventDescriptor, (uint)argCount, &userData);
                            }
                        }
                        else
                        {
                            if (argCount == 0)
                            {
                                status = UnsafeNativeMethods.EventWrite(this.traceRegistrationHandle, ref eventDescriptor, 0, null);
                            }
                            else
                            {
                                status = UnsafeNativeMethods.EventWrite(this.traceRegistrationHandle, ref eventDescriptor, (uint)argCount, &userData);
                            }
                        }
                    }
                    else
                    {
                        argCount = eventPayload.Length;

                        if (argCount > etwMaxNumberArguments)
                        {
                            //
                            //too many arguments to log
                            //
                            throw Fx.Exception.AsError(new ArgumentOutOfRangeException("eventPayload",
                                                                                       InternalSR.EtwMaxNumberArgumentsExceeded(etwMaxNumberArguments)));
                        }

                        uint     totalEventSize = 0;
                        int      index;
                        int      stringIndex    = 0;
                        int[]    stringPosition = new int[etwAPIMaxStringCount];
                        string[] dataString     = new string[etwAPIMaxStringCount];
                        UnsafeNativeMethods.EventData *userData    = stackalloc UnsafeNativeMethods.EventData[argCount];
                        UnsafeNativeMethods.EventData *userDataPtr = (UnsafeNativeMethods.EventData *)userData;
                        byte *dataBuffer    = stackalloc byte[basicTypeAllocationBufferSize * argCount]; // Assume 16 chars for non-string argument
                        byte *currentBuffer = dataBuffer;

                        //
                        // The loop below goes through all the arguments and fills in the data
                        // descriptors. For strings save the location in the dataString array.
                        // Caculates the total size of the event by adding the data descriptor
                        // size value set in EncodeObjec method.
                        //
                        for (index = 0; index < eventPayload.Length; index++)
                        {
                            if (eventPayload[index] != null)
                            {
                                string isString;
                                isString        = EncodeObject(ref eventPayload[index], userDataPtr, currentBuffer);
                                currentBuffer  += basicTypeAllocationBufferSize;
                                totalEventSize += userDataPtr->Size;
                                userDataPtr++;
                                if (isString != null)
                                {
                                    if (stringIndex < etwAPIMaxStringCount)
                                    {
                                        dataString[stringIndex]     = isString;
                                        stringPosition[stringIndex] = index;
                                        stringIndex++;
                                    }
                                    else
                                    {
                                        throw Fx.Exception.AsError(new ArgumentOutOfRangeException("eventPayload",
                                                                                                   InternalSR.EtwAPIMaxStringCountExceeded(etwAPIMaxStringCount)));
                                    }
                                }
                            }
                        }

                        if (totalEventSize > traceEventMaximumSize)
                        {
                            errorCode = WriteEventErrorCode.EventTooBig;
                            return(false);
                        }

                        //
                        // now fix any string arguments and set the pointer on the data descriptor
                        //
                        fixed(char *v0 = dataString[0], v1 = dataString[1], v2 = dataString[2], v3 = dataString[3],
                              v4       = dataString[4], v5 = dataString[5], v6 = dataString[6], v7 = dataString[7])
                        {
                            userDataPtr = (UnsafeNativeMethods.EventData *)userData;
                            if (dataString[0] != null)
                            {
                                userDataPtr[stringPosition[0]].DataPointer = (ulong)v0;
                            }
                            if (dataString[1] != null)
                            {
                                userDataPtr[stringPosition[1]].DataPointer = (ulong)v1;
                            }
                            if (dataString[2] != null)
                            {
                                userDataPtr[stringPosition[2]].DataPointer = (ulong)v2;
                            }
                            if (dataString[3] != null)
                            {
                                userDataPtr[stringPosition[3]].DataPointer = (ulong)v3;
                            }
                            if (dataString[4] != null)
                            {
                                userDataPtr[stringPosition[4]].DataPointer = (ulong)v4;
                            }
                            if (dataString[5] != null)
                            {
                                userDataPtr[stringPosition[5]].DataPointer = (ulong)v5;
                            }
                            if (dataString[6] != null)
                            {
                                userDataPtr[stringPosition[6]].DataPointer = (ulong)v6;
                            }
                            if (dataString[7] != null)
                            {
                                userDataPtr[stringPosition[7]].DataPointer = (ulong)v7;
                            }

                            status = UnsafeNativeMethods.EventWrite(this.traceRegistrationHandle, ref eventDescriptor, (uint)argCount, userData);
                        }
                    }
                }
            }

            if (status != 0)
            {
                SetLastError((int)status);
                return(false);
            }

            return(true);
        }