示例#1
0
        public unsafe static int PackInfo(byte[] destinationBuffer, ref int pos, int maxSize)
        {
            BipBuffer buffer = DiagnosticContext.GetBuffer();

            if (maxSize < DiagnosticContext.ContextBuffer.StructSize)
            {
                return(0);
            }
            while (maxSize < DiagnosticContext.Size)
            {
                DiagnosticContext.FlushHeadRecord(buffer);
            }

            fixed(byte *ptr = &destinationBuffer[pos])
            {
                DiagnosticContext.ContextBuffer *ptr2 = (DiagnosticContext.ContextBuffer *)ptr;
                ptr2->Format    = byte.MaxValue;
                ptr2->ThreadID  = (uint)Environment.CurrentManagedThreadId;
                ptr2->RequestID = 0U;
                ptr2->Flags     = (byte)(2 | (DiagnosticContext.overFlow ? 1 : 0));
                ptr2->Length    = (uint)buffer.AllocatedSize;
            }

            pos     += DiagnosticContext.ContextBuffer.StructSize;
            maxSize -= DiagnosticContext.ContextBuffer.StructSize;
            int allocatedSize = buffer.AllocatedSize;

            buffer.Extract(destinationBuffer, pos, allocatedSize);
            pos += allocatedSize;
            return(allocatedSize + DiagnosticContext.ContextBuffer.StructSize);
        }
示例#2
0
        public static void ExtractInfo(int maxSize, out byte flags, out byte[] info)
        {
            BipBuffer buffer = DiagnosticContext.GetBuffer();

            DiagnosticContext.Shared.ExtractInfo(buffer, maxSize, out info);
            flags = (byte)(2 | (DiagnosticContext.overFlow ? 1 : 0));
        }
示例#3
0
        public unsafe static void TraceDwordAndString(LID lid, uint info, string str)
        {
            DiagnosticContext.TraceTestLocation(lid.Value);
            if (DiagnosticContext.onLIDCallback != null)
            {
                DiagnosticContext.onLIDCallback(lid);
            }
            DiagnosticContext.GetBuffer();
            int  bytes = DiagnosticContext.asciiEncoding.GetBytes(str, 0, Math.Min(103, str.Length), DiagnosticContext.stringBuffer, 0);
            int  num   = Math.Min(bytes, 103) + 1;
            int  num2  = 1 + (num + 7) / 8;
            uint num3  = (uint)((uint)num2 << 28);

            num3 |= 5242880U;
            byte[] array;
            int    num4;

            DiagnosticContext.GetBufferPointer(DiagnosticContext.SizeOfRecordFromSignature(num3), out array, out num4);
            fixed(byte *ptr = &array[num4])
            {
                DiagnosticContext.LocationAndDwordAndStringRecord *ptr2 = (DiagnosticContext.LocationAndDwordAndStringRecord *)ptr;
                ptr2->Lid  = DiagnosticContext.AdjustLID(lid.Value, num3);
                ptr2->Info = info;
            }

            Array.Copy(DiagnosticContext.stringBuffer, 0, array, num4 + DiagnosticContext.LocationAndDwordAndStringRecord.StructSize, num - 1);
            array[num4 + DiagnosticContext.LocationAndDwordAndStringRecord.StructSize + num - 1] = 0;
        }
示例#4
0
        public static byte[] PackInfo()
        {
            BipBuffer buffer = DiagnosticContext.GetBuffer();

            byte[] array = new byte[DiagnosticContext.ContextBuffer.StructSize + buffer.AllocatedSize];
            int    num   = 0;

            DiagnosticContext.PackInfo(array, ref num, array.Length);
            return(array);
        }
示例#5
0
        public static void Reset()
        {
            if (DiagnosticContext.DiagnosticContextTest != null)
            {
                DiagnosticContext.DiagnosticContextTest.Reset();
            }
            BipBuffer buffer = DiagnosticContext.GetBuffer();

            DiagnosticContext.Shared.Reset(buffer);
            DiagnosticContext.overFlow = false;
        }
示例#6
0
        private static void GetBufferPointer(int size, out byte[] buffer, out int index)
        {
            BipBuffer buffer2 = DiagnosticContext.GetBuffer();

            DiagnosticContext.Shared.GetBufferPointer(buffer2, size, out buffer, out index);
        }