コード例 #1
0
        internal SortAndHighlightSelector(CallTreeForm.SortingBehaviour sort, CallTreeForm.SortingBehaviour highlight)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // need to add any constructor code after InitializeComponent call
            //
            int i, numCounters = Statistics.GetNumberOfCounters();
            sortCounter.Items.Add("in order of execution");
            for(i = 0; i < numCounters; i++)
            {
                sortCounter.Items.Add("by " + Statistics.GetCounterName(i).ToLower());
            }
            sortCounter.SelectedIndex = 1 + sort.counterId;
            sortOrder.SelectedIndex = (1 + sort.sortingOrder) / 2;

            for(i = 0; i < numCounters; i++)
            {
                highlightCounter.Items.Add(Statistics.GetCounterName(i).ToLower());
            }
            highlightCounter.SelectedIndex = highlight.counterId;
            highlightOrder.SelectedIndex = (1 + highlight.sortingOrder) / 2;
        }
コード例 #2
0
        internal void GetSortResults(CallTreeForm.SortingBehaviour s,
                                   CallTreeForm.SortingBehaviour h)
        {
            s.counterId = sortCounter.SelectedIndex - 1;
            s.sortingOrder = sortOrder.SelectedIndex * 2 - 1;

            h.counterId = highlightCounter.SelectedIndex;
            h.sortingOrder = highlightOrder.SelectedIndex * 2 - 1;
        }
コード例 #3
0
ファイル: CallTreeForm.cs プロジェクト: engincancan/utilities
 public void SetIncludeFilters( CallTreeForm.FnViewFilter[] filters)
 {
     filterInclude = filters;
 }
コード例 #4
0
 private void viewCallTreeMenuItem_Click(object sender, System.EventArgs e)
 {
     if (clrProfiler.lastLogResult != null && clrProfiler.lastLogResult.hadCallInfo)
     {
         CallTreeForm callTreeForm = new CallTreeForm(clrProfiler.log.fileName, clrProfiler.lastLogResult);
     }
 }
コード例 #5
0
		private void BuildBaseData(GraphBase gb, CallTreeForm tmpcallTree,  Hashtable htbl, Hashtable FuncExcl, Hashtable TypeExcl)
		{
			Vertex selectedVertex;
			int selectedVertexCount = gb.SelectedVertexCount(out selectedVertex);
			int id = 1;
			
			string nameAndSignature = null;
			datanode n = new datanode();


			try
			{
				foreach (Vertex v in gb.basegraph.vertices.Values)
				{
					if( !v.name.StartsWith("????"))
					{
						if (v.selected || (selectedVertexCount == 0) )
						{
							nameAndSignature  = v.name;
							if(v.signature != null)
								nameAndSignature += ' ' + v.signature;
							n.name = nameAndSignature;
							n.incl = FormatSize((int)v.weight);
							n.caller = v.incomingEdges;
							n.callee = v.outgoingEdges;
							n.level = v.level;
							n.excl = 0;
							n.timesBeenCalled= n.timesMakeCalls = 0;
							FillCallAlloc(ref n, v);
							if(tmpcallTree.LogResult.allocatedHistogram.readNewLog.funcSignatureIdHash.ContainsKey(nameAndSignature))
							{
								n.category = 1;	// func
								id = tmpcallTree.LogResult.callstackHistogram.readNewLog.funcSignatureIdHash[nameAndSignature];
								if(FuncExcl.ContainsKey(nameAndSignature))
								{
									n.excl =  FormatSize((int)FuncExcl[nameAndSignature]);
								}
								if( id > 0 && id <tmpcallTree.CallStats.Length)
								{

									n.timesBeenCalled = (int)tmpcallTree.CallStats[id].timesCalled;
									n.timesMakeCalls = (int)tmpcallTree.CallStats[id].totalFunctionsCalled;
								}
								if( !htbl.ContainsKey(nameAndSignature))
								{
									htbl.Add(nameAndSignature, n);
								}
							}
							else if(tmpcallTree.LogResult.allocatedHistogram.readNewLog.typeSignatureIdHash.ContainsKey(nameAndSignature))
							{
								n.category = 2;	// type
								id = tmpcallTree.LogResult.allocatedHistogram.readNewLog.typeSignatureIdHash[nameAndSignature];
								if(TypeExcl.ContainsKey(nameAndSignature))
								{
									n.excl =  FormatSize((int)TypeExcl[nameAndSignature]);
								}
								if( id > 0 && id <tmpcallTree.AllocStats.Length)
								{
									n.timesBeenCalled = (int)tmpcallTree.AllocStats[id].timesAllocated;
								}
								if( !htbl.ContainsKey(nameAndSignature))
								{
									typemaxIncl = (typemaxIncl > v.weight) ? typemaxIncl : v.weight;
									htbl.Add(nameAndSignature, n);
								}
							}
							else
							{
								if( !htbl.ContainsKey(nameAndSignature))
								{
									maxIncl = v.weight;
									htbl.Add(nameAndSignature, n);
								}
							}

						}
			
					}
				}
			}
			catch
			{
				throw new Exception("Faild on build base data structure \n");
			}
			// max for caculate function/type 9 details 
			if( prevFilter.max == 0)
			{
				prevFilter.max = maxIncl;
				prevTypedeFilter.max = typemaxIncl;
			}
			else
			{
				currFilter.max = maxIncl;
				currTypedeFilter.max = typemaxIncl;
			}
			maxIncl = 0;
			typemaxIncl = 0;
		}
