|
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 SymbianStructuresLib.Debug.Trace; |
|
21 using SymbianDebugLib.PluginAPI.Types.Trace; |
|
22 using CrashItemLib.Crash; |
|
23 using CrashItemLib.Crash.Base; |
|
24 using CrashItemLib.Crash.Base.DataBinding; |
|
25 using CrashItemLib.Crash.Utils; |
|
26 using CrashItemLib.Crash.Container; |
|
27 |
|
28 namespace CrashItemLib.Crash.Traces |
|
29 { |
|
30 [CIDBAttributeColumn( "Prefix", 0 )] |
|
31 [CIDBAttributeColumn( "Payload", 1, true )] |
|
32 [CIDBAttributeColumn( "Suffix", 2 )] |
|
33 public class CITraceData : CIElement, IEnumerable<CITrace> |
|
34 { |
|
35 #region Constructors |
|
36 [CIElementAttributeMandatory()] |
|
37 public CITraceData( CIContainer aContainer ) |
|
38 : base( aContainer ) |
|
39 { |
|
40 // Restrict children to traces |
|
41 base.AddSupportedChildType( typeof( CITrace ) ); |
|
42 |
|
43 // Must be done at the end because it creates elements |
|
44 base.IsToBeFinalizedLast = true; |
|
45 } |
|
46 #endregion |
|
47 |
|
48 #region API |
|
49 #endregion |
|
50 |
|
51 #region Properties |
|
52 public byte[] RawData |
|
53 { |
|
54 get { return iRawData != null ? iRawData : new byte[] { }; } |
|
55 set |
|
56 { |
|
57 iRawData = value; |
|
58 } |
|
59 } |
|
60 |
|
61 public TraceLine[] Lines |
|
62 { |
|
63 get |
|
64 { |
|
65 TraceLine[] ret = iLines; |
|
66 if ( ret == null ) |
|
67 { |
|
68 ret = new TraceLine[] { }; |
|
69 } |
|
70 return ret; |
|
71 } |
|
72 } |
|
73 #endregion |
|
74 |
|
75 #region From IEnumerable<CITrace> |
|
76 public new IEnumerator<CITrace> GetEnumerator() |
|
77 { |
|
78 foreach ( CIElement element in base.Children ) |
|
79 { |
|
80 if ( element is CITrace ) |
|
81 { |
|
82 CITrace reg = (CITrace) element; |
|
83 yield return reg; |
|
84 } |
|
85 } |
|
86 } |
|
87 |
|
88 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() |
|
89 { |
|
90 foreach ( CIElement element in base.Children ) |
|
91 { |
|
92 if ( element is CITrace ) |
|
93 { |
|
94 CITrace reg = (CITrace) element; |
|
95 yield return reg; |
|
96 } |
|
97 } |
|
98 } |
|
99 #endregion |
|
100 |
|
101 #region From CIElementBase |
|
102 public override void PrepareRows() |
|
103 { |
|
104 DataBindingModel.ClearRows(); |
|
105 |
|
106 // Our data binding model is based upon the trace object, rather |
|
107 // than any key-value-pair properties. |
|
108 foreach ( CITrace t in this ) |
|
109 { |
|
110 DataBindingModel.Add( t ); |
|
111 } |
|
112 } |
|
113 |
|
114 internal override void OnFinalize( CIElementFinalizationParameters aParams ) |
|
115 { |
|
116 base.OnFinalize( aParams ); |
|
117 // |
|
118 DecodeTraces( aParams.DebugEngine.TraceDictionaries ); |
|
119 } |
|
120 #endregion |
|
121 |
|
122 #region Internal methods |
|
123 private void DecodeTraces( DbgEngineTrace aTraceDecoder ) |
|
124 { |
|
125 if ( iRawData != null ) |
|
126 { |
|
127 iLines = aTraceDecoder.Decode( iRawData ); |
|
128 if ( iLines != null && iLines.Length > 0 ) |
|
129 { |
|
130 foreach ( TraceLine line in iLines ) |
|
131 { |
|
132 CITrace entry = new CITrace( base.Container, line ); |
|
133 base.AddChild( entry ); |
|
134 } |
|
135 } |
|
136 } |
|
137 } |
|
138 #endregion |
|
139 |
|
140 #region Data members |
|
141 private byte[] iRawData = null; |
|
142 private TraceLine[] iLines = null; |
|
143 #endregion |
|
144 } |
|
145 } |