|
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 CCrashInfoFileSink is part of CrashAnalyser CrashInfoFile plugin. |
|
16 * Sink output plugin for Crash Info File format. |
|
17 * Implements CISink which is automatically discovered by CISinkManager. |
|
18 * Serialize function produces a Crash Info file formatted text output |
|
19 * |
|
20 */ |
|
21 |
|
22 using System; |
|
23 using System.Collections.Generic; |
|
24 using System.Text; |
|
25 |
|
26 using CrashItemLib.Sink; |
|
27 |
|
28 //using CrashItemLib.Crash.Symbols; |
|
29 //using CrashItemLib.Crash.CodeSegs; |
|
30 //using CrashItemLib.Crash.Registers; |
|
31 //using CrashItemLib.Crash.Threads; |
|
32 |
|
33 |
|
34 using CrashInfoFilePlugin.PluginImplementations.FileFormat; |
|
35 using System.IO; |
|
36 |
|
37 namespace CrashInfoFilePlugin.PluginImplementations.Sink |
|
38 { |
|
39 public class CCrashInfoFileSink : CISink |
|
40 { |
|
41 #region Constants |
|
42 public const string KCrashInfoSinkName = "Crash Info File"; |
|
43 #endregion |
|
44 |
|
45 #region Constructors |
|
46 public CCrashInfoFileSink(CISinkManager aManager) |
|
47 : base(KCrashInfoSinkName, aManager) |
|
48 { |
|
49 } |
|
50 #endregion |
|
51 |
|
52 #region From CISink |
|
53 public override object Serialize(CISinkSerializationParameters aParams) |
|
54 { |
|
55 CCrashInfoFileDocument document = new CCrashInfoFileDocument(); |
|
56 |
|
57 //Read information relevant to crash info file from container to internal variables |
|
58 document.ReadDataFromContainer(aParams); |
|
59 |
|
60 //Override default file extension |
|
61 aParams.FileExtensionFailed = ".corrupt_ci"; |
|
62 aParams.FileExtensionSuccess = ".ci"; |
|
63 |
|
64 //Write document's internal data to file |
|
65 string newFileName = string.Empty; |
|
66 using ( Stream output = aParams.CreateFile( out newFileName ) ) |
|
67 { |
|
68 using ( StreamWriter sw = new StreamWriter( output, Encoding.ASCII ) ) |
|
69 { |
|
70 document.WriteToStream( sw ); |
|
71 } |
|
72 } |
|
73 return newFileName; |
|
74 } |
|
75 #endregion |
|
76 } |
|
77 } |