コード例 #6
0
		private void GetLogData()
		{
			// get base data from log files
			try
			{
				_prevLog.readLogFile();
			}
			catch
			{
				throw new Exception("Bad log file: " + _prevLog.LogFileName + "\n");
			}
			try
			{
				_currLog.readLogFile();
			}
			catch
			{
				throw new Exception("Bad log file: " + _currLog.LogFileName +  "\n");
			}

			// get mixed data structure graph
			try
			{
				_prevG.GetAllocationGraph(_prevLog.logResult);
			}
			catch
			{
				throw new Exception("Bad data structure in log file: " + _prevLog.LogFileName +  "\n");
			}
			try
			{
				_currG.GetAllocationGraph(_currLog.logResult);
			}
			catch
			{
				throw new Exception("Bad data structure in log file: " + _currLog.LogFileName +  "\n");
			}

			// get more detailed allocation info from stack trace 
			try
			{
				
				_prevcallTrace = new CallTreeForm(_prevLog.LogFileName, _prevLog.logResult, true);
				ReadFile(_prevcallTrace, _prevLog.LogFileName, this.prevFuncExcl, this.prevTypeExcl);
			}
			catch
			{
				throw new Exception("Bad stacktrace content in log file: " + _prevLog.logResult +  "\n");
			}
			try
			{
				_currcallTrace = new CallTreeForm(_currLog.LogFileName, _currLog.logResult, true);
				ReadFile(_currcallTrace, _currLog.LogFileName, this.currFuncExcl, this.currTypeExcl);
			}
			catch
			{
				throw new Exception("Bad stacktrace content in log file: " + _currLog.logResult +  "\n");
			}
			nodeidx = 0;
			diffTracetbl = new DataTable("diffTrace");
			summaryTracetbl = new DataTable("summaryTracetbl");
			MakeDiffTreceTable(diffTracetbl);
			MakeDiffTreceTable(summaryTracetbl);
		

			string rname = _currcallTrace.MakeName((TreeNode)_currcallTrace.callTreeView.Root);
			Root = new DiffDataNode(rname);
			Root.prevIncl = ((TreeNode)_prevcallTrace.callTreeView.Root).data.bytesAllocated;
			Root.currIncl = ((TreeNode)_currcallTrace.callTreeView.Root).data.bytesAllocated;
			Root.diffIncl = Root.currIncl - Root.prevIncl;
			Root.prevCalls = ((TreeNode)_prevcallTrace.callTreeView.Root).data.numberOfFunctionsCalled;
			Root.currCalls = ((TreeNode)_currcallTrace.callTreeView.Root).data.numberOfFunctionsCalled;
			Root.diffCalls = Root.currCalls - Root.prevCalls;
			

			Root.nodeId = nodeidx++;
			Root.parentId = -1;
			Root.prevFunId = 0;
			Root.currFunId = 0;
			AddDiffTraceTableRow(diffTracetbl, Root);

			
			BuildDiffTraceTable(Root, (TreeNode)_currcallTrace.callTreeView.Root, (TreeNode)_prevcallTrace.callTreeView.Root);
			this.ds.Tables.Add(diffTracetbl);
			sumnodeidx = 0;
			depth = -1;
			BuildSummaryTable(Root, -1, "parentid = -1");
			Root = (DiffDataNode)Root.allkids[0];
			this.ds.Tables.Add(summaryTracetbl);

		

		}
