crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianSymbolLib/Plugins/SLPluginMap/Provider/MapSourceProvider.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.Interfaces;
       
    24 using SymbianSymbolLib.SourceManagement.Source;
       
    25 using SymbianSymbolLib.SourceManagement.Provisioning;
       
    26 using SymbianUtils.FileTypes;
       
    27 using SymbianUtils;
       
    28 using SLPluginMap.Utilities;
       
    29 using SLPluginMap.Reader;
       
    30 using SLPluginMap.Reader.RVCT;
       
    31 using SLPluginMap.Reader.GCCE;
       
    32 
       
    33 namespace SLPluginMap.Provider
       
    34 {
       
    35     public class MapSourceProvider : SymSourceProvider
       
    36     {
       
    37         #region Constructors
       
    38         public MapSourceProvider( SymSourceProviderManager aManager )
       
    39             : base( aManager )
       
    40         {
       
    41         }
       
    42         #endregion
       
    43           
       
    44         #region From SymSourceProvider
       
    45         public override SymSourceCollection CreateSources( string aFileName )
       
    46         {
       
    47             // In order to get the host binary name, we remove the map file extension
       
    48             string fileName = aFileName;
       
    49             string extension = Path.GetExtension( fileName ).ToUpper();
       
    50             if ( extension.EndsWith( KMapFileExtension ) )
       
    51             {
       
    52                 string name = fileName.Substring( 0, fileName.Length - extension.Length );
       
    53                 fileName = name;
       
    54             }
       
    55 
       
    56             // A map file source contains just a single collection. We don't know
       
    57             // the device-side file name at this point.
       
    58             SymbolCollection collection = SymbolCollection.NewByHostFileName( base.IdAllocator, fileName );
       
    59             collection.IsRelocatable = true;
       
    60             //
       
    61             SymSource source = new SymSource( aFileName, this, collection );
       
    62             return new SymSourceCollection( source );
       
    63         }
       
    64 
       
    65         public override void ReadSource( SymSource aSource, TSynchronicity aSynchronicity )
       
    66         {
       
    67             // Need to work out if it's a GCCE or RVCT map file.
       
    68             TMapFileType type = MapFileUtils.Type( aSource.FileName );
       
    69             //
       
    70             MapReader reader = null;
       
    71             switch( type )
       
    72             { 
       
    73             case TMapFileType.ETypeRVCT:
       
    74                 reader = new RVCTMapFileReader( aSource, base.Tracer );
       
    75                 break;
       
    76             case TMapFileType.ETypeGCCE:
       
    77                 reader = new GCCEMapFileReader( aSource, base.Tracer );
       
    78                 break;
       
    79             case TMapFileType.ETypeUnknown:
       
    80             default:
       
    81                 throw new NotSupportedException();
       
    82             }
       
    83             //
       
    84             reader.Read( aSynchronicity );
       
    85         }
       
    86 
       
    87         public override SymFileTypeList FileTypes
       
    88         {
       
    89             get
       
    90             {
       
    91                 SymFileTypeList ret = new SymFileTypeList();
       
    92                 //
       
    93                 ret.Add( new SymFileType( ".map", "Map Files" ) );
       
    94                 //
       
    95                 return ret;
       
    96             }
       
    97         }
       
    98 
       
    99         public override string Name
       
   100         {
       
   101             get { return "MAP"; }
       
   102         }
       
   103         #endregion
       
   104 
       
   105         #region Properties
       
   106         #endregion
       
   107 
       
   108         #region Event handlers
       
   109 
       
   110         #endregion
       
   111 
       
   112         #region Internal constants
       
   113         private const string KMapFileExtension = ".MAP";
       
   114         #endregion
       
   115 
       
   116         #region Internal methods
       
   117         #endregion
       
   118 
       
   119         #region Data members
       
   120         #endregion
       
   121     }
       
   122 }