crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbolLib/CodeSeg/CodeSegDefinition.cs
changeset 0 818e61de6cd1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbolLib/CodeSeg/CodeSegDefinition.cs	Thu Feb 11 15:50:58 2010 +0200
@@ -0,0 +1,188 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description:
+*
+*/
+using System;
+using System.IO;
+using System.Text;
+using System.Collections.Generic;
+using SymbianUtils;
+using SymbianUtils.Range;
+
+namespace SymbolLib.CodeSegDef
+{
+    public class CodeSegDefinition : CodeSegResolverEntry
+	{
+        #region Enumerations
+        [Flags]
+        public enum TAttributes
+        {
+            EAttributeNone = 0,
+            EAttributeXIP = 1,
+            EAttributeRAM = 2,
+        }
+        #endregion
+
+        #region Constructors & destructor
+        public CodeSegDefinition()
+            : this( string.Empty )
+		{
+		}
+
+		public CodeSegDefinition( string aFileName )
+            : this( aFileName, string.Empty )
+		{
+		}
+
+		public CodeSegDefinition( string aEnvFileName, string aImageFileName )
+            : base( aEnvFileName, aImageFileName )
+        {
+		}
+		#endregion
+
+		#region Constants
+		public const string KMapFileExtension = ".map";
+        public const string KSysBinPath = @"\sys\bin\";
+        public const string KROMBinaryPath = "z:" + KSysBinPath;
+        #endregion
+
+        #region API
+        #endregion
+
+        #region Properties
+        public string MapFileName
+		{
+			get
+			{
+                string ret = string.Empty;
+                //
+                if ( !String.IsNullOrEmpty( EnvironmentFileNameAndPath ) )
+                {
+                    ret = EnvironmentFileNameAndPath + KMapFileExtension;
+                }
+                //
+				return ret;
+			}
+		}
+
+		public bool MapFileExists
+		{
+			get
+			{
+				bool ret = false;
+				//
+				try
+				{
+					string fileName = MapFileName;
+					ret = File.Exists( fileName );
+				}
+				finally
+				{
+				}
+				//
+				return ret;
+			}
+		}
+
+        public bool AddressValid
+        {
+            get
+            {
+                bool good = iRange.IsValid;
+                return good;
+            }
+        }
+
+		public uint AddressStart
+		{
+			get { return (uint) iRange.Min; }
+			set
+            { 
+                iRange.UpdateMin( value );
+                UpdateAttributes();
+            }
+		}
+
+        public uint AddressEnd
+		{
+            get { return (uint) iRange.Max; }
+            set 
+            { 
+                iRange.UpdateMax( value );
+                UpdateAttributes();
+            }
+        }
+
+        public uint Checksum
+        {
+            get { return iChecksum; }
+            set { iChecksum = value; }
+        }
+
+        public AddressRange AddressRange
+        {
+            get { return iRange; }
+        }
+
+        public TAttributes Attributes
+        {
+            get { return iAttributes; }
+        }
+		#endregion
+
+        #region From System.Object
+		public override string ToString()
+		{
+            StringBuilder ret = new StringBuilder();
+            //
+            ret.Append( iRange.ToString() );
+            ret.Append( " " );
+            ret.Append( base.ToString() );
+            //
+            return ret.ToString();
+		}
+        #endregion
+
+        #region Internal methods
+        private void UpdateAttributes()
+        {
+            // Remove XIP/RAM attrib before we work out the type...
+            iAttributes &= ~TAttributes.EAttributeRAM;
+            iAttributes &= ~TAttributes.EAttributeXIP;
+
+            MemoryModel.TMemoryModelType type = MemoryModel.TypeByAddress( AddressStart );
+            if ( type != MemoryModel.TMemoryModelType.EMemoryModelUnknown )
+            {
+                MemoryModel.TMemoryModelRegion region = MemoryModel.RegionByAddress( AddressStart, type );
+                //
+                if ( region == MemoryModel.TMemoryModelRegion.EMemoryModelRegionROM )
+                {
+                    iAttributes |= TAttributes.EAttributeXIP;
+                }
+                else if ( region == MemoryModel.TMemoryModelRegion.EMemoryModelRegionRAMLoadedCode )
+                {
+                    iAttributes |= TAttributes.EAttributeRAM;
+                }
+            }
+        }
+		#endregion
+
+		#region Data members
+        private readonly AddressRange iRange = new AddressRange();
+        private uint iChecksum = 0;
+        private TAttributes iAttributes = TAttributes.EAttributeNone;
+		#endregion
+	}
+}