crashanalysercmd/Libraries/Engine/CrashDebuggerLib/Parsers/State/Implementation/Info/StateInfoCpu.cs
changeset 0 818e61de6cd1
equal deleted inserted replaced
-1:000000000000 0:818e61de6cd1
       
     1 /*
       
     2 * Copyright (c) 2004-2008 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 
       
    18 using System;
       
    19 using System.Collections.Generic;
       
    20 using System.Text;
       
    21 using SymbianParserLib.Engine;
       
    22 using SymbianParserLib.BaseStructures;
       
    23 using CrashDebuggerLib.Structures.Cpu;
       
    24 using CrashDebuggerLib.Structures.Register;
       
    25 using SymbianParserLib.Elements;
       
    26 using SymbianParserLib.Enums;
       
    27 using SymbianStructuresLib.Arm.Registers;
       
    28 
       
    29 namespace CrashDebuggerLib.Parsers.State.Implementation
       
    30 {
       
    31     internal class StateInfoCpu : State
       
    32     {
       
    33         #region Constructors
       
    34         public StateInfoCpu( CrashDebuggerParser aParser )
       
    35             : base( aParser )
       
    36         {
       
    37             iInfo = aParser.CrashDebugger.InfoCpu;
       
    38         }
       
    39         #endregion
       
    40 
       
    41         #region API
       
    42         public override void Prepare()
       
    43         {
       
    44             PrepareMandatoryParagraph();
       
    45         }
       
    46 
       
    47         public override void Finalise()
       
    48         {
       
    49 
       
    50         }
       
    51         #endregion
       
    52 
       
    53         #region Properties
       
    54         #endregion
       
    55 
       
    56         #region Internal methods
       
    57         private void SwitchBank( ParserParagraph aPara, ParserLine aLine )
       
    58         {
       
    59         }
       
    60 
       
    61         private void AddRegister( ParserParagraph aPara, ParserField aField, ParserFieldName aFieldName, uint aValue )
       
    62         {
       
    63             RegisterCollection.TType type = (RegisterCollection.TType) aPara.Tag;
       
    64             string regName = aFieldName.Name;
       
    65 
       
    66             // USR registers are a bit tricky since they are largely shared. Only R13 and R14 are
       
    67             // really USR specific.
       
    68             if ( type == RegisterCollection.TType.ETypeUser )
       
    69             {
       
    70                 ArmRegister reg = new ArmRegister( regName, aValue );
       
    71                 //
       
    72                 switch ( reg.RegType )
       
    73                 {
       
    74                 default:
       
    75                     type = RegisterCollection.TType.ETypeCommonBank;
       
    76                     break;
       
    77                 case TArmRegisterType.EArmReg_SP:
       
    78                 case TArmRegisterType.EArmReg_LR:
       
    79                     break;
       
    80                 }
       
    81             }
       
    82 
       
    83             RegisterCollection regCollection = iInfo[ type ];
       
    84             regCollection.Add( regName, aValue );
       
    85         }
       
    86 
       
    87         private void PrepareMandatoryParagraph()
       
    88         {
       
    89             {
       
    90                 ParserParagraph para = CreateParagraph( "MODE_USR:", RegisterCollection.TType.ETypeUser );
       
    91                 //
       
    92                 ParserLine l2 = ParserLine.NewSymFormat( " R0=%08x  R1=%08x  R2=%08x  R3=%08x\r\n" );
       
    93                 ParserLine l3 = ParserLine.NewSymFormat( " R4=%08x  R5=%08x  R6=%08x  R7=%08x\r\n" );
       
    94                 ParserLine l4 = ParserLine.NewSymFormat( " R8=%08x  R9=%08x R10=%08x R11=%08x\r\n" );
       
    95                 ParserLine l5 = ParserLine.NewSymFormat( "R12=%08x R13=%08x R14=%08x R15=%08x\r\n" );
       
    96                 para.Add( l2, l3, l4, l5 );
       
    97                 ParserEngine.Add( para );
       
    98             }
       
    99 
       
   100             {
       
   101                 ParserParagraph para = CreateParagraph( string.Empty, RegisterCollection.TType.ETypeCommonBank );
       
   102                 ParserLine l2 = ParserLine.NewSymFormat( "CPSR=%08x\r\n" );
       
   103                 para.Add( l2 );
       
   104                 ParserEngine.Add( para );
       
   105             }
       
   106 
       
   107             {
       
   108                 ParserParagraph para = CreateParagraph( "MODE_FIQ:", RegisterCollection.TType.ETypeFastInterrupt );
       
   109                 //
       
   110                 ParserLine l2 = ParserLine.NewSymFormat( " R8=%08x  R9=%08x R10=%08x R11=%08x\r\n" );
       
   111                 ParserLine l3 = ParserLine.NewSymFormat( "R12=%08x R13=%08x R14=%08x SPSR=%08x\r\n" );
       
   112                 para.Add( l2, l3 );
       
   113                 ParserEngine.Add( para );
       
   114             }
       
   115 
       
   116             {
       
   117                 ParserParagraph para = CreateParagraph( "MODE_IRQ:", RegisterCollection.TType.ETypeInterrupt );
       
   118                 ParserLine l2 = ParserLine.NewSymFormat( "R13=%08x R14=%08x SPSR=%08x\r\n" );
       
   119                 para.Add( l2 );
       
   120                 ParserEngine.Add( para );
       
   121             }
       
   122 
       
   123             {
       
   124                 ParserParagraph para = CreateParagraph( "MODE_SVC:", RegisterCollection.TType.ETypeSupervisor );
       
   125                 ParserLine l2 = ParserLine.NewSymFormat( "R13=%08x R14=%08x SPSR=%08x\r\n" );
       
   126                 para.Add( l2 );
       
   127                 ParserEngine.Add( para );
       
   128             }
       
   129 
       
   130             {
       
   131                 ParserParagraph para = CreateParagraph( "MODE_ABT:", RegisterCollection.TType.ETypeAbort );
       
   132                 ParserLine l2 = ParserLine.NewSymFormat( "R13=%08x R14=%08x SPSR=%08x\r\n" );
       
   133                 para.Add( l2 );
       
   134                 ParserEngine.Add( para );
       
   135             }
       
   136 
       
   137             {
       
   138                 ParserParagraph para = CreateParagraph( "MODE_UND:", RegisterCollection.TType.ETypeUndefined );
       
   139                 ParserLine l2 = ParserLine.NewSymFormat( "R13=%08x R14=%08x SPSR=%08x\r\n" );
       
   140                 para.Add( l2 );
       
   141                 ParserEngine.Add( para );
       
   142             }
       
   143 
       
   144             {
       
   145                 ParserParagraph para = CreateParagraph( string.Empty, RegisterCollection.TType.ETypeGeneral );
       
   146                 ParserLine l2 = ParserLine.NewSymFormat( "DACR %08x\r\n" );
       
   147                 ParserLine l3 = ParserLine.NewSymFormat( "CAR %08x\r\n" );
       
   148                 ParserLine l4 = ParserLine.NewSymFormat( "MMUID %08x\r\n" );
       
   149                 ParserLine l5 = ParserLine.NewSymFormat( "MMUCR %08x\r\n" );
       
   150                 ParserLine l6 = ParserLine.NewSymFormat( "AUXCR %08x\r\n" );
       
   151                 ParserLine l7 = ParserLine.NewSymFormat( "FPEXC %08x\r\n" );
       
   152                 ParserLine l8 = ParserLine.NewSymFormat( "CTYPE %08x\r\n" );
       
   153                 para.Add( l2, l3, l4, l5, l6, l7, l8 );
       
   154                 ParserEngine.Add( para );
       
   155             }
       
   156         }
       
   157 
       
   158         private ParserParagraph CreateParagraph( string aName, RegisterCollection.TType aType )
       
   159         {
       
   160             RegisterCollection registers = CrashDebugger.InfoCpu[ aType ];
       
   161             //
       
   162             ParserParagraph para = new ParserParagraph( aName );
       
   163             para.Tag = aType;
       
   164             para.SetTargetMethod( this, "AddRegister" );
       
   165             //
       
   166             if ( aName.Length > 0 )
       
   167             {
       
   168                 ParserLine header = ParserLine.New( aName + "\r\n" );
       
   169                 header.SetTargetMethod( this, "SwitchBank" );
       
   170             }
       
   171             return para;
       
   172         }
       
   173         #endregion
       
   174 
       
   175         #region Data members
       
   176         private readonly CpuInfo iInfo;
       
   177         #endregion
       
   178     }
       
   179 }