|
1 /* |
|
2 * Copyright (c) 2004-2008 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 |
|
18 using System; |
|
19 using System.Collections.Generic; |
|
20 using System.Text; |
|
21 using SymbianParserLib.Engine; |
|
22 using SymbianParserLib.Elements; |
|
23 using SymbianParserLib.Enums; |
|
24 using CrashDebuggerLib.Structures.KernelObjects; |
|
25 using CrashDebuggerLib.Parsers.State.Implementation.Helpers; |
|
26 |
|
27 namespace CrashDebuggerLib.Parsers.State.Implementation |
|
28 { |
|
29 internal abstract class StateContainerBase : State |
|
30 { |
|
31 #region Constructors |
|
32 protected StateContainerBase( CrashDebuggerParser aParser ) |
|
33 : base( aParser ) |
|
34 { |
|
35 DObject temp = CreateNewObject(); |
|
36 iObjectType = temp.Type; |
|
37 } |
|
38 #endregion |
|
39 |
|
40 #region API |
|
41 public override void Prepare() |
|
42 { |
|
43 DObjectCon container = CrashDebugger.ContainerByType( iObjectType ); |
|
44 // |
|
45 ParserLine l1 = ParserLine.NewSymFormat( "Container %d at %08x contains %d %S:\r\n" ); |
|
46 l1[ 0 ].SetTargetProperty( container, "Index" ); |
|
47 l1[ 1 ].SetTargetProperty( container, "KernelAddress" ); |
|
48 l1[ 2 ].SetTargetProperty( container, "ExpectedCount" ); |
|
49 l1.ElementComplete += new SymbianParserLib.BaseStructures.ParserElementBase.ElementCompleteHandler( ContainerCountInfoComplete ); |
|
50 // |
|
51 ParserParagraph para = new ParserParagraph( "CONTAINER [" + container.TypeDescription + "]" ); |
|
52 para.Add( l1 ); |
|
53 ParserEngine.Add( para ); |
|
54 // |
|
55 CreateEntryDetector(); |
|
56 } |
|
57 |
|
58 public override void Finalise() |
|
59 { |
|
60 } |
|
61 #endregion |
|
62 |
|
63 #region Abstract API |
|
64 protected abstract DObject CreateNewObject(); |
|
65 |
|
66 protected virtual bool IsObjectReadyForSaving( DObject aObject ) |
|
67 { |
|
68 bool ret = ( aObject.KernelAddress != 0 ); |
|
69 return ret; |
|
70 } |
|
71 |
|
72 protected virtual void CreateEntryParagraphs( DObject aObject ) |
|
73 { |
|
74 string name = "ENTRY [" + Container.TypeDescription + "]"; |
|
75 ParserParagraph para = iHelperDObject.CreateMonitorObjectParagraph( name, aObject ); |
|
76 ParserEngine.Add( para ); |
|
77 } |
|
78 |
|
79 protected virtual void CreateEntryParser() |
|
80 { |
|
81 // Remove all the old entries |
|
82 ParserEngine.Reset(); |
|
83 |
|
84 // Save last thread if it looks valid |
|
85 if ( iCurrentObject != null ) |
|
86 { |
|
87 bool ready = IsObjectReadyForSaving( iCurrentObject ); |
|
88 if ( ready ) |
|
89 { |
|
90 Container.Add( iCurrentObject ); |
|
91 iCurrentObject = null; |
|
92 } |
|
93 } |
|
94 |
|
95 // Create a new object which will contain the next set of parser data |
|
96 iCurrentObject = CreateNewObject(); |
|
97 |
|
98 // Use the helper to prepare next paragraphs |
|
99 CreateEntryParagraphs( iCurrentObject ); |
|
100 |
|
101 // Catch the next new entry |
|
102 CreateEntryDetector(); |
|
103 } |
|
104 |
|
105 protected virtual void CreateEntryDetector() |
|
106 { |
|
107 string containerType = Container.TypeDescription; |
|
108 ParserParagraph para = iHelperDObject.CreateEntryDetector( containerType, new SymbianParserLib.BaseStructures.ParserElementBase.ElementCompleteHandler( NewElementDetected ) ); |
|
109 ParserEngine.Add( para ); |
|
110 } |
|
111 #endregion |
|
112 |
|
113 #region Properties |
|
114 protected DObjectCon Container |
|
115 { |
|
116 get { return CrashDebugger.ContainerByType( iObjectType ); } |
|
117 } |
|
118 |
|
119 protected DObject.TObjectType ObjectType |
|
120 { |
|
121 get |
|
122 { |
|
123 return iObjectType; |
|
124 } |
|
125 } |
|
126 #endregion |
|
127 |
|
128 #region Internal methods |
|
129 #endregion |
|
130 |
|
131 #region Event handlers |
|
132 void NewElementDetected( SymbianParserLib.BaseStructures.ParserElementBase aElement ) |
|
133 { |
|
134 CreateEntryParser(); |
|
135 } |
|
136 |
|
137 void ContainerCountInfoComplete( SymbianParserLib.BaseStructures.ParserElementBase aElement ) |
|
138 { |
|
139 } |
|
140 #endregion |
|
141 |
|
142 #region Data members |
|
143 private DObject iCurrentObject = null; |
|
144 private HelperDObject iHelperDObject = new HelperDObject(); |
|
145 private readonly DObject.TObjectType iObjectType; |
|
146 #endregion |
|
147 } |
|
148 } |