crashanalysercmd/Libraries/Engine/CrashDebuggerLib/Structures/UserContextTable/UserContextTableManager.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 System.Reflection;
       
    22 
       
    23 namespace CrashDebuggerLib.Structures.UserContextTable
       
    24 {
       
    25     // <summary>
       
    26     // Return table of pointers to user context tables.
       
    27     // 
       
    28     // Each user context table is an array of UserContextTableEntry objects, one per
       
    29     // ARM CPU register, in the order defined in TArmRegisters.
       
    30     // 
       
    31 	// The master table contains pointers to the user context tables in the order
       
    32 	// defined in TUserContextType.  There are as many user context tables as
       
    33 	// scenarii leading a user thread to switch to privileged mode.
       
    34     // </summary>
       
    35     internal class UserContextTableManager
       
    36     {
       
    37         #region Constructors
       
    38         public UserContextTableManager()
       
    39         {
       
    40             Array vals = Enum.GetValues( typeof( TUserContextType ) );
       
    41             foreach ( object val in vals )
       
    42             {
       
    43                 TUserContextType value = (TUserContextType) val;
       
    44                 iTables.Add( new UserContextTable( value ) );
       
    45             }
       
    46         }
       
    47         #endregion
       
    48 
       
    49         #region API
       
    50         public void Dump()
       
    51         {
       
    52             int i =0;
       
    53             foreach ( UserContextTable table in iTables )
       
    54             {
       
    55                 TUserContextType type = (TUserContextType) i;
       
    56                 string text = table.ToString();
       
    57                 System.Diagnostics.Debug.WriteLine( string.Format( "Table[{0:d2}] = {1} {2}", i, text, type ) );
       
    58                 i++;
       
    59             }
       
    60         }
       
    61         #endregion
       
    62 
       
    63         #region Properties
       
    64         public int Count
       
    65         {
       
    66             get { return iTables.Count; }
       
    67         }
       
    68 
       
    69         public UserContextTable this[ TUserContextType aType ]
       
    70         {
       
    71             get
       
    72             {
       
    73                 UserContextTable ret = null;
       
    74                 //
       
    75                 foreach ( UserContextTable table in iTables )
       
    76                 {
       
    77                     if ( table.Type == aType )
       
    78                     {
       
    79                         ret = table;
       
    80                         break;
       
    81                     }
       
    82                 }
       
    83                 //
       
    84                 if ( ret == null )
       
    85                 {
       
    86                     throw new ArgumentException();
       
    87                 }
       
    88                 //
       
    89                 return ret;
       
    90             }
       
    91         }
       
    92         #endregion
       
    93 
       
    94         #region Internal methods
       
    95         #endregion
       
    96 
       
    97         #region Data members
       
    98         private List<UserContextTable> iTables = new List<UserContextTable>();
       
    99         #endregion
       
   100     }
       
   101 }