|
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.Collections.Generic; |
|
19 using System.Text; |
|
20 using SymbianUtils; |
|
21 using SymbianUtils.FileSystem.FilePair; |
|
22 using SymbianStructuresLib.CodeSegments; |
|
23 using SymbianDebugLib.Engine; |
|
24 using SymbianDebugLib.PluginAPI.Types; |
|
25 using SymbianDebugLib.PluginAPI.Types.Code; |
|
26 using SymbianDebugLib.PluginAPI.Types.Symbol; |
|
27 |
|
28 namespace SymbianDebugLib.Engine |
|
29 { |
|
30 public class DbgEngineView : DisposableObject |
|
31 { |
|
32 #region Constructors |
|
33 internal DbgEngineView( DbgEngine aEngine, string aName, CodeSegDefinitionCollection aCodeSegments, TDbgViewDeactivationType aDeactivationType ) |
|
34 { |
|
35 iName = aName; |
|
36 iEngine = aEngine; |
|
37 iDeactivationType = aDeactivationType; |
|
38 iCodeSegments = new CodeSegDefinitionCollection( aCodeSegments ); |
|
39 // |
|
40 iViewCode = (DbgViewCode) EngineCode.CreateView( iName ); |
|
41 if ( iViewCode != null ) |
|
42 { |
|
43 iViewCode.Activate( aCodeSegments ); |
|
44 } |
|
45 // |
|
46 iViewSymbols = (DbgViewSymbol) EngineSymbols.CreateView( iName ); |
|
47 if ( iViewSymbols != null ) |
|
48 { |
|
49 iViewSymbols.Activate( aCodeSegments ); |
|
50 } |
|
51 } |
|
52 #endregion |
|
53 |
|
54 #region API |
|
55 public bool SerializeTaggedCollections( FileNamePairCollection aFilesToSave ) |
|
56 { |
|
57 bool savedSyms = Symbols.SerializeTaggedCollections( aFilesToSave ); |
|
58 bool savedCode = Code.SerializeTaggedCollections( aFilesToSave ); |
|
59 // |
|
60 return ( savedCode || savedSyms ); |
|
61 } |
|
62 #endregion |
|
63 |
|
64 #region Properties |
|
65 public string Name |
|
66 { |
|
67 get |
|
68 { |
|
69 return iName; |
|
70 } |
|
71 } |
|
72 |
|
73 public DbgViewCode Code |
|
74 { |
|
75 get |
|
76 { |
|
77 if ( iViewCode == null ) |
|
78 { |
|
79 throw new NotSupportedException(); |
|
80 } |
|
81 // |
|
82 return iViewCode; |
|
83 } |
|
84 } |
|
85 |
|
86 public DbgViewSymbol Symbols |
|
87 { |
|
88 get |
|
89 { |
|
90 if ( iViewSymbols == null ) |
|
91 { |
|
92 throw new NotSupportedException(); |
|
93 } |
|
94 // |
|
95 return iViewSymbols; |
|
96 } |
|
97 } |
|
98 |
|
99 public DbgEngineCode EngineCode |
|
100 { |
|
101 get { return iEngine.Code; } |
|
102 } |
|
103 |
|
104 public DbgEngineSymbol EngineSymbols |
|
105 { |
|
106 get { return iEngine.Symbols; } |
|
107 } |
|
108 #endregion |
|
109 |
|
110 #region Operators |
|
111 public static implicit operator DbgViewCode( DbgEngineView aView ) |
|
112 { |
|
113 return aView.Code; |
|
114 } |
|
115 |
|
116 public static implicit operator DbgViewSymbol( DbgEngineView aView ) |
|
117 { |
|
118 return aView.Symbols; |
|
119 } |
|
120 #endregion |
|
121 |
|
122 #region From DisposableObject |
|
123 protected override void CleanupManagedResources() |
|
124 { |
|
125 try |
|
126 { |
|
127 base.CleanupManagedResources(); |
|
128 } |
|
129 finally |
|
130 { |
|
131 if ( iViewCode != null ) |
|
132 { |
|
133 if ( iDeactivationType == TDbgViewDeactivationType.EDeactivateWhenDisposed ) |
|
134 { |
|
135 iViewCode.Deactivate( iCodeSegments ); |
|
136 } |
|
137 // |
|
138 iViewCode.Dispose(); |
|
139 iViewCode = null; |
|
140 } |
|
141 if ( iViewSymbols != null ) |
|
142 { |
|
143 if ( iDeactivationType == TDbgViewDeactivationType.EDeactivateWhenDisposed ) |
|
144 { |
|
145 iViewSymbols.Deactivate( iCodeSegments ); |
|
146 } |
|
147 // |
|
148 iViewSymbols.Dispose(); |
|
149 iViewSymbols = null; |
|
150 } |
|
151 } |
|
152 } |
|
153 #endregion |
|
154 |
|
155 #region From System.Object |
|
156 public override int GetHashCode() |
|
157 { |
|
158 return iName.GetHashCode(); |
|
159 } |
|
160 |
|
161 public override string ToString() |
|
162 { |
|
163 return iName; |
|
164 } |
|
165 #endregion |
|
166 |
|
167 #region Data members |
|
168 private readonly string iName; |
|
169 private readonly DbgEngine iEngine; |
|
170 private readonly CodeSegDefinitionCollection iCodeSegments; |
|
171 private readonly TDbgViewDeactivationType iDeactivationType; |
|
172 private DbgViewCode iViewCode; |
|
173 private DbgViewSymbol iViewSymbols; |
|
174 #endregion |
|
175 } |
|
176 } |