crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianStackLib/StackElement.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;
       
    19 using System.Text;
       
    20 using SymbolLib;
       
    21 
       
    22 namespace StackLib
       
    23 {
       
    24 	public class StackElement
       
    25 	{
       
    26 		public class StackElementDescriptorInfo
       
    27 		{
       
    28 			#region Public enumerations
       
    29 			public enum TType
       
    30 			{
       
    31 				EBuf
       
    32 			}
       
    33 			#endregion
       
    34 
       
    35 			#region API
       
    36 			public string AsString( out int aNumberOfLines, bool aPostfixInfo )
       
    37 			{
       
    38 				aNumberOfLines = 1;
       
    39 				StringBuilder sb = new StringBuilder();
       
    40 				//
       
    41 				int count = iDescriptorCharacters.Count;
       
    42 				for(int i=0; i<count && sb.Length < iLength; i++ )
       
    43 				{
       
    44 					char character = (char) iDescriptorCharacters[i];
       
    45 
       
    46 					if	( character < ' ' || character > '~' )
       
    47 					{
       
    48 						sb.Append( KReplacementForUnprintableCharacters );
       
    49 					}
       
    50 					else
       
    51 					{
       
    52 						sb.Append( character );
       
    53 					}
       
    54 
       
    55 					if	( sb.Length > 0 && ((sb.Length % KNumberOfCharactersPerLine ) == 0))
       
    56 					{
       
    57 						sb.Append( System.Environment.NewLine );
       
    58 						++aNumberOfLines;
       
    59 					}
       
    60 				}
       
    61 
       
    62 				if	( aPostfixInfo )
       
    63 				{
       
    64 					string header = System.Environment.NewLine  + System.Environment.NewLine + "[Len: " + iLength.ToString() + ", max: " + iMaxLength.ToString() + "]";
       
    65 					aNumberOfLines += 2;
       
    66 					sb.Append( header );
       
    67 				}
       
    68 				//
       
    69 				return sb.ToString();
       
    70 			}
       
    71 			#endregion
       
    72 
       
    73 			#region Internal constants
       
    74 			private const int KNumberOfCharactersPerLine = 64;
       
    75 			private const char KReplacementForUnprintableCharacters = '.';
       
    76 			#endregion
       
    77 
       
    78 			#region Data members
       
    79 			public TType iType;
       
    80 			public long iLength;
       
    81 			public long iMaxLength;
       
    82 			public int iByteWidth = 1;
       
    83 			public ArrayList iDescriptorCharacters = new ArrayList( 100 );
       
    84 			#endregion
       
    85 		}
       
    86 
       
    87 		#region Constructors & destructor
       
    88 		public StackElement( long aAddress, long aData, string aCharacterisedData )
       
    89 		{
       
    90 			iAddress = aAddress;
       
    91 			iData = aData;
       
    92 			iCharacterisedData = aCharacterisedData;
       
    93 			iSymbol = null;
       
    94 		}
       
    95 		#endregion
       
    96 
       
    97 		#region Properties
       
    98 		public long Address
       
    99 		{
       
   100 			get { return iAddress; }
       
   101 			set { iAddress = value; }
       
   102 		}
       
   103 
       
   104 		public long Data
       
   105 		{
       
   106 			get { return iData; }
       
   107 			set { iData = value; }
       
   108 		}
       
   109 
       
   110 		public string CharacterisedData
       
   111 		{
       
   112 			get { return iCharacterisedData; }
       
   113 		}
       
   114 
       
   115 		public GenericSymbol Symbol
       
   116 		{
       
   117 			get { return iSymbol; }
       
   118 			set { iSymbol = value; }
       
   119 		}
       
   120 
       
   121 		public bool IsDescriptor
       
   122 		{
       
   123 			get { return iDescriptorInfo != null; }
       
   124 		}
       
   125 
       
   126 		public StackElementDescriptorInfo DescriptorInfo
       
   127 		{
       
   128 			get { return iDescriptorInfo; }
       
   129 			set { iDescriptorInfo = value; }
       
   130 		}
       
   131 		#endregion
       
   132 
       
   133 		#region From System.Object
       
   134 		public override string ToString()
       
   135 		{
       
   136 			string fixedElement = "= " + iData.ToString("x8") + " " + iCharacterisedData + " ";
       
   137 			if	(iSymbol != null)
       
   138 			{
       
   139 				return fixedElement + iSymbol.Symbol;
       
   140 			}
       
   141 			return fixedElement;
       
   142 		}
       
   143 		#endregion
       
   144 	
       
   145 		#region Data members
       
   146 		private GenericSymbol iSymbol;
       
   147 		private long iAddress;
       
   148 		private long iData;
       
   149 		private string iCharacterisedData;
       
   150 		private StackElementDescriptorInfo iDescriptorInfo = null;
       
   151 		#endregion
       
   152 	}
       
   153 }