crashanalysercmd/Libraries/Engine/CrashDebuggerLib/Parsers/State/Implementation/Containers/StateContainerProcesses.cs
changeset 0 818e61de6cd1
equal deleted inserted replaced
-1:000000000000 0:818e61de6cd1
       
     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.Process;
       
    24 using CrashDebuggerLib.Structures.KernelObjects;
       
    25 using SymbianParserLib.Elements;
       
    26 using SymbianParserLib.Enums;
       
    27 
       
    28 namespace CrashDebuggerLib.Parsers.State.Implementation
       
    29 {
       
    30     internal class StateContainerProcesses : State
       
    31     {
       
    32         #region Constructors
       
    33         public StateContainerProcesses( CrashDebuggerParser aParser )
       
    34             : base( aParser )
       
    35         {
       
    36         }
       
    37         #endregion
       
    38 
       
    39         #region API
       
    40         public override void Prepare()
       
    41         {
       
    42             DObjectCon container = CrashDebugger.ContainerByType( DObject.TObjectType.EProcess );
       
    43             //
       
    44             ParserLine l1 = ParserLine.NewSymFormat( "Container %d at %08x contains %d %S:\r\n" );
       
    45             l1[ 0 ].SetTargetProperty( container, "Index" );
       
    46             l1[ 1 ].SetTargetProperty( container, "KernelAddress" );
       
    47             l1[ 2 ].SetTargetProperty( container, "ExpectedCount" );
       
    48             l1.ElementComplete += new SymbianParserLib.BaseStructures.ParserElementBase.ElementCompleteHandler( HeaderLine_ElementComplete );
       
    49             //
       
    50             ParserParagraph para = new ParserParagraph( "CONTAINER [" + container.TypeDescription + "]" );
       
    51             para.Add( l1 );
       
    52             ParserEngine.Add( para );
       
    53         }
       
    54 
       
    55         public override void Finalise()
       
    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.EProcess );
       
    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 DProcess( CrashDebugger );
       
    86 
       
    87             // Use the helper to prepare next paragraphs
       
    88             iHelper.CreateMonitorProcess( ParserEngine, "ENTRY [" + container.TypeDescription + "]", iCurrentObject, new SymbianParserLib.BaseStructures.ParserElementBase.ElementCompleteHandler( ProcessChunksComplete_ElementHandler ) );
       
    89         }
       
    90         #endregion
       
    91 
       
    92         #region Event handlers
       
    93         void ProcessChunksComplete_ElementHandler( 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 DProcess iCurrentObject = null;
       
   106         private Helpers.HelperDProcess iHelper = new CrashDebuggerLib.Parsers.State.Implementation.Helpers.HelperDProcess();
       
   107         #endregion
       
   108     }
       
   109 }