crashanalysercmd/Libraries/Engine/CrashItemLib/Engine/ProblemDetectors/Stack/CIPDStackBoundaryValidator.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.Text;
       
    19 using System.Collections.Generic;
       
    20 using CrashItemLib.Crash.Container;
       
    21 using CrashItemLib.Crash.Stacks;
       
    22 using CrashItemLib.Crash.Registers;
       
    23 using CrashItemLib.Crash.Base;
       
    24 using CrashItemLib.Crash.Messages;
       
    25 using CrashItemLib.Crash.Summarisable;
       
    26 using SymbianStructuresLib.Arm.Registers;
       
    27 using SymbianUtils.Range;
       
    28 
       
    29 namespace CrashItemLib.Engine.ProblemDetectors.Stack
       
    30 {
       
    31     internal class CIPDStackBoundaryValidator : CIProblemDetector
       
    32     {
       
    33         #region Constructors
       
    34         public CIPDStackBoundaryValidator()
       
    35 		{
       
    36         }
       
    37 		#endregion
       
    38 
       
    39         #region From CIProblemDetector
       
    40         public override void Check( CIContainer aContainer )
       
    41         {
       
    42             CISummarisableEntityList list = aContainer.Summaries;
       
    43             foreach ( CISummarisableEntity entry in list )
       
    44             {
       
    45                 bool stackAvailable = entry.IsAvailable( CISummarisableEntity.TElement.EElementStack );
       
    46                 bool regsAvailable = entry.IsAvailable( CISummarisableEntity.TElement.EElementRegisters );
       
    47                 //
       
    48                 if ( stackAvailable && regsAvailable )
       
    49                 {
       
    50                     CIStack stack = entry.Stack;
       
    51                     bool pointerAvailable = stack.Registers.Contains( TArmRegisterType.EArmReg_SP );
       
    52                     //
       
    53                     if ( pointerAvailable )
       
    54                     {
       
    55                         CIRegister regSP = stack.Pointer;
       
    56                         AddressRange stackRange = entry.Stack.Range;
       
    57                         //
       
    58                         if ( stack.IsOverflow )
       
    59                         {
       
    60                             base.CreateError( aContainer, stack, 
       
    61                                 LibResources.CIPDStackBoundaryValidator_StackOverflow_Title,
       
    62                                 string.Format( LibResources.CIPDStackBoundaryValidator_StackOverflow_Description, base.CreateIdentifierText( entry ) )
       
    63                                 );
       
    64                         }
       
    65                         else if ( !stackRange.Contains( regSP ) )
       
    66                         {
       
    67                             base.CreateError( aContainer, stack,
       
    68                                 LibResources.CIPDStackBoundaryValidator_StackUnderflow_Title,
       
    69                                 string.Format( LibResources.CIPDStackBoundaryValidator_StackUnderflow_Description, base.CreateIdentifierText( entry ) )
       
    70                                 );
       
    71                         }
       
    72                     }
       
    73                 }
       
    74             }
       
    75         }
       
    76         #endregion
       
    77 
       
    78         #region Properties
       
    79         #endregion
       
    80 
       
    81         #region Internal methods
       
    82         #endregion
       
    83 
       
    84         #region From System.Object
       
    85         #endregion
       
    86 
       
    87         #region Data members
       
    88 		#endregion
       
    89     }
       
    90 }