crashanalysercmd/Libraries/Engine/CrashDebuggerLib/Parsers/State/Implementation/Containers/StateContainerCodeSegs.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.Fault;
       
    23 using CrashDebuggerLib.Structures.CodeSeg;
       
    24 using SymbianParserLib.Elements;
       
    25 using SymbianParserLib.Enums;
       
    26 
       
    27 namespace CrashDebuggerLib.Parsers.State.Implementation
       
    28 {
       
    29     internal class StateContainerCodeSegs : State
       
    30     {
       
    31         #region Constructors
       
    32         public StateContainerCodeSegs( CrashDebuggerParser aParser )
       
    33             : base( aParser )
       
    34         {
       
    35         }
       
    36         #endregion
       
    37 
       
    38         #region API
       
    39         public override void Prepare()
       
    40         {
       
    41             PrepareEntryParser();
       
    42         }
       
    43 
       
    44         public override void Finalise()
       
    45         {
       
    46             
       
    47         }
       
    48         #endregion
       
    49 
       
    50         #region Properties
       
    51         #endregion
       
    52 
       
    53         #region Internal methods
       
    54         private void PrepareEntryParser()
       
    55         {
       
    56             ParserParagraph para = new ParserParagraph( "CODE SEGS" );
       
    57             //
       
    58             ParserLine l1 = ParserLine.NewSymFormat( "\r\nCodeSeg at %08x:\r\n" );
       
    59             ParserLine l2 = ParserLine.NewSymFormat( "   FileName: %S\r\n" );
       
    60             ParserLine l3 = ParserLine.NewSymFormat( "   RunAddress: %08x\r\n" );
       
    61 
       
    62             para.ElementComplete += new SymbianParserLib.BaseStructures.ParserElementBase.ElementCompleteHandler( ParagraphComplete );
       
    63             //
       
    64             para.Add( l1, l2, l3 );
       
    65             ParserEngine.Add( para );
       
    66         }
       
    67         #endregion
       
    68 
       
    69         #region Event handlers
       
    70         void ParagraphComplete( SymbianParserLib.BaseStructures.ParserElementBase aElement )
       
    71         {
       
    72             ParserParagraph para = (ParserParagraph) aElement;
       
    73             //
       
    74             ParserField fAddress = para[ 0 ][ 0 ];
       
    75             ParserField fFileName = para[ 1 ][ 0 ];
       
    76             ParserField fRunAddress = para[ 2 ][ 0 ];
       
    77             //
       
    78             uint address = fAddress.AsUint;
       
    79             string fName = fFileName.AsString;
       
    80             uint runAddress = fRunAddress.AsUint;
       
    81             //
       
    82             CodeSegEntry entry = new CodeSegEntry( CrashDebugger, address, fName );
       
    83             entry.RunAddress = runAddress;
       
    84             CrashDebugger.CodeSegs.Add( entry );
       
    85 
       
    86             // Remove completed entry, add a new one
       
    87             ParserEngine.Remove( para );
       
    88             PrepareEntryParser();
       
    89         }
       
    90         #endregion
       
    91 
       
    92         #region Data members
       
    93         #endregion
       
    94     }
       
    95 }