crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianSymbolLib/Plugins/SLPluginMap/Reader/RVCT/RVCTMapFileReader.cs
changeset 0 818e61de6cd1
child 2 0c91f0baec58
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.IO;
       
    20 using System.Collections.Generic;
       
    21 using System.Text;
       
    22 using System.Text.RegularExpressions;
       
    23 using SymbianStructuresLib.Debug.Symbols;
       
    24 using SymbianSymbolLib.SourceManagement.Source;
       
    25 using SymbianSymbolLib.SourceManagement.Provisioning;
       
    26 using SymbianUtils;
       
    27 using SymbianUtils.FileTypes;
       
    28 using SymbianUtils.Tracer;
       
    29 
       
    30 namespace SLPluginMap.Reader.RVCT
       
    31 {
       
    32     internal class RVCTMapFileReader : MapReader
       
    33 	{
       
    34         #region Delegates & events
       
    35         #endregion
       
    36 
       
    37         #region Constructors
       
    38         public RVCTMapFileReader( SymSource aSource, ITracer aTracer )
       
    39             : base( aSource, aTracer )
       
    40 		{
       
    41             iSymbolParser = new RVCTSymbolCreator( this, base.Collection );
       
    42 		}
       
    43 		#endregion
       
    44 
       
    45         #region API
       
    46         #endregion
       
    47 
       
    48         #region Properties
       
    49 		#endregion
       
    50 
       
    51 		#region From AsyncTextReaderBase
       
    52 		protected override void HandleFilteredLine( string aLine )
       
    53 		{
       
    54 			if	( aLine == "Global Symbols" )
       
    55 			{
       
    56 				iState = TState.EInGlobalRegion;
       
    57 			}
       
    58 			else if ( aLine == "Local Symbols" )
       
    59 			{
       
    60 				iState = TState.EInLocalRegion;
       
    61 			}
       
    62 			else
       
    63 			{
       
    64 				switch( iState )
       
    65 				{
       
    66 				case TState.EInUnknownRegion:
       
    67 					break;
       
    68 				case TState.EInLocalRegion:
       
    69 					ParseLineRegionLocal( aLine );
       
    70 					break;
       
    71 				case TState.EInGlobalRegion:
       
    72 					ParseLineRegionGlobal( aLine );
       
    73 					break;
       
    74 				case TState.EComplete:
       
    75 					System.Diagnostics.Debug.Assert(false);
       
    76 					break;
       
    77 				}
       
    78 			}
       
    79 		}
       
    80 		#endregion
       
    81 
       
    82 		#region Local & global (high level) line handlers
       
    83 		private void ParseLineRegionLocal( string aLine )
       
    84 		{
       
    85 		}
       
    86 
       
    87 		private void ParseLineRegionGlobal( string aLine )
       
    88 		{
       
    89 			switch( iStateGlobal )
       
    90 			{
       
    91 			case TGlobalState.EWaitingForImage_ER_RO_Base:
       
    92                 ParseGlobalBaseAddress( aLine );
       
    93 				break;
       
    94 			case TGlobalState.EProcessingSymbols:
       
    95 				ParseGlobalSymbol( aLine );
       
    96 				break;
       
    97 			default:
       
    98 				break;
       
    99 			}
       
   100 		}
       
   101 		#endregion
       
   102 
       
   103 		#region Global section line parse methods
       
   104 		private void ParseGlobalBaseAddress( string aLine )
       
   105 		{
       
   106             Match m = KGlobalBaseAddressRegEx.Match( aLine );
       
   107             if ( m.Success )
       
   108             {
       
   109                 string value = m.Groups[ 1 ].Value;
       
   110                 base.GlobalBaseAddress = uint.Parse( value, System.Globalization.NumberStyles.HexNumber );
       
   111                 iStateGlobal = TGlobalState.EProcessingSymbols;
       
   112             }
       
   113 		}
       
   114 
       
   115 		private void ParseGlobalSymbol( string aLine )
       
   116 		{
       
   117 			try
       
   118 			{
       
   119                 Symbol sym = iSymbolParser.Parse( aLine );
       
   120                 if ( sym != null )
       
   121                 {
       
   122                     base.ReportSymbol( sym );
       
   123                 }
       
   124 			}
       
   125 			catch( Exception )
       
   126 			{
       
   127 			}
       
   128 		}
       
   129 		#endregion
       
   130 
       
   131 		#region Internal enumerations
       
   132 		private enum TState
       
   133 		{
       
   134 			EInUnknownRegion = 0,
       
   135 			EInLocalRegion,
       
   136 			EInGlobalRegion,
       
   137 			EComplete
       
   138 		}
       
   139 
       
   140 		private enum TGlobalState
       
   141 		{
       
   142 			EWaitingForImage_ER_RO_Base = 0,
       
   143 			EProcessingSymbols
       
   144 		}
       
   145 		#endregion
       
   146 
       
   147         #region Internal constants
       
   148         private readonly static Regex KGlobalBaseAddressRegEx = new Regex(
       
   149               "\\s*Image\\$\\$ER_RO\\$\\$Base\\s+0x([A-Fa-f0-9]{8})\\s"+
       
   150               "+Number",
       
   151              RegexOptions.CultureInvariant
       
   152             | RegexOptions.Compiled
       
   153             );
       
   154         #endregion
       
   155 
       
   156         #region Data members
       
   157         private TState iState = TState.EInUnknownRegion;
       
   158 		private TGlobalState iStateGlobal = TGlobalState.EWaitingForImage_ER_RO_Base;
       
   159         private readonly RVCTSymbolCreator iSymbolParser;
       
   160 		#endregion
       
   161 	}
       
   162 }