|
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.Processes; |
|
23 using SymbianStructuresLib.Debug.Symbols; |
|
24 |
|
25 namespace CrashXmlPlugin.FileFormat.Segment.Entries.Symbols |
|
26 { |
|
27 internal class CXmlSegSymbols : CXmlSegBase |
|
28 { |
|
29 #region Constructors |
|
30 public CXmlSegSymbols() |
|
31 : base( SegConstants.Symbols ) |
|
32 { |
|
33 } |
|
34 #endregion |
|
35 |
|
36 #region From CXmlSegBase |
|
37 public override int SegmentPriority |
|
38 { |
|
39 get { return 10; } |
|
40 } |
|
41 #endregion |
|
42 |
|
43 #region From CXmlNode |
|
44 public override void XmlSerialize( CrashXmlPlugin.FileFormat.Document.CXmlDocumentSerializationParameters aParameters ) |
|
45 { |
|
46 // Don't write symbols or stack if we were asked to create the summary file. |
|
47 if ( aParameters.DetailLevel == CrashItemLib.Sink.CISinkSerializationParameters.TDetailLevel.EFull ) |
|
48 { |
|
49 base.XmlSerialize( aParameters ); |
|
50 } |
|
51 } |
|
52 |
|
53 protected override void XmlSerializeChildren( CrashXmlPlugin.FileFormat.Document.CXmlDocumentSerializationParameters aParameters ) |
|
54 { |
|
55 // First partition the symbols into sets |
|
56 CISymbolDictionary globalSymbols = aParameters.Container.Symbols; |
|
57 Partition( globalSymbols ); |
|
58 |
|
59 // Also get the dictionaries from the individual processes |
|
60 CIElementList<CIProcess> processes = aParameters.Container.ChildrenByType<CIProcess>(); |
|
61 foreach ( CIProcess process in processes ) |
|
62 { |
|
63 CISymbolDictionary processSymbols = process.Symbols; |
|
64 Partition( processSymbols ); |
|
65 } |
|
66 |
|
67 // Then serialize the sets |
|
68 foreach ( KeyValuePair<string, CXmlSymbolSet> kvp in iSets ) |
|
69 { |
|
70 CXmlSymbolSet set = kvp.Value; |
|
71 set.XmlSerialize( aParameters ); |
|
72 } |
|
73 } |
|
74 #endregion |
|
75 |
|
76 #region Internal methods |
|
77 private void Partition( CISymbolDictionary aDictionary ) |
|
78 { |
|
79 foreach ( CISymbol crashItemSymbol in aDictionary ) |
|
80 { |
|
81 bool serializable = CXmlSymbol.IsSerializable( crashItemSymbol ); |
|
82 if ( serializable ) |
|
83 { |
|
84 Symbol symbol = crashItemSymbol.Symbol; |
|
85 SymbolCollection symbolCollection = symbol.Collection; |
|
86 // |
|
87 string collectionName = symbolCollection.FileName.FileNameInHost.ToUpper(); |
|
88 CXmlSymbolSet set = null; |
|
89 // |
|
90 if ( !iSets.ContainsKey( collectionName ) ) |
|
91 { |
|
92 set = new CXmlSymbolSet( symbolCollection ); |
|
93 iSets.Add( collectionName, set ); |
|
94 } |
|
95 else |
|
96 { |
|
97 set = iSets[ collectionName ]; |
|
98 } |
|
99 // |
|
100 set.Add( crashItemSymbol ); |
|
101 } |
|
102 } |
|
103 } |
|
104 #endregion |
|
105 |
|
106 #region Data members |
|
107 private SortedDictionary<string, CXmlSymbolSet> iSets = new SortedDictionary<string, CXmlSymbolSet>(); |
|
108 #endregion |
|
109 } |
|
110 } |