コード例 #7
0
		private void ReadFile(CallTreeForm callTrace, string fileName, Hashtable FuncExcl, Hashtable TypeExcl)
		{
			Hashtable funcCalled = new Hashtable();
			Hashtable TypeAlloc = new Hashtable();
			Stream s = null;
			ProgressForm progressForm = null;
			try
			{
				s = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
				r = new StreamReader(s);

				progressForm = new ProgressForm();
				progressForm.Text = "Preparing call tree view";
				progressForm.Visible = true;
				progressForm.setProgress(0);
				progressForm.TopMost = false;
				int maxProgress = (int)(r.BaseStream.Length/1024);
				progressForm.setMaximum(maxProgress);

				buffer = new byte[4096];
				bufPos = 0;
				bufLevel = 0;
				line = 1;
				StringBuilder sb = new StringBuilder();
				c = ReadChar();

				bool found;
				string assemblyName = null;
				int threadid = 0, stackid = 0;
				TreeNode.NodeType nodetype = TreeNode.NodeType.Call;

				while (c != -1)
				{
					found = false;
					if ((line % 1024) == 0)
					{
						int currentProgress = (int)(pos/1024);
						if (currentProgress <= maxProgress)
						{
							progressForm.setProgress(currentProgress);
						}
					}
					lastLineStartPos = pos-1;
					switch (c)
					{
						case    -1:
							break;
				
							// 'A' with thread identifier
						case    '!':
						{
							found = true;
							c = ReadChar();
							threadid = ReadInt();
							ReadInt();
							stackid = ReadInt();
							nodetype = TreeNode.NodeType.Allocation;
							if (c == -1)	{found = false;}
							break;
			
						}

						case    'C':
						case    'c':
						{
							found = true;
							c = ReadChar();
							nodetype = TreeNode.NodeType.Call;
							threadid = ReadInt();
							stackid = ReadInt();
							if (c == -1)	{found = false;}
							break;
						}

						
						case 'y':
						case 'Y':
						{
							found = true;
							c = ReadChar();
							nodetype = TreeNode.NodeType.AssemblyLoad;
							threadid = ReadInt();
							ReadInt();

							while (c == ' ' || c == '\t')
							{
								c = ReadChar();
							}
							sb.Length = 0;
							while (c > ' ')
							{
								sb.Append((char)c);
								c = ReadChar();
							}
							assemblyName = sb.ToString();
							break;
						}


						default:
						{
							// just ignore the unknown
							while(c != '\n' && c != '\r')
							{
								c = ReadChar();
							}
							break;
						}
					}
					while (c == ' ' || c == '\t')
						c = ReadChar();
					if (c == '\r')
						c = ReadChar();
					if (c == '\n')
					{
						c = ReadChar();
						line++;
					}
					if(!found)
					{
						continue;
					}
				
					string name = null;
					string typename = null;

					int[] stacktrace = callTrace.IndexToStacktrace(stackid);
					int functionId = (nodetype != TreeNode.NodeType.AssemblyLoad ? stacktrace[stacktrace.Length - 1] : 0);
					switch(nodetype)
					{
						case TreeNode.NodeType.Allocation:
							string key = null;
							if( (functionId < callTrace.LogResult.callstackHistogram.readNewLog.funcName.Length )&& 
								((name = callTrace.LogResult.callstackHistogram.readNewLog.funcName[functionId]) != null))
							{
								if( callTrace.LogResult.callstackHistogram.readNewLog.funcSignature[functionId] != null)
								{
									name += ' ' + callTrace.LogResult.callstackHistogram.readNewLog.funcSignature[functionId];
								}
							}
							else
							{
								name = "NATIVE FUNCTION ( UNKNOWN ARGUMENTS )";
							}
														
							// function Excl							
							if(FuncExcl.ContainsKey(name))
							{
								int alloc = (int)FuncExcl[(string)name];
								alloc += stacktrace[1];
								FuncExcl[name] = alloc;
							}
							else
							{
								FuncExcl.Add(name, stacktrace[1]);
							}
							
							// Type Excl
							if( stacktrace[0]>=0 && stacktrace[0] < callTrace.LogResult.callstackHistogram.readNewLog.typeName.Length)
							{
								typename = callTrace.LogResult.callstackHistogram.readNewLog.typeName[stacktrace[0]];
							}
							if(typename == null)
								typename = "NATIVE FUNCTION ( UNKNOWN ARGUMENTS )";
																											
							if(TypeExcl.ContainsKey(typename))
							{
								int alloc = (int)TypeExcl[(string)typename];
								alloc += stacktrace[1];
								TypeExcl[typename] = alloc;
							}
							else
							{
								TypeExcl.Add(typename, stacktrace[1]);
							}
							
							// Type Allocated by Excl
							if(name != "NATIVE FUNCTION ( UNKNOWN ARGUMENTS )")
								key = typename + '|' + functionId;
							else
								key = typename + '|' + 0;
							if( TypeAlloc.ContainsKey(key))
							{
								int alloc = (int)TypeAlloc[key];
								alloc += stacktrace[1];
								TypeAlloc[key] = alloc;
							}
							else
							{
								TypeAlloc.Add(key, stacktrace[1]);
							}
									
							break;
						case TreeNode.NodeType.Call:
							if(funcCalled.ContainsKey(functionId))
							{
								int calls = (int)funcCalled[functionId] + 1;;
								funcCalled[functionId]= calls;
							}
							else
							{
								funcCalled.Add(functionId,1);
							}
							break;
					}
				}

			}
			catch (Exception)
			{
				throw new Exception(string.Format("Bad format in log file {0} line {1}", fileName, line));
			}

			finally
			{
				progressForm.Visible = false;
				progressForm.Dispose();
				if (r != null)
					r.Close();
			}
		}