예제 #1
0
		public void readLogFile()
		{
			log = new ReadNewLog(logFileName);
			logResult = GetLogResult();
			log.ReadFile(logFileStartOffset, logFileEndOffset, logResult);
			
		}
예제 #2
0
        internal static void CommentReport(string logFileName)
        {
            // first read the entire file
            ReadNewLog log = new ReadNewLog(logFileName, false);
            ReadLogResult entireLogResult = GetLogResult(log);
            log.ReadFile(0, long.MaxValue, entireLogResult);

            Console.WriteLine("Comments logged in {0}", logFileName);
            Console.WriteLine("Time (seconds),Comment");
            for (int i = 0; i < log.commentEventList.count; i++)
                Console.WriteLine("{1:f3},{0}", log.commentEventList.eventString[i], log.TickIndexToTime(log.commentEventList.eventTickIndex[i]));
        }
예제 #3
0
        internal static void FinalizerReport(bool criticalFinalizers, string logFileName, string startMarker, string endMarker)
        {
            // first read the entire file
            ReadNewLog log = new ReadNewLog(logFileName, false);
            ReadLogResult entireLogResult = GetLogResult(log);
            log.ReadFile(0, long.MaxValue, entireLogResult);

            // if we were given a start or an end marker, we need to re-read a portion of the file.
            ReadLogResult logResult = entireLogResult;
            if (startMarker != null || endMarker != null)
            {
                int startTickIndex = 0;
                int endTickIndex = entireLogResult.sampleObjectTable.lastTickIndex;

                if (startMarker != null)
                    startTickIndex = FindMarkerTickIndex(startMarker, log);

                if (endMarker != null)
                    endTickIndex = FindMarkerTickIndex(endMarker, log);

                long startPos = log.TickIndexToPos(startTickIndex);
                long endPos = log.TickIndexToPos(endTickIndex);

                // Read the selected portion of the log again
                logResult = new ReadLogResult();
                logResult.liveObjectTable = new LiveObjectTable(log);
                logResult.finalizerHistogram = new Histogram(log);
                logResult.criticalFinalizerHistogram = new Histogram(log);

                log.ReadFile(startPos, endPos, logResult);

                if (startMarker == null)
                    startMarker = CommentRangeForm.startCommentString;
                if (endMarker == null)
                    endMarker = CommentRangeForm.shutdownCommentString;
                Console.WriteLine("{0} summary for {1} Objects between {2} ({3} secs) and {4} ({5} secs)",
                                    criticalFinalizers ? "Critical Finalized" : "Finalized",
                                                    logFileName, 
                                                                startMarker, 
                                                                     log.TickIndexToTime(startTickIndex),
                                                                                   endMarker,
                                                                                        log.TickIndexToTime(endTickIndex));
            }
            else
                Console.WriteLine("{0} summary for {1}",
                                    criticalFinalizers ? "Critical Finalized" : "Finalized",
                                                    logFileName);

            // now we are ready to produce the allocation report from the allocation histogram
            WriteReport(criticalFinalizers ? logResult.criticalFinalizerHistogram : logResult.finalizerHistogram, "");
        }
예제 #4
0
        internal static void HeapDumpReport(string logFileName, string startMarker, string endMarker)
        {
            ReadNewLog log = new ReadNewLog(logFileName, false);
            ReadLogResult entireLogResult = GetLogResult(log);
            log.ReadFile(0, long.MaxValue, entireLogResult);

            Histogram[] heapDumpHistograms = entireLogResult.heapDumpHistograms;
            string[] timeMarkers = new String[heapDumpHistograms.Length];
            if (startMarker != null || endMarker != null)
            {
                int startTickIndex = 0;
                int endTickIndex = entireLogResult.sampleObjectTable.lastTickIndex;

                if (startMarker != null)
                    startTickIndex = FindMarkerTickIndex(startMarker, log);

                if (endMarker != null)
                    endTickIndex = FindMarkerTickIndex(endMarker, log);

                int startIndex = 0;
                int endIndex = 0;
                for (int i = 0; i < log.heapDumpEventList.count; i++)
                {
                    if (log.heapDumpEventList.eventTickIndex[i] < startTickIndex)
                        startIndex = i + 1;
                    if (log.heapDumpEventList.eventTickIndex[i] < endTickIndex)
                        endIndex = i + 1;
                }

                if (endMarker == null)
                {
                    Console.WriteLine("Heap dump for {0} after {1}", logFileName, startMarker);
                    if (startIndex < log.heapDumpEventList.count)
                        endIndex = startIndex + 1;
                    else
                        endIndex = startIndex;
                }
                else
                {
                    Console.WriteLine("Heap dump for {0} between {1} and {2}", logFileName, startMarker, endMarker);
                }
                if (startIndex < endIndex)
                {
                    heapDumpHistograms = new Histogram[endIndex - startIndex];
                    for (int i = startIndex; i < endIndex; i++)
                    {
                        heapDumpHistograms[i - startIndex] = entireLogResult.heapDumpHistograms[i];
                    }
                    timeMarkers = new string[endIndex - startIndex];
                }
                else
                {
                    heapDumpHistograms = new Histogram[0];
                    timeMarkers = new string[0];
                }
            }
            else
            {
                Console.WriteLine("Heap dumps for {0}", logFileName);
            }
            for (int i = 0; i < timeMarkers.Length; i++)
            {
                timeMarkers[i] = string.Format("Heap dump #{0}", i);
            }
            if (heapDumpHistograms.Length > 0)
                WriteReport(heapDumpHistograms, timeMarkers);
            else
                Console.WriteLine("***** No heap dumps found *****");
        }
