sysperfana/heapanalyser/Libraries/Engine/MemAnalysisLib/Parser/Prefixes/MemAnalysisParserPrefixesBase.cs
changeset 8 15296fd0af4a
equal deleted inserted replaced
7:8e12a575a9b5 8:15296fd0af4a
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 *
       
     5 * Redistribution and use in source and binary forms, with or without
       
     6 * modification, are permitted provided that the following conditions are met:
       
     7 *
       
     8 * - Redistributions of source code must retain the above copyright notice,
       
     9 *   this list of conditions and the following disclaimer.
       
    10 * - Redistributions in binary form must reproduce the above copyright notice,
       
    11 *   this list of conditions and the following disclaimer in the documentation
       
    12 *   and/or other materials provided with the distribution.
       
    13 * - Neither the name of Nokia Corporation nor the names of its contributors
       
    14 *   may be used to endorse or promote products derived from this software
       
    15 *   without specific prior written permission.
       
    16 *
       
    17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
       
    18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
       
    19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
       
    20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
       
    21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
       
    22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
       
    23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
       
    24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
       
    25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
       
    26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
       
    27 * POSSIBILITY OF SUCH DAMAGE.
       
    28 * 
       
    29 * Initial Contributors:
       
    30 * Nokia Corporation - initial contribution.
       
    31 *
       
    32 * Contributors:
       
    33 *
       
    34 * Description: 
       
    35 *
       
    36 */
       
    37 
       
    38 using System;
       
    39 using System.IO;
       
    40 using System.Text;
       
    41 using System.Collections;
       
    42 using System.Collections.Generic;
       
    43 using MemAnalysisLib.MemoryOperations.Functions;
       
    44 using SymbolLib.Generics;
       
    45 using SymbolLib.Engines;
       
    46 using SymbianUtils;
       
    47 
       
    48 namespace MemAnalysisLib.Parser.Prefixes
       
    49 {
       
    50     public class MemAnalysisParserPrefixesBase
       
    51 	{
       
    52 		#region Constructors & destructor
       
    53 		protected MemAnalysisParserPrefixesBase()
       
    54 		{
       
    55 		}
       
    56 		#endregion
       
    57 
       
    58         #region API
       
    59         internal void AssociatePrefixWithFunction( string aPrefix, MemOpFnBase aFunction )
       
    60         {
       
    61             iFunctionPrefixes.Add( aPrefix, aFunction );
       
    62         }
       
    63 
       
    64         internal bool MatchesPrefix( ref string aLine, out MemOpFnBase aFunction )
       
    65         {
       
    66             bool foundMatch = false;
       
    67             aFunction = null;
       
    68             //
       
    69             foreach ( KeyValuePair< string, MemOpFnBase> entry in iFunctionPrefixes )
       
    70             {
       
    71                 int pos = aLine.IndexOf( entry.Key );
       
    72                 //
       
    73                 if ( pos >= 0 )
       
    74                 {
       
    75                     SymbianUtils.PrefixParser.SkipPrefix( entry.Key, ref aLine );
       
    76                     aFunction = entry.Value;
       
    77                     foundMatch = true;
       
    78                     break;
       
    79                 }
       
    80             }
       
    81             //
       
    82             return foundMatch;
       
    83         }
       
    84         #endregion
       
    85 
       
    86         #region Properties
       
    87 		public string HeapSize
       
    88 		{
       
    89 			get { return iHeapSize; }
       
    90 			set { iHeapSize = value; }
       
    91 		}
       
    92 
       
    93         public string ChunkSize
       
    94 		{
       
    95             get { return iChunkSize; }
       
    96             set { iChunkSize = value; }
       
    97 		}
       
    98 
       
    99 		public string CellAddress
       
   100 		{
       
   101 			get { return iCellAddress; }
       
   102 			set { iCellAddress = value; }
       
   103 		}
       
   104 
       
   105 		public string LinkRegister
       
   106 		{
       
   107 			get { return iLinkRegister; }
       
   108 			set { iLinkRegister = value; }
       
   109 		}
       
   110 
       
   111 		public string AllocSize
       
   112 		{
       
   113 			get { return iAllocSize; }
       
   114 			set { iAllocSize = value; }
       
   115 		}
       
   116 
       
   117         public string AllocNumber
       
   118 		{
       
   119             get { return iAllocNumber; }
       
   120             set { iAllocNumber = value; }
       
   121 		}
       
   122 
       
   123 		public string OriginalCellAddress
       
   124 		{
       
   125 			get { return iOriginalCellAddress; }
       
   126 			set { iOriginalCellAddress = value; }
       
   127 		}
       
   128 
       
   129 		public string OriginalCellSize
       
   130 		{
       
   131             get { return iOriginalCellSize; }
       
   132             set { iOriginalCellSize = value; }
       
   133 		}
       
   134 
       
   135         public string OriginalCellAllocNumber
       
   136 		{
       
   137             get { return iOriginalCellAllocNumber; }
       
   138             set { iOriginalCellAllocNumber = value; }
       
   139 		}
       
   140 
       
   141 		public string ReallocMode
       
   142 		{
       
   143 			get { return iReallocMode; }
       
   144 			set { iReallocMode = value; }
       
   145 		}
       
   146 
       
   147         public string VTable
       
   148         {
       
   149             get { return iVTable; }
       
   150             set { iVTable = value; }
       
   151         }
       
   152 
       
   153         public string CellSize
       
   154         {
       
   155             get { return iCellSize; }
       
   156             set { iCellSize = value; }
       
   157         }
       
   158         #endregion
       
   159 
       
   160 		#region Data members
       
   161 		private string iHeapSize = "heapSize: ";
       
   162         private string iChunkSize = "HCS: ";
       
   163 		private string iCellAddress = "cell: ";
       
   164 		private string iLinkRegister = "linkR:";
       
   165 		private string iAllocSize = "allocSize:";
       
   166 		private string iOriginalCellAddress = "oCell:";
       
   167 		private string iOriginalCellSize = "oCSize:";
       
   168         private string iOriginalCellAllocNumber = "oCAN:";
       
   169         private string iReallocMode = "aMode:";
       
   170 		private string iAllocNumber = "allocNum:";
       
   171         private string iVTable = "vTable:";
       
   172         private string iCellSize = "cSize:";
       
   173         private Dictionary<string, MemOpFnBase> iFunctionPrefixes = new Dictionary<string, MemOpFnBase>();
       
   174 		#endregion
       
   175 	}
       
   176 }