|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 using System; |
|
18 using System.Text; |
|
19 using System.Collections.Generic; |
|
20 using CrashItemLib.Crash.Base; |
|
21 using CrashItemLib.Crash.Symbols; |
|
22 using CrashItemLib.Crash.Stacks; |
|
23 using CrashItemLib.Crash.Registers; |
|
24 using CrashXmlPlugin.FileFormat.Node; |
|
25 |
|
26 namespace CrashXmlPlugin.FileFormat.Segment.Entries.Stacks |
|
27 { |
|
28 internal class CXmlStack : CXmlNode |
|
29 { |
|
30 #region Constructors |
|
31 public CXmlStack( CIStack aStack ) |
|
32 : base( SegConstants.Stacks_Stack ) |
|
33 { |
|
34 iStack = aStack; |
|
35 } |
|
36 #endregion |
|
37 |
|
38 #region From CXmlNode |
|
39 protected override void XmlSerializeContent( CrashXmlPlugin.FileFormat.Document.CXmlDocumentSerializationParameters aParameters ) |
|
40 { |
|
41 CXmlNode.WriteId( iStack, aParameters.Writer ); |
|
42 |
|
43 if ( iStack.Registers != null ) |
|
44 { |
|
45 CXmlNode.WriteLink( iStack.Registers.Id, SegConstants.Registers, aParameters.Writer ); |
|
46 } |
|
47 if ( iStack.OwningThread != null ) |
|
48 { |
|
49 CXmlNode.WriteLink( iStack.OwningThread.Id, SegConstants.Threads, aParameters.Writer ); |
|
50 } |
|
51 |
|
52 aParameters.Writer.WriteElementString( SegConstants.CmnBase, iStack.Base.ToString("x8") ); |
|
53 aParameters.Writer.WriteElementString( SegConstants.CmnSize, iStack.Size.ToString( "x" ) ); |
|
54 aParameters.Writer.WriteElementString( SegConstants.CmnRange, iStack.Range.ToString() ); |
|
55 |
|
56 // Write any messages |
|
57 CXmlSegBase.XmlSerializeMessages( aParameters, iStack ); |
|
58 } |
|
59 |
|
60 protected override void XmlSerializeChildren( CrashXmlPlugin.FileFormat.Document.CXmlDocumentSerializationParameters aParameters ) |
|
61 { |
|
62 // Algorithm name directly maps onto an attribute |
|
63 string attributeAlgorithm = string.Empty; |
|
64 if ( iStack.Algorithm.ToUpper().Contains( "ACCURATE" ) ) |
|
65 { |
|
66 attributeAlgorithm = SegConstants.Stacks_Stack_Attributes_Accurate; |
|
67 } |
|
68 else if ( iStack.Algorithm.ToUpper().Contains( "HEURISTIC" ) ) |
|
69 { |
|
70 attributeAlgorithm = SegConstants.Stacks_Stack_Attributes_Heuristic; |
|
71 } |
|
72 |
|
73 // Attributes |
|
74 if ( attributeAlgorithm != string.Empty ) |
|
75 { |
|
76 aParameters.Writer.WriteStartElement( SegConstants.CmnAttributes ); |
|
77 aParameters.Writer.WriteElementString( attributeAlgorithm, string.Empty ); |
|
78 aParameters.Writer.WriteEndElement(); |
|
79 } |
|
80 |
|
81 // Entries |
|
82 if ( aParameters.DetailLevel != CrashItemLib.Sink.CISinkSerializationParameters.TDetailLevel.ESummary ) |
|
83 { |
|
84 System.Diagnostics.Debug.Assert( iStack.IsStackOutputAvailable ); |
|
85 // |
|
86 aParameters.Writer.WriteStartElement( SegConstants.Stacks_Stack_Data ); |
|
87 // |
|
88 foreach ( CIStackEntry entry in iStack ) |
|
89 { |
|
90 CXmlStackEntry xmlEntry = new CXmlStackEntry( entry ); |
|
91 xmlEntry.XmlSerialize( aParameters ); |
|
92 } |
|
93 // |
|
94 aParameters.Writer.WriteEndElement(); |
|
95 } |
|
96 } |
|
97 #endregion |
|
98 |
|
99 #region Properties |
|
100 #endregion |
|
101 |
|
102 #region Data members |
|
103 private readonly CIStack iStack; |
|
104 #endregion |
|
105 } |
|
106 } |