crashanalysercmd/Libraries/File Formats/Plugins/CrashInfoFilePlugin/FileFormat/CCrashInfoDataBlock.cs
changeset 0 818e61de6cd1
child 2 0c91f0baec58
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 * The class CCrashInfoDataBlock is part of CrashAnalyser CrashInfoFile plugin.
       
    16 * Provides reading methods, container and output methods for all data in a single
       
    17 * datablock of crashinfo file, corresponding to one crash. Complete crashinfo file 
       
    18 * may contain one or more datablock.
       
    19 * 
       
    20 */
       
    21 using System;
       
    22 using System.Collections.Generic;
       
    23 using System.Text;
       
    24 using CrashItemLib.Crash.Container;
       
    25 using CrashItemLib.Crash.Base;
       
    26 using CrashItemLib.Crash.Processes;
       
    27 using CrashItemLib.Crash.InfoSW;
       
    28 using CrashItemLib.Crash.Utils;
       
    29 using System.Globalization;
       
    30 using CrashItemLib.Crash.Threads;
       
    31 using CrashItemLib.Crash.Registers;
       
    32 using CrashItemLib.Crash.Symbols;
       
    33 using CrashItemLib.Crash.CodeSegs;
       
    34 using CrashItemLib.Crash.Memory;
       
    35 using CrashItemLib.Crash.Summarisable;
       
    36 using CrashItemLib.Crash.InfoHW;
       
    37 using CrashItemLib.Crash.Telephony;
       
    38 using CrashItemLib.Crash.Header;
       
    39 using CrashItemLib.Crash.Reports;
       
    40 using CrashItemLib.Crash.Stacks;
       
    41 using CrashInfoFilePlugin.FileFormat;
       
    42 using CrashItemLib.Crash.Source;
       
    43 using CrashItemLib.Crash.Events;
       
    44 using CrashItemLib.Crash.Messages;
       
    45 using System.IO;
       
    46 using CrashItemLib.Crash.Traces;
       
    47 using SymbianStructuresLib.Debug.Trace;
       
    48 using CrashItemLib.Crash.InfoEnvironment;
       
    49 
       
    50 namespace CrashInfoFilePlugin.PluginImplementations.FileFormat
       
    51 {
       
    52     internal class CCrashInfoDataBlock
       
    53     {
       
    54         #region Constructors
       
    55         public CCrashInfoDataBlock()
       
    56            
       
    57         {
       
    58         }
       
    59 
       
    60         #endregion
       
    61 
       
    62         #region Adding data content
       
    63         /** Add timestamp and uptime */
       
    64         internal void AddHeader(CIContainer aContainer)
       
    65         {
       
    66             CIHeader header = (CIHeader) aContainer.ChildByType( typeof( CIHeader ) );
       
    67             if (header != null)
       
    68             {
       
    69                 //Timestamp
       
    70                 DateTime timeStamp = header.CrashTime;
       
    71                 String date = timeStamp.ToString("yyyyMMdd", DateTimeFormatInfo.InvariantInfo);
       
    72                 int hour = timeStamp.Hour;
       
    73                 int minute = timeStamp.Minute;
       
    74                 int second = timeStamp.Second;
       
    75                 iTimeStampText = date + hour.ToString().PadLeft(2, '0') + minute.ToString().PadLeft(2, '0') + second.ToString().PadLeft(2, '0');
       
    76 
       
    77                 //UpTime
       
    78                 iUptime = header.UpTime.TotalSeconds;
       
    79             }
       
    80         }
       
    81         /** Add romid, timestamp, platform, language and sw version */
       
    82         internal void AddSWInfos(CIContainer aContainer)
       
    83         {
       
    84             CIInfoSW info = (CIInfoSW) aContainer.ChildByType( typeof( CIInfoSW ) );
       
    85             if (info != null)
       
    86             {
       
    87                 //RomID
       
    88                 if (info.ImageCheckSum != 0)
       
    89                 {
       
    90                     iRomId = info.ImageCheckSum;                    
       
    91                 }
       
    92                 //Platform
       
    93                 iPlatform = info.Platform;
       
    94                 
       
    95                 //Language
       
    96                 iLanguage = info.Language;             
       
    97 
       
    98                 //Version                
       
    99                 const string KInfoSW_Version_Runtime    = "Runtime Version";
       
   100                 const string KInfoSW_Version_Variant    = "Variant Version";
       
   101                 const string KInfoSW_Version_S60        = "S60 Version";      
       
   102                 foreach ( CIVersionInfo version in info )
       
   103                 {
       
   104                     if (version.IsValid && version.Name == KInfoSW_Version_Runtime)
       
   105                     {                        
       
   106                         iSWVersion = version.Value;                            
       
   107                     }
       
   108                     if (version.IsValid && version.Name == KInfoSW_Version_Variant)
       
   109                     {                        
       
   110                         iVariantVersion =  version.Value;                            
       
   111                     }
       
   112                     if (version.IsValid && version.Name == KInfoSW_Version_S60)
       
   113                     {                        
       
   114                         iS60Version =  version.Value;                            
       
   115                     }
       
   116                 }          
       
   117  
       
   118                 //Timestamp
       
   119                 DateTime timeStamp = info.ImageTimeStamp;
       
   120                 String date = timeStamp.ToString("yyyyMMdd", DateTimeFormatInfo.InvariantInfo);
       
   121                 int hour = timeStamp.Hour;
       
   122                 int minute = timeStamp.Minute;
       
   123                 int second = timeStamp.Second;
       
   124                 iTimeStampText = date + hour.ToString().PadLeft(2, '0') + minute.ToString().PadLeft(2, '0') + second.ToString().PadLeft(2, '0');
       
   125                            
       
   126             }
       
   127         }
       
   128 
       
   129           
       
   130 
       
   131         internal void AddThreadAndExitInfo(CIContainer aContainer)
       
   132         {
       
   133 
       
   134             CIElementList<CIThread> threads = aContainer.ChildrenByType<CIThread>( CIElement.TChildSearchType.EEntireHierarchy );
       
   135             if (threads.Count > 1)
       
   136             {
       
   137                 System.Console.WriteLine("Warning: CrashInfoFilePlugin found multiple threads. CI file output can handle only one thread!");
       
   138             }
       
   139             foreach (CIThread thread in threads)
       
   140             {
       
   141                 iPanicCategory = thread.ExitInfo.Category;
       
   142                 iPanicID = thread.ExitInfo.Reason;
       
   143 
       
   144                 iCrashedModuleName = thread.FullName;
       
   145             }
       
   146 
       
   147         }
       
   148 
       
   149         internal void AddPanicedProcess(CIContainer aContainer)
       
   150         {
       
   151             CIElementList<CIProcess> processes = aContainer.ChildrenByType<CIProcess>(CIElement.TChildSearchType.EEntireHierarchy);
       
   152             if (processes.Count > 1)
       
   153             {
       
   154                 System.Console.WriteLine("Warning: CrashInfoFilePlugin found multiple processes. CI file output can handle only one process!");
       
   155             }
       
   156             foreach (CIProcess process in processes)
       
   157             {
       
   158                  iProcess = process.Name;
       
   159                  iUID = process.Uids.MostSignificant;
       
   160             }
       
   161 
       
   162         }
       
   163 
       
   164         internal void AddRegisterLists(CIContainer aContainer)
       
   165         {
       
   166             CIElementList<CIRegisterListCollection> regListCols = aContainer.ChildrenByType<CIRegisterListCollection>(CIElement.TChildSearchType.EEntireHierarchy);
       
   167             foreach (CIRegisterListCollection regListCol in regListCols)
       
   168             {
       
   169                 foreach (CIRegisterList regList in regListCol)
       
   170                 {                                      
       
   171                     iRegStorage.ReadRegisterData(regList);     
       
   172                 }
       
   173             }
       
   174 
       
   175         }
       
   176 
       
   177         internal void AddStacks(CIContainer aContainer)
       
   178         {
       
   179             CIElementList<CIStack> stacks = aContainer.ChildrenByType<CIStack>(CIElement.TChildSearchType.EEntireHierarchy);
       
   180             foreach (CIStack stack in stacks)
       
   181             {
       
   182                 CCrashInfoCallStack callStack = new CCrashInfoCallStack();
       
   183                 callStack.Read(stack);
       
   184                 callStack.CleanStack();
       
   185                 iCallStacks.Add(callStack);
       
   186 
       
   187             }
       
   188         }
       
   189 
       
   190         internal void AddCodeSegments(CIContainer aContainer)
       
   191         {
       
   192             // Get the code segments
       
   193             CIElementList<CICodeSeg> codeSegs = aContainer.ChildrenByType<CICodeSeg>(CIElement.TChildSearchType.EEntireHierarchy);
       
   194 
       
   195             // Sort them
       
   196             Comparison<CICodeSeg> comparer = delegate(CICodeSeg aLeft, CICodeSeg aRight)
       
   197             {
       
   198                 return string.Compare(aLeft.Name, aRight.Name, true);
       
   199             };
       
   200             codeSegs.Sort(comparer);
       
   201 
       
   202             // List them
       
   203             foreach (CICodeSeg codeSeg in codeSegs)
       
   204             {
       
   205                 uint start = codeSeg.Range.Min;
       
   206                 uint end = codeSeg.Range.Max;
       
   207                 string name = codeSeg.Name;
       
   208 
       
   209                 CCrashInfoCodeSegItem ciCodeSeg = new CCrashInfoCodeSegItem(start, end, name);
       
   210                 iCodeSegs.Add(ciCodeSeg);
       
   211             }
       
   212         }
       
   213 
       
   214         internal void AddMemoryInfo(CIContainer aContainer)
       
   215         {
       
   216             CIElementList<CIMemoryInfo> list = aContainer.ChildrenByType<CIMemoryInfo>(CIElement.TChildSearchType.EEntireHierarchy);
       
   217             foreach ( CIMemoryInfo info in list )
       
   218             {                
       
   219                 if ( info.Type == CIMemoryInfo.TType.ETypeRAM )
       
   220                 {
       
   221                     iFreeMomery = info.Free;        
       
   222                 }
       
   223                 if (info.Type == CIMemoryInfo.TType.ETypeDrive)
       
   224                 {
       
   225                     iDiskInfo = info.Free;
       
   226                 }
       
   227             }
       
   228         }
       
   229 
       
   230         internal void AddHWInfo(CIContainer aContainer)
       
   231         {
       
   232             CIInfoHW info = (CIInfoHW)aContainer.ChildByType(typeof(CIInfoHW));
       
   233             if (info != null)
       
   234             {
       
   235                 iProductType = info.ProductType; 
       
   236                 iProductCode = info.ProductCode.Trim();
       
   237                 iSerialNumber = info.SerialNumber.Trim();             
       
   238             }           
       
   239         }
       
   240 
       
   241         internal void AddTelephony(CIContainer aContainer)
       
   242         {
       
   243             CITelephony info = (CITelephony)aContainer.ChildByType(typeof(CITelephony));
       
   244             if (info != null)
       
   245             {
       
   246                 iPhoneNumber = info.PhoneNumber;
       
   247                 iImei = info.IMEI;
       
   248                 iImsi = info.IMSI;
       
   249 
       
   250                 CITelephonyNetworkInfo networkInfo = info.NetworkInfo;
       
   251 
       
   252                 iNetworkCountry = networkInfo.Country;
       
   253                 iNetworkIdentity = networkInfo.Identity;
       
   254                 iNetworkCell = networkInfo.CellId;
       
   255                 iLocInfo = networkInfo.CGI;
       
   256 
       
   257             }
       
   258 
       
   259         }
       
   260 
       
   261         internal void AddEnvInfo(CIContainer aContainer)
       
   262         {
       
   263             CIInfoEnvironment info = (CIInfoEnvironment)aContainer.ChildByType(typeof(CIInfoEnvironment));
       
   264             if (info != null)
       
   265             {
       
   266                 iTestSet = info.TestSet;
       
   267             }
       
   268 
       
   269         }
       
   270 
       
   271         internal void AddReportParameters(CIContainer aContainer)
       
   272         {
       
   273             CIReportInfo report = (CIReportInfo)aContainer.ChildByType(typeof(CIReportInfo));
       
   274             if (report != null)
       
   275             {
       
   276                 iReportType = report.Type;
       
   277                 if (iReportType != string.Empty)
       
   278                 {
       
   279                     iFileType = CrashInfoConsts.MobileCrashFileType.ETypeCrashAPIReport;
       
   280                 }
       
   281                 
       
   282 
       
   283                 iReportCategory = report.Category;
       
   284                 iReportOK = report.CountSuccess;
       
   285                 iReportFail = report.CountFail;
       
   286                 IEnumerator<CIReportParameter> parameters = report.GetEnumerator();
       
   287                 if (parameters.MoveNext()) //has first parameter
       
   288                 {
       
   289                     iReportParamName1 = parameters.Current.Name;
       
   290                     iReportParamValue1 = parameters.Current.Value;
       
   291 
       
   292                     if (parameters.MoveNext()) //has second parameter
       
   293                     {
       
   294                         iReportParamName2 = parameters.Current.Name;
       
   295                         iReportParamValue2 = parameters.Current.Value;
       
   296                         if (parameters.MoveNext())
       
   297                         {
       
   298                             iReportParamName3 = parameters.Current.Name;
       
   299                             iReportParamValue3 = parameters.Current.Value;
       
   300                         }
       
   301                     }
       
   302                 }
       
   303                    
       
   304                 iReportComments = report.Comments;
       
   305                 
       
   306             }
       
   307             
       
   308         }
       
   309 
       
   310         internal void AddMessages(CIContainer container)
       
   311         {
       
   312             foreach (CIMessage message in container.Messages)
       
   313             {
       
   314                 if (message.Title == "Miscellaneous Information")
       
   315                 {
       
   316 
       
   317                     if (message.Description.Trim() == CrashInfoConsts.KRegistrationMiscInfo)
       
   318                     {
       
   319                         iFileType = CrashInfoConsts.MobileCrashFileType.ETypeRegistrationMessage;
       
   320                     }
       
   321                     if (message.Description.Trim() == CrashInfoConsts.KAliveTimeMiscInfo)
       
   322                     {
       
   323                         iFileType = CrashInfoConsts.MobileCrashFileType.ETypeAliveMessage;
       
   324                     }
       
   325                 }
       
   326             }
       
   327         }
       
   328 
       
   329         internal void AddCrashHash(CIContainer aContainer)
       
   330         {
       
   331             //hash is only calculated for normal crashes - registrations and reports are omitted
       
   332             if (iFileType == CrashInfoConsts.MobileCrashFileType.ETypeBasicCrash)
       
   333             {
       
   334                 CISummarisableEntity primarySummary = aContainer.PrimarySummary;
       
   335                 if (primarySummary != null)
       
   336                 {
       
   337                     CCrashInfoHashBuilder.TConfiguration config = CCrashInfoHashBuilder.TConfiguration.EDefault;
       
   338                     try //CCrashInfoHashBuilder.New throws an exception if there's not enough data for hash creation
       
   339                     {
       
   340                         CCrashInfoHashBuilder builder = CCrashInfoHashBuilder.New(config, primarySummary);
       
   341                         iHash = builder.GetHash();
       
   342                     }
       
   343                     catch (Exception e)
       
   344                     {
       
   345                         //Not enough data -> no hash and no grouping
       
   346                     }
       
   347                 }
       
   348             }
       
   349         }
       
   350 
       
   351         internal void AddFileNames(CIContainer aContainer, string aArchivedFileName)
       
   352      
       
   353         {
       
   354             iBinFilename = aArchivedFileName;
       
   355 
       
   356             CISource source = aContainer.Source;
       
   357             string binFileOriginalName = source.MasterFileName;
       
   358                         
       
   359             foreach (string filename in aContainer.FileNames)
       
   360             {
       
   361                 if (filename != binFileOriginalName) //Since bin file name is stored separately, remove it from this list
       
   362                 {
       
   363                     iSymbolFiles.Add(filename);
       
   364                 }
       
   365             }          
       
   366 
       
   367         }
       
   368         internal void AddEventlog(CIContainer aContainer)
       
   369         {
       
   370             CIEventList events = aContainer.Events;
       
   371             foreach (CIEvent ev in events)
       
   372             {
       
   373 
       
   374                 iEventlog.Add(ev.Value.ToString());
       
   375             }
       
   376         }
       
   377 
       
   378 
       
   379         internal void AddOstTraces(CIContainer aContainer)
       
   380         {
       
   381             CITraceData traceData = aContainer.Traces;
       
   382             //
       
   383             if (traceData != null && traceData.Lines.Length > 0)
       
   384             {
       
   385                 foreach (CITrace ciTrace in traceData)
       
   386                 {
       
   387                     System.Text.StringBuilder line = new System.Text.StringBuilder();                
       
   388                    
       
   389                     TraceLine trace = ciTrace;
       
   390 
       
   391                     // Type
       
   392                     string type = string.Empty;
       
   393                     switch (trace.Type)
       
   394                     {
       
   395                         case TraceLine.TType.ETypeBinary:
       
   396                             type = "Bin";
       
   397                             break;
       
   398                         case TraceLine.TType.ETypeRaw:
       
   399                             type = "Raw";
       
   400                             break;
       
   401                         case TraceLine.TType.ETypeText:
       
   402                             type = "Text";
       
   403                             break;
       
   404                         default:
       
   405                             type = "Unknown";
       
   406                             break;
       
   407                     }
       
   408                     if (string.IsNullOrEmpty(type) == false)
       
   409                     {
       
   410                         line.Append(type);
       
   411                     }
       
   412 
       
   413                     // Context id
       
   414                     if (trace.ContextId != 0)
       
   415                     {
       
   416                         line.Append(" " + "0x" + trace.ContextId.ToString("x8"));
       
   417                     }
       
   418 
       
   419                     // Time stamp
       
   420                     line.Append(" " + trace.TimeStamp.ToString());
       
   421 
       
   422                     // Prefix
       
   423                     string prefix = trace.Prefix;
       
   424                     if (string.IsNullOrEmpty(prefix) == false)
       
   425                     {
       
   426                         line.Append(" " + prefix);
       
   427                     }
       
   428 
       
   429                     // Suffix
       
   430                     string suffix = trace.Suffix;
       
   431                     if (string.IsNullOrEmpty(suffix) == false)
       
   432                     {
       
   433                         line.Append(" " + suffix);
       
   434                     }
       
   435 
       
   436                     if (trace.HasIdentifier)
       
   437                     {
       
   438                         // Component/group/id triplet
       
   439                         TraceIdentifier identifier = trace.Identifier;
       
   440                         line.Append(" C:" + "0x" + identifier.Component.ToString("x8"));
       
   441                         line.Append(" G:" + identifier.Group.ToString());
       
   442                         line.Append(" I:" + identifier.Id.ToString());
       
   443                         // File & line
       
   444                         TraceLocation location = identifier.Location;
       
   445                         //
       
   446                         string file = location.File;
       
   447                         string lineNumber = location.Line.ToString();
       
   448                         //
       
   449                         if (string.IsNullOrEmpty(file) == false && string.IsNullOrEmpty(lineNumber) == false)
       
   450                         {
       
   451                             line.Append(" " +file);
       
   452                             line.Append(":" + lineNumber);
       
   453                         }
       
   454                     }
       
   455 
       
   456                     // Payload
       
   457                     string payload = trace.Payload;
       
   458                     line.Append(" " + payload);
       
   459                     iOstTraces.Add(line.ToString());
       
   460                 }
       
   461             }
       
   462         }
       
   463 
       
   464         #endregion
       
   465 
       
   466         #region Data writers
       
   467 
       
   468         internal void WriteTimeStamp(System.IO.StreamWriter aOutput)
       
   469         {
       
   470             CCrashInfoFileUtilities.WriteOutputTags(iTimeStampText, CrashInfoConsts.Ktimestamp, aOutput);          
       
   471         }        
       
   472 
       
   473         internal void WriteRomID(System.IO.StreamWriter aOutput)
       
   474         {
       
   475             CCrashInfoFileUtilities.WriteOutputTags(iRomId, CrashInfoConsts.Kromid, aOutput); 
       
   476         }
       
   477 
       
   478         internal void WriteSWVersion(System.IO.StreamWriter aOutput)
       
   479         {
       
   480             string version = iPlatform + CrashInfoConsts.KSeparator + iSWVersion;
       
   481             CCrashInfoFileUtilities.WriteOutputTags(version, CrashInfoConsts.Ksw_version, aOutput);
       
   482         }
       
   483 
       
   484         internal void WriteVariantID(System.IO.StreamWriter aOutput)
       
   485         {
       
   486             //variant id is not really used - dummy value needs to be written for dbmover        
       
   487             CCrashInfoFileUtilities.WriteOutputTags("12345678", CrashInfoConsts.Kvariant_id, aOutput); 
       
   488         }
       
   489 
       
   490         internal void WriteHWVersion(System.IO.StreamWriter aOutput)
       
   491         {
       
   492             //HW version is not really used - dummy value needs to be written for dbmover
       
   493            CCrashInfoFileUtilities.WriteOutputTags("NotFound", CrashInfoConsts.Khw_version, aOutput);           
       
   494         }
       
   495 
       
   496         internal void WritePanicID(System.IO.StreamWriter aOutput)
       
   497         {
       
   498             CCrashInfoFileUtilities.WriteOutputTags(iPanicID, CrashInfoConsts.Kpanic_id, aOutput);
       
   499         }
       
   500 
       
   501         internal void WritePanicCategory(System.IO.StreamWriter aOutput)
       
   502         {
       
   503             CCrashInfoFileUtilities.WriteOutputTags(iPanicCategory, CrashInfoConsts.Kpanic_category, aOutput);
       
   504         }
       
   505 
       
   506         internal void WriteLanguage(System.IO.StreamWriter aOutput)
       
   507         {
       
   508             CCrashInfoFileUtilities.WriteOutputTags(iLanguage, CrashInfoConsts.Klanguage, aOutput);
       
   509         }
       
   510         
       
   511         internal void WritePanicedProcess(System.IO.StreamWriter aOutput)
       
   512         {
       
   513             CCrashInfoFileUtilities.WriteOutputTags(iProcess, CrashInfoConsts.Kpanicked_process, aOutput);
       
   514         }
       
   515 
       
   516         internal void WriteProgramCounter(System.IO.StreamWriter aOutput)
       
   517         {
       
   518             iRegStorage.WriteProgramCounter(aOutput);
       
   519         }
       
   520 
       
   521         internal void WriteRegisterList(System.IO.StreamWriter aOutput)
       
   522         {
       
   523             iRegStorage.WriteBasicRegisters(aOutput);           
       
   524         }
       
   525       
       
   526         internal void WriteModuleName(System.IO.StreamWriter aOutput)
       
   527         {
       
   528             CCrashInfoFileUtilities.WriteOutputTags(iCrashedModuleName, CrashInfoConsts.Kcrashed_module_name, aOutput);
       
   529         }
       
   530 
       
   531         internal void WriteLoadedDLLs(System.IO.StreamWriter aOutput)
       
   532         {
       
   533             aOutput.Write(CCrashInfoFileUtilities.BlockStartMarker(CrashInfoConsts.Kcrashtime_loaded_dlls));
       
   534             bool first = true;
       
   535             foreach(CCrashInfoCodeSegItem codeseg in iCodeSegs)
       
   536             {
       
   537                 if (first) //all but first item start with separator - special handling needed
       
   538                 {
       
   539                     first = false;
       
   540                 }
       
   541                 else
       
   542                 {
       
   543                     aOutput.Write(CrashInfoConsts.KSeparator);
       
   544                 }
       
   545                 aOutput.Write(codeseg.Start);
       
   546                 aOutput.Write(CrashInfoConsts.KSeparator);
       
   547                 aOutput.Write(codeseg.End);
       
   548                 aOutput.Write(CrashInfoConsts.KSeparator);
       
   549                 aOutput.Write(codeseg.Name);
       
   550             }
       
   551             aOutput.Write(CCrashInfoFileUtilities.BlockEndMarker(CrashInfoConsts.Kcrashtime_loaded_dlls));
       
   552         }
       
   553 
       
   554         internal void WriteAvailableMemory(System.IO.StreamWriter aOutput)
       
   555         {
       
   556             CCrashInfoFileUtilities.WriteOutputTags(iFreeMomery, CrashInfoConsts.Kavailable_memory, aOutput);
       
   557         }
       
   558 
       
   559         internal void WriteUserComment(System.IO.StreamWriter aOutput)
       
   560         {
       
   561             //Dummy value needs to be written for dbmover
       
   562             CCrashInfoFileUtilities.WriteOutputTags("NotFound", CrashInfoConsts.Kuser_comment, aOutput);
       
   563         }
       
   564 
       
   565         internal void WriteMemoryInfo(System.IO.StreamWriter aOutput)
       
   566         {
       
   567             //Dummy value needs to be written for dbmover - for memory info just the tags
       
   568             aOutput.Write(CCrashInfoFileUtilities.BlockStartMarker(CrashInfoConsts.Kmemory_info));            
       
   569             aOutput.Write(CCrashInfoFileUtilities.BlockEndMarker(CrashInfoConsts.Kmemory_info));
       
   570         }
       
   571 
       
   572         internal void WriteMiscInfo(System.IO.StreamWriter aOutput)
       
   573         {
       
   574             //Dummy value needs to be written for dbmover
       
   575             string mInfo = "NotFound";
       
   576             if (iFileType == CrashInfoConsts.MobileCrashFileType.ETypeRegistrationMessage)
       
   577             {
       
   578                 mInfo = CrashInfoConsts.KRegistrationMiscInfo;
       
   579             }
       
   580             if (iFileType == CrashInfoConsts.MobileCrashFileType.ETypeAliveMessage)
       
   581             {
       
   582                 mInfo = CrashInfoConsts.KAliveTimeMiscInfo;
       
   583             }
       
   584 
       
   585             CCrashInfoFileUtilities.WriteOutputTags(mInfo, CrashInfoConsts.Kmisc_info, aOutput);
       
   586         }
       
   587 
       
   588         //This is the phone number
       
   589         internal void WriteReporter(System.IO.StreamWriter aOutput)
       
   590         {
       
   591             //Dummy value needs to be written for first part
       
   592             aOutput.Write(CCrashInfoFileUtilities.BlockStartMarker(CrashInfoConsts.Kreporter));      
       
   593             aOutput.Write("NotFound");
       
   594             aOutput.Write(CrashInfoConsts.KSeparator);
       
   595             aOutput.Write(iPhoneNumber);
       
   596             aOutput.Write(CCrashInfoFileUtilities.BlockEndMarker(CrashInfoConsts.Kreporter));     
       
   597         }
       
   598 
       
   599         internal void WriteArchive(System.IO.StreamWriter aOutput)
       
   600         {
       
   601             //Dummy value needs to be written for dbmover
       
   602             CCrashInfoFileUtilities.WriteOutputTags("0", CrashInfoConsts.Karchive, aOutput);
       
   603         }
       
   604 
       
   605         internal void WriteProductType(System.IO.StreamWriter aOutput)
       
   606         {
       
   607             CCrashInfoFileUtilities.WriteOutputTags(iProductType, CrashInfoConsts.Kproduct_type, aOutput);   
       
   608         }
       
   609         internal void WriteImei(System.IO.StreamWriter aOutput)
       
   610         {
       
   611             CCrashInfoFileUtilities.WriteOutputTags(iImei, CrashInfoConsts.Kimei, aOutput);
       
   612         }
       
   613 
       
   614         internal void WriteResetreason(System.IO.StreamWriter aOutput)
       
   615         {
       
   616             //Dummy value needs to be written for dbmover
       
   617             CCrashInfoFileUtilities.WriteOutputTags("", CrashInfoConsts.Kresetreason, aOutput);
       
   618         }
       
   619 
       
   620         internal void WriteUptime(System.IO.StreamWriter aOutput)
       
   621         {
       
   622             CCrashInfoFileUtilities.WriteOutputTags(iUptime.ToString(), CrashInfoConsts.Kuptime, aOutput);
       
   623         }
       
   624           
       
   625         internal void WriteIMSI(System.IO.StreamWriter aOutput)
       
   626         {
       
   627             CCrashInfoFileUtilities.WriteOutputTags(iImsi, CrashInfoConsts.Ksiminfo, aOutput);
       
   628         }
       
   629 
       
   630         internal void WriteNetworkCountry(System.IO.StreamWriter aOutput)
       
   631         {
       
   632             CCrashInfoFileUtilities.WriteOutputTags(iNetworkCountry, CrashInfoConsts.Knetwork_country_code, aOutput);
       
   633         }
       
   634 
       
   635         internal void WriteNetworkIdentity(System.IO.StreamWriter aOutput)
       
   636         {
       
   637             CCrashInfoFileUtilities.WriteOutputTags(iNetworkIdentity, CrashInfoConsts.Knetwork_identity, aOutput);
       
   638         }      
       
   639       
       
   640         internal void WriteLocInfo(System.IO.StreamWriter aOutput)
       
   641         {
       
   642             CCrashInfoFileUtilities.WriteOutputTags(iLocInfo, CrashInfoConsts.Klocinfo, aOutput);
       
   643         }
       
   644        
       
   645         internal void WriteNetworkCell(System.IO.StreamWriter aOutput)
       
   646         {
       
   647             CCrashInfoFileUtilities.WriteOutputTags(iNetworkCell, CrashInfoConsts.Kcellid, aOutput);
       
   648         }
       
   649 
       
   650         internal void WriteTestset(System.IO.StreamWriter aOutput)
       
   651         {
       
   652             CCrashInfoFileUtilities.WriteOutputTags(iTestSet, CrashInfoConsts.Ktestset, aOutput);
       
   653         }
       
   654 
       
   655         //Serial number known also as PSN
       
   656         internal void WriteSerialNumber(System.IO.StreamWriter aOutput)
       
   657         {
       
   658             CCrashInfoFileUtilities.WriteOutputTags(iSerialNumber, CrashInfoConsts.Kpsninfo, aOutput);
       
   659         }
       
   660 
       
   661         internal void WriteS60Version(System.IO.StreamWriter aOutput)
       
   662         {
       
   663             CCrashInfoFileUtilities.WriteOutputTags(iS60Version, CrashInfoConsts.Ks60version, aOutput);
       
   664         }
       
   665 
       
   666         internal void WriteProductCode(System.IO.StreamWriter aOutput)
       
   667         {
       
   668             CCrashInfoFileUtilities.WriteOutputTags(iProductCode, CrashInfoConsts.Kproduct_code, aOutput);
       
   669         }
       
   670 
       
   671         internal void WriteVariantVersion(System.IO.StreamWriter aOutput)
       
   672         {
       
   673             CCrashInfoFileUtilities.WriteOutputTags(iVariantVersion, CrashInfoConsts.Kvariant_version, aOutput);
       
   674         }
       
   675         internal void WriteCrashHash(System.IO.StreamWriter aOutput)
       
   676         {
       
   677             if ( string.IsNullOrEmpty( iHash ) == false )
       
   678             {
       
   679                 aOutput.Write( CCrashInfoFileUtilities.MakeOutputTags( iHash, CrashInfoConsts.Kcrash_hash ) );
       
   680             }
       
   681         }
       
   682         internal void WriteMMCInfo(System.IO.StreamWriter aOutput)
       
   683         {
       
   684             //Dummy value needs to be written for dbmover
       
   685             CCrashInfoFileUtilities.WriteOutputTags("", CrashInfoConsts.Kmmcinfo, aOutput);
       
   686         }
       
   687         internal void WriteUID(System.IO.StreamWriter aOutput)
       
   688         {
       
   689             CCrashInfoFileUtilities.WriteOutputTags(iUID, CrashInfoConsts.Kuid, aOutput); 
       
   690         }
       
   691 
       
   692         internal void WriteDiskInfo(System.IO.StreamWriter aOutput)
       
   693         {
       
   694             CCrashInfoFileUtilities.WriteOutputTags(iDiskInfo.ToString(), CrashInfoConsts.Kdiskinfo, aOutput);
       
   695         }
       
   696 
       
   697         internal void WriteFileType(System.IO.StreamWriter aOutput)
       
   698         {
       
   699             int type = 0; //default type 0
       
   700             if (iReportType != string.Empty)
       
   701             {
       
   702                 type = 1; //for reports, type 1
       
   703             }
       
   704             CCrashInfoFileUtilities.WriteOutputTags(type, CrashInfoConsts.Kfile_type, aOutput);
       
   705         }
       
   706         
       
   707         internal void WriteReportType(System.IO.StreamWriter aOutput)
       
   708         {
       
   709             CCrashInfoFileUtilities.WriteOutputTags(iReportType, CrashInfoConsts.Kreport_type, aOutput);
       
   710         }
       
   711 
       
   712         internal void WriteReportCategory(System.IO.StreamWriter aOutput)
       
   713         {
       
   714             CCrashInfoFileUtilities.WriteOutputTags(iReportCategory, CrashInfoConsts.Kreport_category, aOutput);
       
   715         }
       
   716 
       
   717         internal void WriteReportOK(System.IO.StreamWriter aOutput)
       
   718         {
       
   719             CCrashInfoFileUtilities.WriteOutputTags(iReportOK, CrashInfoConsts.Kreport_ok, aOutput); 
       
   720         }
       
   721 
       
   722         internal void WriteReportFail(System.IO.StreamWriter aOutput)
       
   723         {
       
   724             CCrashInfoFileUtilities.WriteOutputTags(iReportFail, CrashInfoConsts.Kreport_fail, aOutput); 
       
   725         }
       
   726 
       
   727         internal void WriteReportParam1(System.IO.StreamWriter aOutput)
       
   728         {
       
   729             CCrashInfoFileUtilities.WriteOutputTags(iReportParamName1, CrashInfoConsts.Kreport_param_name1, aOutput);      
       
   730             CCrashInfoFileUtilities.WriteOutputTags(iReportParamValue1, CrashInfoConsts.Kreport_param_value1, aOutput);
       
   731 
       
   732         }
       
   733 
       
   734         internal void WriteReportParam2(System.IO.StreamWriter aOutput)
       
   735         {
       
   736             CCrashInfoFileUtilities.WriteOutputTags(iReportParamName2, CrashInfoConsts.Kreport_param_name2, aOutput);
       
   737             CCrashInfoFileUtilities.WriteOutputTags(iReportParamValue2, CrashInfoConsts.Kreport_param_value2, aOutput);
       
   738         }
       
   739 
       
   740         internal void WriteReportParam3(System.IO.StreamWriter aOutput)
       
   741         {
       
   742             CCrashInfoFileUtilities.WriteOutputTags(iReportParamName3, CrashInfoConsts.Kreport_param_name3, aOutput);
       
   743             CCrashInfoFileUtilities.WriteOutputTags(iReportParamValue3, CrashInfoConsts.Kreport_param_value3, aOutput);
       
   744         }
       
   745 
       
   746         internal void WriteReportComments(System.IO.StreamWriter aOutput)
       
   747         {
       
   748             CCrashInfoFileUtilities.WriteOutputTags(iReportComments, CrashInfoConsts.Kreport_comments, aOutput);
       
   749         }
       
   750 
       
   751         internal void WriteRegisterExtraList(System.IO.StreamWriter aOutput)
       
   752         {            
       
   753             iRegStorage.WriteOtherRegisters(aOutput);
       
   754         }
       
   755 
       
   756         internal void WriteCallstacks(System.IO.StreamWriter aOutput)
       
   757         {
       
   758             foreach (CCrashInfoCallStack stack in iCallStacks)
       
   759             {
       
   760                 stack.WriteToStream(aOutput);
       
   761             }
       
   762         }
       
   763 
       
   764         internal void WriteBinFileName(System.IO.StreamWriter aOutput)
       
   765         {
       
   766             CCrashInfoFileUtilities.WriteOutputTags(iBinFilename, CrashInfoConsts.Kbinfile_name, aOutput);
       
   767         }
       
   768         internal void WriteSymbolFileNames(System.IO.StreamWriter aOutput)
       
   769         {
       
   770             string symbolfilenames = string.Empty;
       
   771             foreach (string fileName in iSymbolFiles)
       
   772             {
       
   773                 if (symbolfilenames != string.Empty)
       
   774                 {
       
   775                     symbolfilenames = symbolfilenames + ", ";
       
   776                 }
       
   777                 symbolfilenames = symbolfilenames + Path.GetFileName(fileName);
       
   778             }
       
   779             CCrashInfoFileUtilities.WriteOutputTags(symbolfilenames, CrashInfoConsts.Ksymbolfile_names, aOutput);
       
   780         }
       
   781 
       
   782          internal void WriteEventlog(System.IO.StreamWriter aOutput)
       
   783         {
       
   784             if (iEventlog.Count > 0)
       
   785             {
       
   786                 aOutput.Write(CCrashInfoFileUtilities.BlockStartMarker(CrashInfoConsts.Keventlog));
       
   787                 foreach (string line in iEventlog)
       
   788                 {
       
   789                     aOutput.Write(line + CrashInfoConsts.KEOL);
       
   790                 }
       
   791                 aOutput.Write(CCrashInfoFileUtilities.BlockEndMarker(CrashInfoConsts.Keventlog));
       
   792             }
       
   793         }
       
   794 
       
   795 
       
   796          internal void WriteOstTraces(System.IO.StreamWriter aOutput)
       
   797          {
       
   798              if (iOstTraces.Count > 0)
       
   799              {
       
   800                  aOutput.Write(CCrashInfoFileUtilities.BlockStartMarker(CrashInfoConsts.Ktrace_data));
       
   801                  foreach (string line in iOstTraces)
       
   802                  {
       
   803                      aOutput.Write(line + CrashInfoConsts.KEOL);
       
   804                  }
       
   805                  aOutput.Write(CCrashInfoFileUtilities.BlockEndMarker(CrashInfoConsts.Ktrace_data));
       
   806              }
       
   807          }
       
   808 
       
   809         #endregion
       
   810 
       
   811         
       
   812 
       
   813         #region Data members
       
   814          private CrashInfoConsts.MobileCrashFileType iFileType = CrashInfoConsts.MobileCrashFileType.ETypeBasicCrash;
       
   815         
       
   816         private string iTimeStampText = string.Empty; //YearMonthDayHourMinSec
       
   817         private uint? iRomId = null; //aka rom's checksum word
       
   818         private string iPlatform = string.Empty; //usually SOS
       
   819         private string iSWVersion = string.Empty; //The "main" version number
       
   820         private string iS60Version = string.Empty;
       
   821         private string iVariantVersion = string.Empty;
       
   822 
       
   823         private int? iPanicID = null;
       
   824         private string iPanicCategory = string.Empty;
       
   825 
       
   826         private string iLanguage = string.Empty; //english, finnish etc
       
   827         
       
   828         private string iProcess = string.Empty;
       
   829 
       
   830         private CCrashInfoRegisterStorage iRegStorage = new CCrashInfoRegisterStorage(); //registers
       
   831 
       
   832         private string iCrashedModuleName = string.Empty; //thread name
       
   833 
       
   834         private List<CCrashInfoCodeSegItem> iCodeSegs = new List<CCrashInfoCodeSegItem>(); //crash time loaded dlls
       
   835 
       
   836         private ulong? iFreeMomery = null; //free ram
       
   837 
       
   838         private string iProductType = string.Empty; //aka RM-code
       
   839         private string iProductCode = string.Empty; //7-digit HW variant code 
       
   840         private string iSerialNumber = string.Empty; //aka PSN
       
   841 
       
   842         private string iPhoneNumber = "NotFound";
       
   843         private string iImei = string.Empty;
       
   844         private string iImsi = string.Empty;
       
   845         private string iNetworkCountry = string.Empty;
       
   846         private string iNetworkIdentity = string.Empty;
       
   847         private string iNetworkCell = string.Empty;
       
   848         private string iLocInfo = string.Empty;
       
   849         private string iTestSet = string.Empty;
       
   850         private double? iUptime = null;
       
   851         private uint? iUID = null;
       
   852         private ulong? iDiskInfo = null;
       
   853         private string iReportType = string.Empty;
       
   854         private string iReportCategory = string.Empty;
       
   855         private uint? iReportOK = null;
       
   856         private uint? iReportFail = null;
       
   857         private string iReportParamName1 = string.Empty;
       
   858         private uint? iReportParamValue1 = null;
       
   859         private string iReportParamName2 = string.Empty;
       
   860         private uint? iReportParamValue2 = null;
       
   861         private string iReportParamName3 = string.Empty;
       
   862         private uint? iReportParamValue3 = null;
       
   863         private string iReportComments = string.Empty;
       
   864         private string iHash = string.Empty;
       
   865 
       
   866         private List<CCrashInfoCallStack> iCallStacks = new List<CCrashInfoCallStack>(); //Call stacks
       
   867 
       
   868         private string iBinFilename = string.Empty;
       
   869         List<string> iSymbolFiles = new List<string>();
       
   870         List<string> iEventlog = new List<string>();
       
   871         List<string> iOstTraces = new List<string>();
       
   872 
       
   873         #endregion
       
   874 
       
   875 
       
   876 
       
   877     }
       
   878 }