crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianDebugLib/PluginAPI/Symbol/DbgViewSymbol.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 using System;
       
    18 using System.Collections.Generic;
       
    19 using System.Text;
       
    20 using SymbianStructuresLib.CodeSegments;
       
    21 using SymbianStructuresLib.Debug.Symbols;
       
    22 using SymbianStructuresLib.Debug.Common.FileName;
       
    23 
       
    24 namespace SymbianDebugLib.PluginAPI.Types.Symbol
       
    25 {
       
    26     public abstract class DbgViewSymbol : DbgPluginView, IEnumerable<SymbolCollection>
       
    27     {
       
    28         #region Constructors
       
    29         protected DbgViewSymbol( string aName, DbgPluginEngine aEngine )
       
    30             : base( aName, aEngine )
       
    31         {
       
    32             iPlainTextAPI = new DbgSymbolViewText( this );
       
    33         }
       
    34         #endregion
       
    35 
       
    36         #region Framework API
       
    37         public abstract SymbianStructuresLib.Debug.Symbols.Symbol Lookup( uint aAddress, out SymbolCollection aCollection );
       
    38 
       
    39         public abstract SymbolCollection CollectionByAddress( uint aAddress );
       
    40 
       
    41         public abstract SymbolCollection ActivateAndGetCollection( CodeSegDefinition aCodeSegment );
       
    42 
       
    43         public abstract SymbolCollection this[ CodeSegDefinition aCodeSeg ]
       
    44         {
       
    45             get;
       
    46         }
       
    47 
       
    48         public abstract SymbolCollection this[ PlatformFileName aFileName ]
       
    49         {
       
    50             get;
       
    51         }
       
    52 
       
    53         protected abstract IEnumerator<SymbolCollection> GetEnumeratorSymbolCollection();
       
    54         #endregion
       
    55 
       
    56         #region Properties
       
    57         public SymbianStructuresLib.Debug.Symbols.Symbol this[ uint aAddress ]
       
    58         {
       
    59             get
       
    60             {
       
    61                 SymbolCollection col = null;
       
    62                 return Lookup( aAddress, out col );
       
    63             }
       
    64         }
       
    65 
       
    66         public DbgSymbolViewText PlainText
       
    67         {
       
    68             get { return iPlainTextAPI; }
       
    69         }
       
    70         #endregion
       
    71 
       
    72         #region Internal methods
       
    73         #endregion
       
    74 
       
    75         #region From IEnumerable<SymbolCollection>
       
    76         public IEnumerator<SymbolCollection> GetEnumerator()
       
    77         {
       
    78             return GetEnumeratorSymbolCollection();
       
    79         }
       
    80 
       
    81         System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
       
    82         {
       
    83             return GetEnumeratorSymbolCollection();
       
    84         }
       
    85         #endregion
       
    86 
       
    87         #region Data members
       
    88         private readonly DbgSymbolViewText iPlainTextAPI;
       
    89         #endregion
       
    90     }
       
    91 
       
    92     #region Plain Text API helper
       
    93     public sealed class DbgSymbolViewText
       
    94     {
       
    95         #region Constructors
       
    96         internal DbgSymbolViewText( DbgViewSymbol aView )
       
    97         {
       
    98             iView = aView;
       
    99         }
       
   100         #endregion
       
   101 
       
   102         #region API
       
   103         public bool Lookup( uint aAddress, out uint aStartingAddress, out string aSymbolName )
       
   104         {
       
   105             uint addrEnd = 0;
       
   106             bool found = Lookup( aAddress, out aStartingAddress, out addrEnd, out aSymbolName );
       
   107             return found;
       
   108         }
       
   109 
       
   110         public bool Lookup( uint aAddress, out uint aStartingAddress, out uint aEndingAddress, out string aSymbolName )
       
   111         {
       
   112             aStartingAddress = 0;
       
   113             aEndingAddress = 0;
       
   114             aSymbolName = string.Empty;
       
   115             //
       
   116             SymbianStructuresLib.Debug.Symbols.Symbol sym = iView[ aAddress ];
       
   117             //
       
   118             if ( sym != null )
       
   119             {
       
   120                 aStartingAddress = sym.Address;
       
   121                 aEndingAddress = sym.EndAddress;
       
   122                 aSymbolName = sym.Name;
       
   123             }
       
   124             //
       
   125             return ( sym != null );
       
   126         }
       
   127         #endregion
       
   128 
       
   129         #region Properties
       
   130         public string this[ uint aAddress ]
       
   131         {
       
   132             get
       
   133             {
       
   134                 uint addrStart = 0;
       
   135                 string symName = string.Empty;
       
   136                 bool found = Lookup( aAddress, out addrStart, out symName );
       
   137                 return symName;
       
   138             }
       
   139         }
       
   140         #endregion
       
   141 
       
   142         #region Data members
       
   143         private readonly DbgViewSymbol iView;
       
   144         #endregion
       
   145     }
       
   146     #endregion
       
   147 }