예제 #5
0
        /// <summary>
        /// Sonal: Function to generate and print Leak Report for the dump file.
        /// </summary>
        /// <param name="logFileName">dump file name</param>
        /// <param name="startMarker">int {0,NumHeapDumps}</param>
        /// <param name="endMarker">int {0,NumHeapDumps}</param>
        internal static void LeakReport(string logFileName, string startMarker, string endMarker)
        {
            if (startMarker == null)
                startMarker = "1";
            if (endMarker == null)
                endMarker = "2";

            int startIndex;
            int endIndex;
            try
            {
                startIndex = int.Parse(startMarker);
                endIndex = int.Parse(endMarker);
            }
            catch
            {
                throw new ArgumentException("Markers have to be positive integral values");
            }
            startIndex--;
            endIndex--;
            if ((startIndex < 0) || (endIndex < 0))
            {
                throw new ArgumentException("Markers can not be negative");
            }
            ReadNewLog log = new ReadNewLog(logFileName, false);
            ReadLogResult entireLogResult = GetLogResult(log);
            log.ReadFile(0, long.MaxValue, entireLogResult, endIndex + 1);
            if (entireLogResult.requestedObjectGraph == null)
            {
                throw new ArgumentException("Invalid EndIndex");
            }

            Histogram[] heapDumpHistograms = entireLogResult.heapDumpHistograms;
            string[] timeMarkers = new String[2];
            if (startIndex < endIndex)
            {
                heapDumpHistograms = new Histogram[endIndex - startIndex + 1];
                for (int i = startIndex; i <= endIndex; i++)
                {
                    heapDumpHistograms[i - startIndex] = entireLogResult.heapDumpHistograms[i];
                }
                timeMarkers = new string[endIndex - startIndex + 1];
            }
            else
            {
                heapDumpHistograms = new Histogram[0];
                timeMarkers = new string[0];
            }
            for (int i = 0; i < timeMarkers.Length; i++)
            {
                timeMarkers[i] = string.Format("Heap dump #{0}", i + 1);
            }
            if (heapDumpHistograms.Length > 0)
                WriteDiffReport(heapDumpHistograms, timeMarkers, entireLogResult);
            else
                Console.WriteLine("***** No heap dumps found *****");
        }
예제 #6
0
        internal static void SurvivorDifferenceReport(string logFileName, string startMarker, string endMarker)
        {
            // first read the entire file
            ReadNewLog log = new ReadNewLog(logFileName, false);
            ReadLogResult entireLogResult = GetLogResult(log);
            log.ReadFile(0, long.MaxValue, entireLogResult);

            if (startMarker == null)
                startMarker = CommentRangeForm.startCommentString;
            if (endMarker == null)
                endMarker = CommentRangeForm.shutdownCommentString;
            int startTickIndex = FindMarkerTickIndex(startMarker, log);
            int endTickIndex = FindMarkerTickIndex(endMarker, log);

            Histogram startHistogram = GetSurvivorHistogram(log, entireLogResult, 0, int.MaxValue, startMarker);
            Histogram endHistogram = GetSurvivorHistogram(log, entireLogResult, 0, int.MaxValue, endMarker);

            Console.WriteLine("Difference in surviving objects for {0} between {1} ({2} secs) and {3} ({4} secs)",
                                                                    logFileName, 
                                                                                startMarker,
                                                                                     log.TickIndexToTime(startTickIndex),
                                                                                                   endMarker, 
                                                                                                        log.TickIndexToTime(endTickIndex));

            WriteReport(startHistogram, endHistogram);
        }
