|
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 CrashDebuggerLib.Structures.Thread; |
|
23 using CrashDebuggerLib.Structures.KernelObjects; |
|
24 using SymbianParserLib.Elements; |
|
25 using SymbianParserLib.Enums; |
|
26 |
|
27 namespace CrashDebuggerLib.Parsers.State.Implementation |
|
28 { |
|
29 internal class StateContainerThreads : State |
|
30 { |
|
31 #region Constructors |
|
32 public StateContainerThreads( CrashDebuggerParser aParser ) |
|
33 : base( aParser ) |
|
34 { |
|
35 } |
|
36 #endregion |
|
37 |
|
38 #region API |
|
39 public override void Prepare() |
|
40 { |
|
41 DObjectCon container = CrashDebugger.ContainerByType( DObject.TObjectType.EThread ); |
|
42 // |
|
43 ParserLine l1 = ParserLine.NewSymFormat( "Container %d at %08x contains %d %S:\r\n" ); |
|
44 l1[ 0 ].SetTargetProperty( container, "Index" ); |
|
45 l1[ 1 ].SetTargetProperty( container, "KernelAddress" ); |
|
46 l1[ 2 ].SetTargetProperty( container, "ExpectedCount" ); |
|
47 l1.ElementComplete += new SymbianParserLib.BaseStructures.ParserElementBase.ElementCompleteHandler( HeaderLine_ElementComplete ); |
|
48 // |
|
49 ParserParagraph para = new ParserParagraph( "CONTAINER [" + container.TypeDescription + "]" ); |
|
50 para.Add( l1 ); |
|
51 ParserEngine.Add( para ); |
|
52 } |
|
53 |
|
54 public override void Finalise() |
|
55 { |
|
56 |
|
57 } |
|
58 #endregion |
|
59 |
|
60 #region Properties |
|
61 #endregion |
|
62 |
|
63 #region Internal methods |
|
64 private void PrepareEntryParser() |
|
65 { |
|
66 // Junk the old paragraphs |
|
67 ParserEngine.Reset(); |
|
68 |
|
69 // Get a handle to our destination container |
|
70 DObjectCon container = CrashDebugger.ContainerByType( DObject.TObjectType.EThread ); |
|
71 |
|
72 // Save last thread if it looks valid |
|
73 if ( iCurrentObject != null && iCurrentObject.KernelAddress != 0 ) |
|
74 { |
|
75 bool alreadyExists = container.Contains( iCurrentObject ); |
|
76 if ( !alreadyExists ) |
|
77 { |
|
78 container.Add( iCurrentObject ); |
|
79 } |
|
80 // |
|
81 iCurrentObject = null; |
|
82 } |
|
83 |
|
84 // Create a new object which will contain the next set of parser data |
|
85 iCurrentObject = new DThread( CrashDebugger ); |
|
86 |
|
87 // Use the helper to prepare next paragraphs |
|
88 iHelper.CreateMonitorThread( ParserEngine, "ENTRY [" + container.TypeDescription + "]", iCurrentObject, new SymbianParserLib.BaseStructures.ParserElementBase.ElementCompleteHandler( PC_Register_ElementComplete ) ); |
|
89 } |
|
90 #endregion |
|
91 |
|
92 #region Event handlers |
|
93 void PC_Register_ElementComplete( SymbianParserLib.BaseStructures.ParserElementBase aElement ) |
|
94 { |
|
95 PrepareEntryParser(); |
|
96 } |
|
97 |
|
98 void HeaderLine_ElementComplete( SymbianParserLib.BaseStructures.ParserElementBase aElement ) |
|
99 { |
|
100 PrepareEntryParser(); |
|
101 } |
|
102 #endregion |
|
103 |
|
104 #region Data members |
|
105 private DThread iCurrentObject = null; |
|
106 private Helpers.HelperDThread iHelper = new CrashDebuggerLib.Parsers.State.Implementation.Helpers.HelperDThread(); |
|
107 #endregion |
|
108 } |
|
109 } |