crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianETMLib/ETB/StackRecon/ETBStackReconManager.cs
changeset 0 818e61de6cd1
equal deleted inserted replaced
-1:000000000000 0:818e61de6cd1
       
     1 /*
       
     2 * Copyright (c) 2009 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 SymbianETMLib.Common.Engine;
       
    22 using SymbianETMLib.Common.Types;
       
    23 using SymbianStructuresLib.Arm;
       
    24 using SymbianStructuresLib.Arm.Exceptions;
       
    25 
       
    26 namespace SymbianETMLib.ETB.StackRecon
       
    27 {
       
    28     public class ETBStackReconManager
       
    29     {
       
    30         #region Constructors
       
    31         public ETBStackReconManager( ETEngineBase aEngine )
       
    32         {
       
    33             iEngine = aEngine;
       
    34             iEngine.Branch += new ETEngineBase.BranchHandler( ETB_Branch );
       
    35             iEngine.ContextSwitch += new ETEngineBase.ContextSwitchHandler( ETB_ContextSwitch );
       
    36 
       
    37             // Make the initial "unknown" context id stack.
       
    38             SwitchContext( 0 );
       
    39         }
       
    40         #endregion
       
    41 
       
    42         #region API
       
    43         #endregion
       
    44 
       
    45         #region Properties
       
    46         #endregion
       
    47 
       
    48         #region Event handlers
       
    49         private void ETB_ContextSwitch( uint aContextId, string aThreadName )
       
    50         {
       
    51             // Make sure we're using the new current stack
       
    52             SwitchContext( aContextId );
       
    53         }
       
    54 
       
    55         private void ETB_Branch( ETMBranch aBranch )
       
    56         {
       
    57             if ( iCurrentStack != null )
       
    58             {
       
    59                 iCurrentStack.HandleBranch( aBranch );
       
    60             }
       
    61         }
       
    62         #endregion
       
    63 
       
    64         #region Internal methods
       
    65         private void SwitchContext( uint aId )
       
    66         {
       
    67             if ( !iStacks.ContainsKey( aId ) )
       
    68             {
       
    69                 ETBStack stack = new ETBStack( iEngine, aId );
       
    70                 iStacks.Add( aId, stack );
       
    71             }
       
    72             //
       
    73             iCurrentStack = iStacks[ aId ];
       
    74         }
       
    75         #endregion
       
    76 
       
    77         #region Data members
       
    78         private readonly ETEngineBase iEngine;
       
    79         private ETBStack iCurrentStack = null;
       
    80         private Dictionary<uint, ETBStack> iStacks = new Dictionary<uint, ETBStack>();
       
    81         #endregion
       
    82     }
       
    83 }