crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianSymbolLib/Plugins/SLPluginMap/Reader/MapReader.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.IO;
       
    20 using System.Collections.Generic;
       
    21 using System.Text;
       
    22 using SymbianStructuresLib.Debug.Symbols;
       
    23 using SymbianStructuresLib.Debug.Symbols.Utilities;
       
    24 using SymbianSymbolLib.SourceManagement.Source;
       
    25 using SymbianSymbolLib.SourceManagement.Provisioning;
       
    26 using SymbianUtils;
       
    27 using SymbianUtils.Tracer;
       
    28 using SymbianUtils.FileTypes;
       
    29 
       
    30 namespace SLPluginMap.Reader
       
    31 {
       
    32     internal abstract class MapReader : AsyncTextFileReader
       
    33 	{
       
    34         #region Constructors
       
    35         protected MapReader( SymSource aSource, ITracer aTracer )
       
    36         : base( aSource.FileName, aTracer )
       
    37 		{
       
    38             iSource = aSource;
       
    39             iHarmoniser = new SymbolCollectionHarmoniser( Collection );
       
    40 		}
       
    41 		#endregion
       
    42 
       
    43         #region API
       
    44         public void Read( TSynchronicity aSynchronicity )
       
    45         {
       
    46             base.Trace( "[SLPluginMap] Starting to read: {0}", base.FileName );
       
    47             base.StartRead( aSynchronicity );
       
    48         }
       
    49         #endregion
       
    50 
       
    51         #region Properties
       
    52         public uint GlobalBaseAddress
       
    53         {
       
    54             get { return iGlobalBaseAddress; }
       
    55             set { iGlobalBaseAddress = value; } 
       
    56         }
       
    57 
       
    58         protected SymbolCollection Collection
       
    59         {
       
    60             get
       
    61             {
       
    62                 SymbianUtils.SymDebug.SymDebugger.Assert( iSource.Count == 1 );
       
    63                 return iSource[ 0 ];
       
    64             }
       
    65         }
       
    66 		#endregion
       
    67 
       
    68         #region Internal framework API
       
    69         protected void ReportSymbol( Symbol aSymbol )
       
    70         {
       
    71             // Make sure it's tagged as a map file symbol
       
    72             aSymbol.Source = TSymbolSource.ESourceWasMapFile;
       
    73 
       
    74             // Hand off to harmoniser for filing
       
    75             if ( iHarmoniser != null )
       
    76             {
       
    77                 bool saved = iHarmoniser.Add( aSymbol );
       
    78             }
       
    79         }
       
    80         #endregion
       
    81 
       
    82 		#region From AsyncTextReaderBase
       
    83         protected override void HandleReadStarted()
       
    84         {
       
    85             iSource.ReportEvent( SymSource.TEvent.EReadingStarted );
       
    86             Collection.TransactionBegin();
       
    87             base.HandleReadStarted();
       
    88         }
       
    89 
       
    90         protected override void HandleReadCompleted()
       
    91         {
       
    92             try
       
    93             {
       
    94                 iHarmoniser.Dispose();
       
    95                 iHarmoniser = null;
       
    96                 Collection.TransactionEnd();
       
    97                 base.Trace( "[SLPluginMap] Finished read of: {0}", base.FileName );
       
    98                 iSource.ReportEvent( SymSource.TEvent.EReadingComplete );
       
    99             }
       
   100             finally
       
   101             {
       
   102                 base.HandleReadCompleted();
       
   103             }
       
   104         }
       
   105 
       
   106         protected override void OnProgressChanged( int aProgress )
       
   107         {
       
   108             iSource.ReportEvent( SymSource.TEvent.EReadingProgress, aProgress );
       
   109             base.OnProgressChanged( aProgress );
       
   110         }
       
   111         #endregion
       
   112 
       
   113         #region From DisposableObject
       
   114         protected override void CleanupManagedResources()
       
   115         {
       
   116             try
       
   117             {
       
   118                 base.CleanupManagedResources();
       
   119             }
       
   120             finally
       
   121             {
       
   122                 iHarmoniser.Dispose();
       
   123             }
       
   124         }
       
   125 		#endregion
       
   126 
       
   127         #region Data members
       
   128         private readonly SymSource iSource;
       
   129         private SymbolCollectionHarmoniser iHarmoniser;
       
   130         private uint iGlobalBaseAddress = 0;
       
   131 		#endregion
       
   132 	}
       
   133 }