crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianStackLib/Data/Source/Primer/StackEnginePrimer.cs
author Matti Laitinen <matti.t.laitinen@nokia.com>
Thu, 11 Feb 2010 15:50:58 +0200
changeset 0 818e61de6cd1
permissions -rw-r--r--
Add initial version of Crash Analyser cmdline under EPL

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
* 
* Description:
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using SymbianUtils.DataBuffer;
using SymbianUtils.DataBuffer.Entry;
using SymbianUtils.DataBuffer.Primer;
using SymbianStackLib.Engine;
using SymbianStackLib.Data.Source;

namespace SymbianStackLib.Data.Source.Primer
{
    public sealed class StackEnginePrimer : DataBufferPrimer
    {
        #region Constructors
        internal StackEnginePrimer( StackEngine aEngine )
            : base( aEngine.DataSource )
        {
            iEngine = aEngine;
            //
            base.LineNotHandled += new DataBufferPrimerUnhandledLine( StackEnginePrimer_LineNotHandled );
            base.PrimerComplete += new DataBufferPrimerCompleteHandler( StackEnginePrimer_PrimerComplete );
        }
        #endregion

        #region Event handlers
        void StackEnginePrimer_PrimerComplete( DataBufferPrimer aPrimer, DataBuffer aBuffer, uint aFirstByteAddress, uint aLastByteAddress )
        {
            SeedAddressRangeBasedUponData();
        }

        void StackEnginePrimer_LineNotHandled( DataBufferPrimer aPrimer, DataBuffer aBuffer, string aLine )
        {
            iEngine.Prefixes.TryAgainstPrefixes( aLine );
        }
        #endregion

        #region Properties
        #endregion

        #region Internal methods
        private void SeedAddressRangeBasedUponData()
        {
            uint top = iEngine.DataSource.First.Address;
            if ( top != 0 && iEngine.AddressInfo.Top == 0 )
            {
                iEngine.AddressInfo.Top = top;
            }
            //
            uint baseAddr = iEngine.DataSource.Last.Address;
            if ( baseAddr != 0 && iEngine.AddressInfo.Base == 0 )
            {
                iEngine.AddressInfo.Base = baseAddr;
            }
        }
        #endregion

        #region Data members
        private readonly StackEngine iEngine;
        #endregion
    }
}