예제 #7
0
        internal static void SurvivorReport(string logFileName, string startMarker, string endMarker, string[] timeMarker)
        {
            // first read the entire file
            ReadNewLog log = new ReadNewLog(logFileName, false);
            ReadLogResult entireLogResult = GetLogResult(log);
            log.ReadFile(0, long.MaxValue, entireLogResult);

            if (startMarker == null)
                startMarker = CommentRangeForm.startCommentString;
            if (endMarker == null)
                endMarker = CommentRangeForm.shutdownCommentString;
            int startTickIndex = FindMarkerTickIndex(startMarker, log);
            int endTickIndex = FindMarkerTickIndex(endMarker, log);

            if (timeMarker == null || timeMarker.Length == 0)
            {
                timeMarker = new String[1];
                timeMarker[0] = CommentRangeForm.shutdownCommentString;
            }

            Histogram[] histogram = new Histogram[timeMarker.Length];
            Console.Write("Surviving objects for {0} allocated between {1} ({2} secs) and {3} ({4} secs) at",
                                                  logFileName,
                                                                        startMarker, 
                                                                             log.TickIndexToTime(startTickIndex),
                                                                                           endMarker,
                                                                                                log.TickIndexToTime(endTickIndex));
            string separator = "";
            for (int i = 0; i < timeMarker.Length; i++)
            {
                if (timeMarker[i] == null)
                    timeMarker[i] = CommentRangeForm.shutdownCommentString;
                histogram[i] = GetSurvivorHistogram(log, entireLogResult, startTickIndex, endTickIndex, timeMarker[i]);
                int timeTickIndex = FindMarkerTickIndex(timeMarker[i], log);
                Console.Write("{0} {1} ({2} secs) ", separator, timeMarker[i], log.TickIndexToTime(timeTickIndex));
                separator = ",";
            }

            Console.WriteLine();

            WriteReport(histogram, timeMarker);
        }
예제 #8
0
        internal static Histogram GetSurvivorHistogram(ReadNewLog log, ReadLogResult entireLogResult, int startTickIndex, int endTickIndex, string timeMarker)
        {
            ReadLogResult logResult = entireLogResult;
            int timeTickIndex = entireLogResult.sampleObjectTable.lastTickIndex;
            if (timeMarker != null)
            {
                timeTickIndex = FindMarkerTickIndex(timeMarker, log);

                long endPos = log.TickIndexToPos(timeTickIndex);

                // Read the selected portion of the log again
                logResult = new ReadLogResult();
                logResult.liveObjectTable = new LiveObjectTable(log);
                log.ReadFile(0, endPos, logResult);
            }

            Histogram histogram = new Histogram(log);
            LiveObjectTable.LiveObject o;
            for (logResult.liveObjectTable.GetNextObject(0, ulong.MaxValue, out o);
                o.id < ulong.MaxValue;
                logResult.liveObjectTable.GetNextObject(o.id + o.size, ulong.MaxValue, out o))
            {
                if (startTickIndex <= o.allocTickIndex && o.allocTickIndex < endTickIndex)
                    histogram.AddObject(o.typeSizeStacktraceIndex, 1);
            }

            return histogram;
        }
예제 #9
0
        private void LoadLogFile(string logFileName)
        {
            if (logFileName.EndsWith(".exe",                        //The string to compare to the substring at the end of this instance
                                     true,                          //true to ignore case during the comparison; otherwise, false.
                                     CultureInfo.InvariantCulture   //An invariant culture is culture-insensitive.
                                     ))
            {
                ShowErrorMessage(logFileName +" is not a valid CLRProfiler log file name.");
                Environment.ExitCode = 1;
                exitProgram = true;
                return;
            }
            this.logFileName = logFileName;
            logFileStartOffset = 0;
            logFileEndOffset = long.MaxValue;

            processFileName = null;

            log = new ReadNewLog(logFileName);
            lastLogResult = null;
            ObjectGraph.cachedGraph = null;
            ReadLogResult readLogResult = GetLogResult();
            log.ReadFile(logFileStartOffset, logFileEndOffset, readLogResult);
            lastLogResult = readLogResult;
            Text = "Analyzing " + logFileName;
            EnableDisableViewMenuItems();
            viewSummaryMenuItem_Click(null, null);
        }
예제 #10
0
 private void readLogFile(ReadNewLog log, ReadLogResult logResult, string exeName, Graph.GraphType graphType)
 {
     log.ReadFile(logFileStartOffset, logFileEndOffset, logResult);
     ViewGraph(logResult, exeName, graphType);
 }
예제 #11
0
        internal void LoadLogFile(string logFileName)
        {
            this.logFileName = logFileName;
            logFileStartOffset = 0;
            logFileEndOffset = long.MaxValue;

            log = new ReadNewLog(logFileName);
            lastLogResult = null;
            ObjectGraph.cachedGraph = null;
            ReadLogResult readLogResult = GetLogResult();
            log.ReadFile(logFileStartOffset, logFileEndOffset, readLogResult);
            lastLogResult = readLogResult;

            viewSummaryMenuItem_Click(null, null);
        }