crashanalysercmd/Libraries/File Formats/Plugins/CrashXmlPlugin/FileFormat/Segment/Entries/Stacks/CXmlStackEntry.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.Base;
       
    21 using CrashItemLib.Crash.Symbols;
       
    22 using CrashItemLib.Crash.Stacks;
       
    23 using CrashItemLib.Crash.Registers;
       
    24 using CrashXmlPlugin.FileFormat.Node;
       
    25 
       
    26 namespace CrashXmlPlugin.FileFormat.Segment.Entries.Stacks
       
    27 {
       
    28     internal class CXmlStackEntry : CXmlNode
       
    29 	{
       
    30 		#region Constructors
       
    31         public CXmlStackEntry( CIStackEntry aEntry )
       
    32             : base( SegConstants.Stacks_Stack_Data_Entry )
       
    33 		{
       
    34             iEntry = aEntry;
       
    35 		}
       
    36 		#endregion
       
    37 
       
    38         #region From CXmlNode
       
    39         protected override void XmlSerializeContent( CrashXmlPlugin.FileFormat.Document.CXmlDocumentSerializationParameters aParameters )
       
    40         {
       
    41             if ( !iEntry.IsRegisterBasedEntry )
       
    42             {
       
    43                 aParameters.Writer.WriteElementString( SegConstants.CmnAddress, iEntry.Address.ToString( "x8" ) );
       
    44             }
       
    45             //
       
    46             aParameters.Writer.WriteElementString( SegConstants.CmnValue, iEntry.Data.ToString( "x8" ) );
       
    47             aParameters.Writer.WriteElementString( SegConstants.CmnText, iEntry.DataAsString );
       
    48             if ( iEntry.FunctionOffset != 0 )
       
    49             {
       
    50                 aParameters.Writer.WriteElementString( SegConstants.Stacks_Stack_Data_Offset, iEntry.FunctionOffset.ToString( "x4" ) );
       
    51             }
       
    52             //
       
    53             if ( iEntry.IsRegisterBasedEntry )
       
    54             {
       
    55                 // Get the corresponding register from the stack
       
    56                 CIStack stack = iEntry.Stack;
       
    57                 CIRegister register = iEntry.Register;
       
    58                 if ( register != null )
       
    59                 {
       
    60                     CXmlNode.WriteLink( register.Id, SegConstants.Registers, aParameters.Writer );
       
    61                 }
       
    62             }
       
    63 
       
    64             if ( iEntry.Symbol != null )
       
    65             {
       
    66                 CXmlNode.WriteLink( iEntry.Symbol.Id, SegConstants.Symbols, aParameters.Writer );
       
    67             }
       
    68         }
       
    69 
       
    70         protected override void XmlSerializeChildren( CrashXmlPlugin.FileFormat.Document.CXmlDocumentSerializationParameters aParameters )
       
    71         {
       
    72             aParameters.Writer.WriteStartElement( SegConstants.CmnAttributes );
       
    73             //
       
    74             if ( iEntry.IsCurrentStackPointerEntry )
       
    75             {
       
    76                 aParameters.Writer.WriteElementString( SegConstants.Stacks_Stack_Data_Entry_Attributes_CurrentStackPointer, string.Empty );
       
    77             }
       
    78             if ( iEntry.IsAccurate )
       
    79             {
       
    80                 aParameters.Writer.WriteElementString( SegConstants.Stacks_Stack_Data_Entry_Attributes_Accurate, string.Empty );
       
    81             }
       
    82             if ( iEntry.IsRegisterBasedEntry )
       
    83             {
       
    84                 aParameters.Writer.WriteElementString( SegConstants.Stacks_Stack_Data_Entry_Attributes_FromRegister, string.Empty );
       
    85             }
       
    86             else if ( iEntry.IsOutsideCurrentStackRange )
       
    87             {
       
    88                 aParameters.Writer.WriteElementString( SegConstants.Stacks_Stack_Data_Entry_Attributes_OutsideBounds, string.Empty );
       
    89             }
       
    90             //
       
    91             aParameters.Writer.WriteEndElement();
       
    92         }
       
    93         #endregion
       
    94 
       
    95         #region Properties
       
    96         #endregion
       
    97 
       
    98         #region Data members
       
    99         private readonly CIStackEntry iEntry;
       
   100 		#endregion
       
   101 	}
       
   102 }