diff -r 000000000000 -r 818e61de6cd1 crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianETMLib/Common/State/Implementations/ETMDecodeStateContextID.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianETMLib/Common/State/Implementations/ETMDecodeStateContextID.cs Thu Feb 11 15:50:58 2010 +0200 @@ -0,0 +1,86 @@ +/* +* 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 SymbianUtils.BasicTypes; +using SymbianETMLib.Common.Types; +using SymbianETMLib.Common.Packets; + +namespace SymbianETMLib.Common.State +{ + public class ETMDecodeStateContextID : ETMDecodeState + { + #region Constructors + public ETMDecodeStateContextID( ETMStateData aManager ) + : base( aManager ) + { + iContextIdBytesRequired = aManager.Config.ContextIDSize; + iBytesRemaining = iContextIdBytesRequired; + } + #endregion + + #region API + public override ETMDecodeState HandleByte( SymByte aByte ) + { + // TODO: test this + ETMDecodeState nextState = this; + // + int byteNumber = iContextIdBytesRequired - iBytesRemaining; + uint val = aByte.LShift( byteNumber * 8 ); + iContextId |= val; + // + if ( --iBytesRemaining == 0 ) + { + // Got everything + base.StateData.SetContextID( iContextId ); + nextState = new ETMDecodeStateSynchronized( base.StateData ); + } + // + return nextState; + } + #endregion + + #region Properties + public string ContextIDName + { + get + { + string ret = base.StateData.Config.GetContextID( iContextId ); + return ret; + } + } + #endregion + + #region Internal methods + private void Trace() + { + base.DbgTrace( "CONTEXT_ID", string.Format( "ID: {0} [{1}]", iContextId, ContextIDName ) ); + } + #endregion + + #region From System.Object + #endregion + + #region Data members + private readonly int iContextIdBytesRequired; + private uint iContextId = 0; + private int iBytesRemaining = 0; + #endregion + } +}