|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * Redistribution and use in source and binary forms, with or without |
|
6 * modification, are permitted provided that the following conditions are met: |
|
7 * |
|
8 * - Redistributions of source code must retain the above copyright notice, |
|
9 * this list of conditions and the following disclaimer. |
|
10 * - Redistributions in binary form must reproduce the above copyright notice, |
|
11 * this list of conditions and the following disclaimer in the documentation |
|
12 * and/or other materials provided with the distribution. |
|
13 * - Neither the name of Nokia Corporation nor the names of its contributors |
|
14 * may be used to endorse or promote products derived from this software |
|
15 * without specific prior written permission. |
|
16 * |
|
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
27 * POSSIBILITY OF SUCH DAMAGE. |
|
28 * |
|
29 * Initial Contributors: |
|
30 * Nokia Corporation - initial contribution. |
|
31 * |
|
32 * Contributors: |
|
33 * |
|
34 * Description: |
|
35 * |
|
36 */ |
|
37 |
|
38 using System; |
|
39 using System.Drawing; |
|
40 using System.Collections; |
|
41 using System.ComponentModel; |
|
42 using System.Windows.Forms; |
|
43 using MemAnalysisLib; |
|
44 using MemAnalysisLib.Parser; |
|
45 using SymbianUtils.Settings; |
|
46 using MemAnalysisLib.MemoryOperations.Class; |
|
47 using MemAnalysisLib.MemoryOperations.Functions; |
|
48 using MemAnalysisLib.MemoryOperations.Operations; |
|
49 using MemAnalysisLib.Parser.Base; |
|
50 using MemAnalysisLib.Parser.Implementations; |
|
51 |
|
52 namespace MemAnalysisUiLib.Forms |
|
53 { |
|
54 public class MemAnalysisRegionalForm : System.Windows.Forms.Form |
|
55 { |
|
56 #region Windows Form Designer Code |
|
57 private System.Windows.Forms.GroupBox groupBox1; |
|
58 private System.Windows.Forms.ListView iListView; |
|
59 private System.Windows.Forms.ColumnHeader iColRegionNumber; |
|
60 private System.Windows.Forms.ColumnHeader iColLineNumber; |
|
61 private System.Windows.Forms.ColumnHeader iColCountAllocs; |
|
62 private System.Windows.Forms.ColumnHeader iColCountFrees; |
|
63 private System.Windows.Forms.ColumnHeader iColMemAllocated; |
|
64 private System.Windows.Forms.ColumnHeader iColMemFreed; |
|
65 private System.Windows.Forms.ColumnHeader iColNet; |
|
66 private System.Windows.Forms.ColumnHeader iColRegionText; |
|
67 private System.Windows.Forms.GroupBox groupBox2; |
|
68 private System.Windows.Forms.TextBox iMarkerStartText; |
|
69 private System.Windows.Forms.Label label1; |
|
70 private System.Windows.Forms.Label label2; |
|
71 private System.Windows.Forms.Label label3; |
|
72 private System.Windows.Forms.TextBox iMarkerEndText; |
|
73 private System.Windows.Forms.Panel iPnl_Upper; |
|
74 private System.Windows.Forms.Panel iPnl_Lower; |
|
75 private System.Windows.Forms.Splitter iSplitter_Horizontal; |
|
76 private XPTable.Models.Table iTable; |
|
77 private XPTable.Models.TableModel iTable_Model; |
|
78 private XPTable.Models.ColumnModel iTable_ColModel; |
|
79 private XPTable.Models.TextColumn iCol_MemOp; |
|
80 private XPTable.Models.TextColumn iCol_LineNumber; |
|
81 private XPTable.Models.TextColumn iCol_CellAddr; |
|
82 private XPTable.Models.TextColumn iCol_AllocSize; |
|
83 private XPTable.Models.TextColumn iCol_Type; |
|
84 private XPTable.Models.TextColumn iCol_HeapSize; |
|
85 private XPTable.Models.TextColumn iCol_AssociatedOp; |
|
86 private XPTable.Models.TextColumn iCol_Symbol; |
|
87 private System.ComponentModel.Container components = null; |
|
88 #endregion |
|
89 |
|
90 #region Constructors & destructor |
|
91 public MemAnalysisRegionalForm( MemAnalysisParserBase aParser, XmlSettings aSettings ) |
|
92 { |
|
93 InitializeComponent(); |
|
94 |
|
95 System.Diagnostics.Debug.Assert( aParser is MemAnalysisRegionalParser ); |
|
96 iParser = (MemAnalysisRegionalParser) aParser; |
|
97 iSettings = aSettings; |
|
98 } |
|
99 |
|
100 protected override void Dispose( bool disposing ) |
|
101 { |
|
102 if( disposing ) |
|
103 { |
|
104 if(components != null) |
|
105 { |
|
106 components.Dispose(); |
|
107 } |
|
108 } |
|
109 base.Dispose( disposing ); |
|
110 } |
|
111 #endregion |
|
112 |
|
113 #region Windows Form Designer generated code |
|
114 private void InitializeComponent() |
|
115 { |
|
116 this.iPnl_Upper = new System.Windows.Forms.Panel(); |
|
117 this.groupBox1 = new System.Windows.Forms.GroupBox(); |
|
118 this.iListView = new System.Windows.Forms.ListView(); |
|
119 this.iColRegionNumber = new System.Windows.Forms.ColumnHeader(); |
|
120 this.iColLineNumber = new System.Windows.Forms.ColumnHeader(); |
|
121 this.iColCountAllocs = new System.Windows.Forms.ColumnHeader(); |
|
122 this.iColCountFrees = new System.Windows.Forms.ColumnHeader(); |
|
123 this.iColMemAllocated = new System.Windows.Forms.ColumnHeader(); |
|
124 this.iColMemFreed = new System.Windows.Forms.ColumnHeader(); |
|
125 this.iColNet = new System.Windows.Forms.ColumnHeader(); |
|
126 this.iColRegionText = new System.Windows.Forms.ColumnHeader(); |
|
127 this.iPnl_Lower = new System.Windows.Forms.Panel(); |
|
128 this.groupBox2 = new System.Windows.Forms.GroupBox(); |
|
129 this.iTable = new XPTable.Models.Table(); |
|
130 this.iTable_ColModel = new XPTable.Models.ColumnModel(); |
|
131 this.iCol_MemOp = new XPTable.Models.TextColumn(); |
|
132 this.iCol_LineNumber = new XPTable.Models.TextColumn(); |
|
133 this.iCol_CellAddr = new XPTable.Models.TextColumn(); |
|
134 this.iCol_Type = new XPTable.Models.TextColumn(); |
|
135 this.iCol_AllocSize = new XPTable.Models.TextColumn(); |
|
136 this.iCol_HeapSize = new XPTable.Models.TextColumn(); |
|
137 this.iCol_AssociatedOp = new XPTable.Models.TextColumn(); |
|
138 this.iCol_Symbol = new XPTable.Models.TextColumn(); |
|
139 this.iTable_Model = new XPTable.Models.TableModel(); |
|
140 this.iMarkerStartText = new System.Windows.Forms.TextBox(); |
|
141 this.label1 = new System.Windows.Forms.Label(); |
|
142 this.label2 = new System.Windows.Forms.Label(); |
|
143 this.label3 = new System.Windows.Forms.Label(); |
|
144 this.iMarkerEndText = new System.Windows.Forms.TextBox(); |
|
145 this.iSplitter_Horizontal = new System.Windows.Forms.Splitter(); |
|
146 this.iPnl_Upper.SuspendLayout(); |
|
147 this.groupBox1.SuspendLayout(); |
|
148 this.iPnl_Lower.SuspendLayout(); |
|
149 this.groupBox2.SuspendLayout(); |
|
150 ((System.ComponentModel.ISupportInitialize)(this.iTable)).BeginInit(); |
|
151 this.SuspendLayout(); |
|
152 // |
|
153 // iPnl_Upper |
|
154 // |
|
155 this.iPnl_Upper.Controls.Add(this.groupBox1); |
|
156 this.iPnl_Upper.Dock = System.Windows.Forms.DockStyle.Top; |
|
157 this.iPnl_Upper.Location = new System.Drawing.Point(0, 0); |
|
158 this.iPnl_Upper.Name = "iPnl_Upper"; |
|
159 this.iPnl_Upper.Size = new System.Drawing.Size(1016, 172); |
|
160 this.iPnl_Upper.TabIndex = 3; |
|
161 // |
|
162 // groupBox1 |
|
163 // |
|
164 this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) |
|
165 | System.Windows.Forms.AnchorStyles.Left) |
|
166 | System.Windows.Forms.AnchorStyles.Right))); |
|
167 this.groupBox1.Controls.Add(this.iListView); |
|
168 this.groupBox1.Location = new System.Drawing.Point(8, 5); |
|
169 this.groupBox1.Name = "groupBox1"; |
|
170 this.groupBox1.Size = new System.Drawing.Size(1006, 164); |
|
171 this.groupBox1.TabIndex = 1; |
|
172 this.groupBox1.TabStop = false; |
|
173 this.groupBox1.Text = "Identified regions..."; |
|
174 // |
|
175 // iListView |
|
176 // |
|
177 this.iListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) |
|
178 | System.Windows.Forms.AnchorStyles.Left) |
|
179 | System.Windows.Forms.AnchorStyles.Right))); |
|
180 this.iListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { |
|
181 this.iColRegionNumber, |
|
182 this.iColLineNumber, |
|
183 this.iColCountAllocs, |
|
184 this.iColCountFrees, |
|
185 this.iColMemAllocated, |
|
186 this.iColMemFreed, |
|
187 this.iColNet, |
|
188 this.iColRegionText}); |
|
189 this.iListView.FullRowSelect = true; |
|
190 this.iListView.GridLines = true; |
|
191 this.iListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; |
|
192 this.iListView.Location = new System.Drawing.Point(12, 20); |
|
193 this.iListView.Name = "iListView"; |
|
194 this.iListView.Size = new System.Drawing.Size(980, 136); |
|
195 this.iListView.TabIndex = 0; |
|
196 this.iListView.View = System.Windows.Forms.View.Details; |
|
197 this.iListView.SelectedIndexChanged += new System.EventHandler(this.iListView_SelectedIndexChanged); |
|
198 // |
|
199 // iColRegionNumber |
|
200 // |
|
201 this.iColRegionNumber.Text = "Region #"; |
|
202 // |
|
203 // iColLineNumber |
|
204 // |
|
205 this.iColLineNumber.Text = "Line #"; |
|
206 // |
|
207 // iColCountAllocs |
|
208 // |
|
209 this.iColCountAllocs.Text = "Alloc. Count"; |
|
210 this.iColCountAllocs.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; |
|
211 this.iColCountAllocs.Width = 73; |
|
212 // |
|
213 // iColCountFrees |
|
214 // |
|
215 this.iColCountFrees.Text = "Free\'d Count"; |
|
216 this.iColCountFrees.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; |
|
217 this.iColCountFrees.Width = 75; |
|
218 // |
|
219 // iColMemAllocated |
|
220 // |
|
221 this.iColMemAllocated.Text = "Allocated Memory"; |
|
222 this.iColMemAllocated.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; |
|
223 this.iColMemAllocated.Width = 96; |
|
224 // |
|
225 // iColMemFreed |
|
226 // |
|
227 this.iColMemFreed.Text = "Free\'d Memory"; |
|
228 this.iColMemFreed.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; |
|
229 this.iColMemFreed.Width = 84; |
|
230 // |
|
231 // iColNet |
|
232 // |
|
233 this.iColNet.Text = "Net"; |
|
234 this.iColNet.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; |
|
235 this.iColNet.Width = 80; |
|
236 // |
|
237 // iColRegionText |
|
238 // |
|
239 this.iColRegionText.Text = ""; |
|
240 this.iColRegionText.Width = 337; |
|
241 // |
|
242 // iPnl_Lower |
|
243 // |
|
244 this.iPnl_Lower.Controls.Add(this.groupBox2); |
|
245 this.iPnl_Lower.Dock = System.Windows.Forms.DockStyle.Fill; |
|
246 this.iPnl_Lower.Location = new System.Drawing.Point(0, 172); |
|
247 this.iPnl_Lower.Name = "iPnl_Lower"; |
|
248 this.iPnl_Lower.Size = new System.Drawing.Size(1016, 569); |
|
249 this.iPnl_Lower.TabIndex = 4; |
|
250 // |
|
251 // groupBox2 |
|
252 // |
|
253 this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) |
|
254 | System.Windows.Forms.AnchorStyles.Left) |
|
255 | System.Windows.Forms.AnchorStyles.Right))); |
|
256 this.groupBox2.Controls.Add(this.iTable); |
|
257 this.groupBox2.Controls.Add(this.iMarkerStartText); |
|
258 this.groupBox2.Controls.Add(this.label1); |
|
259 this.groupBox2.Controls.Add(this.label2); |
|
260 this.groupBox2.Controls.Add(this.label3); |
|
261 this.groupBox2.Controls.Add(this.iMarkerEndText); |
|
262 this.groupBox2.Location = new System.Drawing.Point(8, 5); |
|
263 this.groupBox2.Name = "groupBox2"; |
|
264 this.groupBox2.Size = new System.Drawing.Size(1006, 558); |
|
265 this.groupBox2.TabIndex = 2; |
|
266 this.groupBox2.TabStop = false; |
|
267 this.groupBox2.Text = "Memory operations within region"; |
|
268 // |
|
269 // iTable |
|
270 // |
|
271 this.iTable.AlternatingRowColor = System.Drawing.Color.Gainsboro; |
|
272 this.iTable.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) |
|
273 | System.Windows.Forms.AnchorStyles.Left) |
|
274 | System.Windows.Forms.AnchorStyles.Right))); |
|
275 this.iTable.ColumnModel = this.iTable_ColModel; |
|
276 this.iTable.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); |
|
277 this.iTable.FullRowSelect = true; |
|
278 this.iTable.HeaderFont = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); |
|
279 this.iTable.Location = new System.Drawing.Point(88, 47); |
|
280 this.iTable.Name = "iTable"; |
|
281 this.iTable.Size = new System.Drawing.Size(904, 476); |
|
282 this.iTable.TabIndex = 3; |
|
283 this.iTable.TableModel = this.iTable_Model; |
|
284 this.iTable.CellClick += new XPTable.Events.CellMouseEventHandler(this.iTable_CellClick); |
|
285 // |
|
286 // iTable_ColModel |
|
287 // |
|
288 this.iTable_ColModel.Columns.AddRange(new XPTable.Models.Column[] { |
|
289 this.iCol_MemOp, |
|
290 this.iCol_LineNumber, |
|
291 this.iCol_CellAddr, |
|
292 this.iCol_Type, |
|
293 this.iCol_AllocSize, |
|
294 this.iCol_HeapSize, |
|
295 this.iCol_AssociatedOp, |
|
296 this.iCol_Symbol}); |
|
297 // |
|
298 // iCol_MemOp |
|
299 // |
|
300 this.iCol_MemOp.Text = "Op. #"; |
|
301 this.iCol_MemOp.Width = 72; |
|
302 // |
|
303 // iCol_LineNumber |
|
304 // |
|
305 this.iCol_LineNumber.Text = "Line"; |
|
306 this.iCol_LineNumber.Width = 62; |
|
307 // |
|
308 // iCol_CellAddr |
|
309 // |
|
310 this.iCol_CellAddr.Text = "Cell Addr."; |
|
311 this.iCol_CellAddr.Width = 62; |
|
312 // |
|
313 // iCol_Type |
|
314 // |
|
315 this.iCol_Type.Text = "Type"; |
|
316 this.iCol_Type.Width = 110; |
|
317 // |
|
318 // iCol_AllocSize |
|
319 // |
|
320 this.iCol_AllocSize.Alignment = XPTable.Models.ColumnAlignment.Right; |
|
321 this.iCol_AllocSize.Text = "Alloc. Size"; |
|
322 this.iCol_AllocSize.Width = 64; |
|
323 // |
|
324 // iCol_HeapSize |
|
325 // |
|
326 this.iCol_HeapSize.Alignment = XPTable.Models.ColumnAlignment.Right; |
|
327 this.iCol_HeapSize.Text = "Heap Size"; |
|
328 this.iCol_HeapSize.Width = 64; |
|
329 // |
|
330 // iCol_AssociatedOp |
|
331 // |
|
332 this.iCol_AssociatedOp.Text = "Associated Op."; |
|
333 this.iCol_AssociatedOp.Width = 170; |
|
334 // |
|
335 // iCol_Symbol |
|
336 // |
|
337 this.iCol_Symbol.Text = "Symbol"; |
|
338 this.iCol_Symbol.Width = 270; |
|
339 // |
|
340 // iMarkerStartText |
|
341 // |
|
342 this.iMarkerStartText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) |
|
343 | System.Windows.Forms.AnchorStyles.Right))); |
|
344 this.iMarkerStartText.Location = new System.Drawing.Point(88, 22); |
|
345 this.iMarkerStartText.Name = "iMarkerStartText"; |
|
346 this.iMarkerStartText.ReadOnly = true; |
|
347 this.iMarkerStartText.Size = new System.Drawing.Size(904, 20); |
|
348 this.iMarkerStartText.TabIndex = 1; |
|
349 this.iMarkerStartText.Text = ""; |
|
350 // |
|
351 // label1 |
|
352 // |
|
353 this.label1.Location = new System.Drawing.Point(16, 24); |
|
354 this.label1.Name = "label1"; |
|
355 this.label1.Size = new System.Drawing.Size(64, 16); |
|
356 this.label1.TabIndex = 2; |
|
357 this.label1.Text = "Start text:"; |
|
358 this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; |
|
359 // |
|
360 // label2 |
|
361 // |
|
362 this.label2.Location = new System.Drawing.Point(16, 52); |
|
363 this.label2.Name = "label2"; |
|
364 this.label2.Size = new System.Drawing.Size(64, 20); |
|
365 this.label2.TabIndex = 2; |
|
366 this.label2.Text = "Operations:"; |
|
367 this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; |
|
368 // |
|
369 // label3 |
|
370 // |
|
371 this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); |
|
372 this.label3.Location = new System.Drawing.Point(16, 530); |
|
373 this.label3.Name = "label3"; |
|
374 this.label3.Size = new System.Drawing.Size(64, 16); |
|
375 this.label3.TabIndex = 2; |
|
376 this.label3.Text = "End text:"; |
|
377 this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight; |
|
378 // |
|
379 // iMarkerEndText |
|
380 // |
|
381 this.iMarkerEndText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) |
|
382 | System.Windows.Forms.AnchorStyles.Right))); |
|
383 this.iMarkerEndText.Location = new System.Drawing.Point(88, 528); |
|
384 this.iMarkerEndText.Name = "iMarkerEndText"; |
|
385 this.iMarkerEndText.ReadOnly = true; |
|
386 this.iMarkerEndText.Size = new System.Drawing.Size(904, 20); |
|
387 this.iMarkerEndText.TabIndex = 1; |
|
388 this.iMarkerEndText.Text = ""; |
|
389 // |
|
390 // iSplitter_Horizontal |
|
391 // |
|
392 this.iSplitter_Horizontal.Dock = System.Windows.Forms.DockStyle.Top; |
|
393 this.iSplitter_Horizontal.Location = new System.Drawing.Point(0, 172); |
|
394 this.iSplitter_Horizontal.Name = "iSplitter_Horizontal"; |
|
395 this.iSplitter_Horizontal.Size = new System.Drawing.Size(1016, 3); |
|
396 this.iSplitter_Horizontal.TabIndex = 5; |
|
397 this.iSplitter_Horizontal.TabStop = false; |
|
398 // |
|
399 // MemAnalysisRegionalForm |
|
400 // |
|
401 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); |
|
402 this.ClientSize = new System.Drawing.Size(1016, 741); |
|
403 this.Controls.Add(this.iSplitter_Horizontal); |
|
404 this.Controls.Add(this.iPnl_Lower); |
|
405 this.Controls.Add(this.iPnl_Upper); |
|
406 this.MaximizeBox = false; |
|
407 this.MinimizeBox = false; |
|
408 this.MinimumSize = new System.Drawing.Size(1024, 456); |
|
409 this.Name = "MemAnalysisRegionalForm"; |
|
410 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; |
|
411 this.Text = "Marker-based Analysis"; |
|
412 this.Load += new System.EventHandler(this.MemAnalysisRegionalForm_Load); |
|
413 this.iPnl_Upper.ResumeLayout(false); |
|
414 this.groupBox1.ResumeLayout(false); |
|
415 this.iPnl_Lower.ResumeLayout(false); |
|
416 this.groupBox2.ResumeLayout(false); |
|
417 ((System.ComponentModel.ISupportInitialize)(this.iTable)).EndInit(); |
|
418 this.ResumeLayout(false); |
|
419 |
|
420 } |
|
421 #endregion |
|
422 |
|
423 #region Event handlers |
|
424 private void MemAnalysisRegionalForm_Load(object sender, System.EventArgs e) |
|
425 { |
|
426 PrepareListView(); |
|
427 } |
|
428 |
|
429 private void iListView_SelectedIndexChanged(object sender, System.EventArgs e) |
|
430 { |
|
431 if ( iListView.SelectedIndices.Count > 0 ) |
|
432 { |
|
433 // Check the selected item isn't one of the footer (total) rows |
|
434 ListViewItem item = iListView.SelectedItems[ 0 ]; |
|
435 if ( item.Tag != null ) |
|
436 { |
|
437 PrepareGridForSelectedListItem(); |
|
438 } |
|
439 } |
|
440 } |
|
441 |
|
442 private void iTable_CellClick(object sender, XPTable.Events.CellMouseEventArgs e) |
|
443 { |
|
444 if ( e.Cell.Tag is MemOpBase ) |
|
445 { |
|
446 // Get the object |
|
447 MemOpBase baseObject = (MemOpBase) e.Cell.Tag; |
|
448 System.Diagnostics.Debug.Assert( baseObject.Link != null ); |
|
449 |
|
450 // Get the current collection |
|
451 if ( iListView.SelectedIndices.Count > 0 && !iPreparingGrid ) |
|
452 { |
|
453 ListViewItem listItem = iListView.SelectedItems[ 0 ]; |
|
454 if ( listItem.Tag != null && listItem.Tag is MemObjRegionalCollection ) |
|
455 { |
|
456 MemObjRegionalCollection collection = (MemObjRegionalCollection) listItem.Tag; |
|
457 |
|
458 // Get the associated (linked) collection |
|
459 int collectionIndex; |
|
460 int itemIndex; |
|
461 MemOpBase linkedItem; |
|
462 MemObjRegionalCollection linkedCollection = iParser.Data.CollectionByOperationIndex( baseObject.Link.OperationIndex, |
|
463 baseObject.Link.Class, |
|
464 out linkedItem, |
|
465 out collectionIndex, |
|
466 out itemIndex ); |
|
467 |
|
468 // Did we find a linked item? |
|
469 if ( linkedCollection != null && linkedItem != null ) |
|
470 { |
|
471 // Select the correct list item |
|
472 if ( collection != linkedCollection ) |
|
473 { |
|
474 // We need to jump to a different collection... |
|
475 if ( linkedCollection.RegionStart.MatchedRegionText || !iParser.Options.MarkerOperationsOutsideRegionToBeIgnored ) |
|
476 { |
|
477 if ( iParser.Options.MarkerOperationsOutsideRegionToBeIgnored ) |
|
478 { |
|
479 collectionIndex = CollectionIndex( linkedCollection ); |
|
480 } |
|
481 iListView.Items[ iListView.SelectedIndices[0] ].Selected = false; |
|
482 iListView.Items[ collectionIndex ].Selected = true; |
|
483 iListView.Select(); |
|
484 } |
|
485 } |
|
486 |
|
487 // Select it |
|
488 iTable.TableModel.Selections.Clear(); |
|
489 iTable.TableModel.Selections.AddCell( itemIndex, 6 ); |
|
490 iTable.EnsureVisible( itemIndex, 6 ); |
|
491 iTable.Select(); |
|
492 } |
|
493 } |
|
494 } |
|
495 } |
|
496 } |
|
497 #endregion |
|
498 |
|
499 #region Internal methods |
|
500 private void PrepareListView() |
|
501 { |
|
502 try |
|
503 { |
|
504 iListView.Enabled = false; |
|
505 Cursor.Current = Cursors.WaitCursor; |
|
506 |
|
507 long totalAllocCount = 0; |
|
508 long totalFreeCount = 0; |
|
509 long totalAllocSize = 0; |
|
510 long totalDeallocSize = 0; |
|
511 long totalNetSize = 0; |
|
512 |
|
513 // Ensure that each allocation-symbol is added to the symbol listbox |
|
514 MemObjRegionalData data = iParser.Data; |
|
515 // |
|
516 iListView.BeginUpdate(); |
|
517 int count = data.Count; |
|
518 for(int i=0; i<count; i++) |
|
519 { |
|
520 MemObjRegionalCollection collection = data[ i ]; |
|
521 // |
|
522 if ( collection.RegionStart.MatchedRegionText || !iParser.Options.MarkerOperationsOutsideRegionToBeIgnored ) |
|
523 { |
|
524 long allocCount = collection.AllocationCount; |
|
525 long freeCount = collection.DeallocationCount; |
|
526 long allocSize = collection.TotalAmountOfAllocatedMemory; |
|
527 long deallocSize = collection.TotalAmountOfDeallocatedMemory; |
|
528 long netSize = collection.TotalMemoryAllocatedButNotFreed; |
|
529 // |
|
530 ListViewItem item = new ListViewItem( (i+1).ToString("d8") ); |
|
531 item.SubItems.Add( collection.RegionStart.LineNumber.ToString("d8") ); |
|
532 item.SubItems.Add( allocCount.ToString() ); |
|
533 item.SubItems.Add( freeCount.ToString() ); |
|
534 item.SubItems.Add( allocSize.ToString() ); |
|
535 item.SubItems.Add( deallocSize.ToString() ); |
|
536 item.SubItems.Add( netSize.ToString() ); |
|
537 item.SubItems.Add( collection.RegionStart.RegionText ); |
|
538 item.Tag = collection; |
|
539 iListView.Items.Add( item ); |
|
540 |
|
541 // Update totals |
|
542 totalAllocCount += allocCount; |
|
543 totalFreeCount += freeCount; |
|
544 totalAllocSize += allocSize; |
|
545 totalDeallocSize += deallocSize; |
|
546 totalNetSize += netSize; |
|
547 } |
|
548 // |
|
549 if ( count % 100 != 0 ) |
|
550 Application.DoEvents(); |
|
551 } |
|
552 |
|
553 // Make the first item selected |
|
554 if ( iListView.Items.Count > 0 && iListView.SelectedIndices.Count == 0 ) |
|
555 { |
|
556 // Add total item |
|
557 iListView.Items.Add( new ListViewItem( "" ) ); |
|
558 // |
|
559 ListViewItem totalItem = new ListViewItem( "Totals:" ); |
|
560 totalItem.SubItems.Add( "" ); |
|
561 totalItem.SubItems.Add( totalAllocCount.ToString() ); |
|
562 totalItem.SubItems.Add( totalFreeCount.ToString() ); |
|
563 totalItem.SubItems.Add( totalAllocSize.ToString() ); |
|
564 totalItem.SubItems.Add( totalDeallocSize.ToString() ); |
|
565 totalItem.SubItems.Add( totalNetSize.ToString() ); |
|
566 totalItem.SubItems.Add( "" ); |
|
567 iListView.Items.Add( totalItem ); |
|
568 // |
|
569 iListView.Items[0].Selected = true; |
|
570 iListView.Select(); |
|
571 } |
|
572 |
|
573 iListView.EndUpdate(); |
|
574 } |
|
575 finally |
|
576 { |
|
577 Cursor.Current = Cursors.Default; |
|
578 iListView.Enabled = true; |
|
579 iListView.Select(); |
|
580 } |
|
581 } |
|
582 |
|
583 private void PrepareGridForSelectedListItem() |
|
584 { |
|
585 if ( !( iPreparingGrid || iListView.SelectedItems.Count == 0 || iListView.SelectedItems[ 0 ].Tag == null ) ) |
|
586 { |
|
587 iPreparingGrid = true; |
|
588 iListView.Enabled = false; |
|
589 Cursor.Current = Cursors.WaitCursor; |
|
590 // |
|
591 ListViewItem listItem = iListView.SelectedItems[ 0 ]; |
|
592 MemObjRegionalCollection collection = (MemObjRegionalCollection) listItem.Tag; |
|
593 // |
|
594 try |
|
595 { |
|
596 // First update the text labels to show the marker values |
|
597 iMarkerStartText.Text = collection.RegionStart.RegionText; |
|
598 iMarkerEndText.Text = collection.RegionEnd.RegionText; |
|
599 |
|
600 // Clear existing content |
|
601 iTable.TableModel.Rows.Clear(); |
|
602 |
|
603 // Make new content |
|
604 int count = collection.Count; |
|
605 for(int i=0; i<count; i++) |
|
606 { |
|
607 // The entry we are rendering |
|
608 MemOpBase baseObject = collection[i]; |
|
609 |
|
610 // Only initialised if we are dealing with an allocation (or realloc) type cell. |
|
611 MemOpAllocation memObj = null; |
|
612 |
|
613 // The color format for the entire row. |
|
614 System.Drawing.Color rowColor = Color.Black; |
|
615 |
|
616 // The row we are creating |
|
617 XPTable.Models.Row row = new XPTable.Models.Row(); |
|
618 |
|
619 // Common items |
|
620 // ============ |
|
621 row.Cells.Add( new XPTable.Models.Cell( baseObject.OperationIndex.ToString("d6") ) ); |
|
622 row.Cells.Add( new XPTable.Models.Cell( baseObject.LineNumber.ToString("d6") ) ); |
|
623 row.Cells.Add( new XPTable.Models.Cell( baseObject.CellAddress.ToString("x8") ) ); |
|
624 row.Cells.Add( new XPTable.Models.Cell( " " + baseObject.FunctionName ) ); |
|
625 |
|
626 // Row Color & Object Association |
|
627 // ============================== |
|
628 if ( baseObject is MemOpAllocation ) |
|
629 { |
|
630 // Allocation |
|
631 memObj = (MemOpAllocation) baseObject; |
|
632 rowColor = Color.Red; |
|
633 } |
|
634 else if ( baseObject is MemOpFree ) |
|
635 { |
|
636 // Deallocation |
|
637 if ( baseObject.Link != null ) |
|
638 { |
|
639 memObj = (MemOpAllocation) baseObject.Link; |
|
640 } |
|
641 else |
|
642 { |
|
643 memObj = null; |
|
644 } |
|
645 rowColor = Color.Green; |
|
646 } |
|
647 else if ( baseObject is MemOpReallocation ) |
|
648 { |
|
649 // Reallocation |
|
650 if ( baseObject.Link != null ) |
|
651 { |
|
652 memObj = (MemOpAllocation) baseObject.Link; |
|
653 } |
|
654 else |
|
655 { |
|
656 memObj = null; |
|
657 } |
|
658 rowColor = Color.Blue; |
|
659 } |
|
660 |
|
661 // Allocation size |
|
662 // =============== |
|
663 string allocationSize = "???"; |
|
664 if ( memObj != null ) |
|
665 { |
|
666 allocationSize = memObj.AllocationSize.ToString(); |
|
667 } |
|
668 row.Cells.Add( new XPTable.Models.Cell( allocationSize + " " ) ); |
|
669 |
|
670 // Heap size |
|
671 // ========= |
|
672 row.Cells.Add( new XPTable.Models.Cell( baseObject.HeapSize.ToString() + " " ) ); |
|
673 |
|
674 // Associated object |
|
675 // ================= |
|
676 MemOpAllocation symbolObject = memObj; |
|
677 if ( memObj != null && baseObject.Link != null ) |
|
678 { |
|
679 // If we have an associated link item, we can connect the two items together |
|
680 string associatedText = string.Empty; |
|
681 if ( baseObject.IsAllocationType ) |
|
682 { |
|
683 associatedText = "Free'd by op #: " + baseObject.Link.OperationIndex.ToString("d5"); |
|
684 } |
|
685 else if ( baseObject.IsReallocationType ) |
|
686 { |
|
687 associatedText = "First alloc'd by op #: " + baseObject.Link.OperationIndex.ToString("d5"); |
|
688 symbolObject = ( baseObject.Link as MemOpAllocation ); |
|
689 } |
|
690 else |
|
691 { |
|
692 associatedText = "Alloc'd by op #: " + baseObject.Link.OperationIndex.ToString("d5"); |
|
693 } |
|
694 |
|
695 // We store the object with the cell so that we can handle hyperlinks between |
|
696 // associated objects. |
|
697 XPTable.Models.Cell associatedCell = new XPTable.Models.Cell( associatedText ); |
|
698 associatedCell.Tag = baseObject; |
|
699 |
|
700 // Make it look like a hyperlink |
|
701 associatedCell.Font = new Font( iTable.Font.FontFamily.Name, iTable.Font.SizeInPoints, System.Drawing.FontStyle.Underline ); |
|
702 |
|
703 // Add the cell to the row |
|
704 row.Cells.Add( associatedCell ); |
|
705 } |
|
706 else |
|
707 { |
|
708 if ( baseObject.IsAllocationType ) |
|
709 { |
|
710 if ( memObj != null ) |
|
711 { |
|
712 symbolObject = memObj; |
|
713 } |
|
714 |
|
715 rowColor = Color.Red; |
|
716 row.Font = new System.Drawing.Font( iTable.Font.FontFamily.Name, iTable.Font.SizeInPoints, System.Drawing.FontStyle.Bold ); |
|
717 row.Cells.Add( new XPTable.Models.Cell( "Object never free'd!" ) ); |
|
718 } |
|
719 else |
|
720 { |
|
721 row.Cells.Add( new XPTable.Models.Cell( "???!" ) ); |
|
722 } |
|
723 } |
|
724 |
|
725 // Symbol |
|
726 // ====== |
|
727 string symbol = string.Empty; |
|
728 if ( symbolObject != null && symbolObject.LinkRegisterSymbol != null ) |
|
729 { |
|
730 symbol = memObj.LinkRegisterSymbol.Symbol.ToString(); |
|
731 } |
|
732 row.Cells.Add( new XPTable.Models.Cell( symbol ) ); |
|
733 |
|
734 // Set row color |
|
735 // ============= |
|
736 row.ForeColor = rowColor; |
|
737 |
|
738 // Add row |
|
739 // ======= |
|
740 iTable.TableModel.Rows.Add( row ); |
|
741 } |
|
742 |
|
743 // If no items, then dim table |
|
744 iTable.Enabled = ( count > 0 ); |
|
745 } |
|
746 finally |
|
747 { |
|
748 Cursor.Current = Cursors.Default; |
|
749 iPreparingGrid = false; |
|
750 iListView.Enabled = true; |
|
751 iListView.Select(); |
|
752 } |
|
753 } |
|
754 } |
|
755 |
|
756 private int CollectionIndex( MemObjRegionalCollection aCollection ) |
|
757 { |
|
758 int ret = -1; |
|
759 int index = 0; |
|
760 // |
|
761 int count = iListView.Items.Count; |
|
762 foreach( ListViewItem item in iListView.Items ) |
|
763 { |
|
764 if ( item.Tag != null ) |
|
765 { |
|
766 MemObjRegionalCollection col = (MemObjRegionalCollection) item.Tag; |
|
767 if ( col == aCollection ) |
|
768 { |
|
769 index = ret; |
|
770 break; |
|
771 } |
|
772 } |
|
773 else |
|
774 { |
|
775 break; |
|
776 } |
|
777 |
|
778 ++index; |
|
779 } |
|
780 // |
|
781 return index; |
|
782 } |
|
783 #endregion |
|
784 |
|
785 #region Data members |
|
786 private bool iPreparingGrid = false; |
|
787 private MemAnalysisRegionalParser iParser; |
|
788 private XmlSettings iSettings; |
|
789 #endregion |
|
790 } |
|
791 } |