|
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 System.IO; |
|
22 using SymbianUtils; |
|
23 using SymbianUtils.Range; |
|
24 using SymbianUtils.Tracer; |
|
25 using SymbianUtils.FileTypes; |
|
26 using SymbianStructuresLib.Arm; |
|
27 using SymbianStructuresLib.Arm.Instructions; |
|
28 using SymbianStructuresLib.Debug.Code; |
|
29 using SymbianStructuresLib.CodeSegments; |
|
30 using SymbianDebugLib.PluginAPI; |
|
31 using SymbianDebugLib.PluginAPI.Types; |
|
32 using SymbianDebugLib.PluginAPI.Types.Code; |
|
33 using SymbianCodeLib.QueryAPI; |
|
34 using SymbianCodeLib.Relocator; |
|
35 using SymbianCodeLib.DbgEnginePlugin; |
|
36 using SymbianCodeLib.SourceManagement.Source; |
|
37 using SymbianCodeLib.SourceManagement.Provisioning; |
|
38 |
|
39 namespace SymbianCodeLib.DbgEnginePlugin |
|
40 { |
|
41 public class CodeView : DbgViewCode |
|
42 { |
|
43 #region Constructors |
|
44 internal CodeView( string aToken, CodePlugin aPlugin ) |
|
45 : base( aToken, aPlugin ) |
|
46 { |
|
47 iRelocator = new CodeRelocator( aPlugin ); |
|
48 iQueryAPI = new CodeQueryAPI( iRelocator ); |
|
49 } |
|
50 #endregion |
|
51 |
|
52 #region From DbgPluginView |
|
53 public override bool Contains( uint aAddress ) |
|
54 { |
|
55 bool ret = iQueryAPI.Contains( aAddress ); |
|
56 return ret; |
|
57 } |
|
58 |
|
59 public override bool Activate( CodeSegDefinition aCodeSegment ) |
|
60 { |
|
61 bool activated = ActivateAndGetCollection( aCodeSegment ) != null; |
|
62 return activated; |
|
63 } |
|
64 |
|
65 public override bool Deactivate( CodeSegDefinition aCodeSegment ) |
|
66 { |
|
67 return iRelocator.Deactivate( aCodeSegment ); |
|
68 } |
|
69 |
|
70 public override bool IsReady |
|
71 { |
|
72 get |
|
73 { |
|
74 // For a view to be ready we must have at least one |
|
75 // activated, i.e. 'ready' symbol source. |
|
76 int count = 0; |
|
77 |
|
78 // Check with dynamic activations |
|
79 foreach ( CodeSourceAndCollection pair in iRelocator ) |
|
80 { |
|
81 if ( pair.Source.TimeToRead == CodeSource.TTimeToRead.EReadWhenPriming ) |
|
82 { |
|
83 ++count; |
|
84 break; // No need to count anymore |
|
85 } |
|
86 } |
|
87 |
|
88 // Try to find any fixed activation entries |
|
89 if ( count == 0 ) |
|
90 { |
|
91 CodeSourceManager allSources = this.SourceManager; |
|
92 foreach ( CodeSource source in allSources ) |
|
93 { |
|
94 count += source.CountActivated; |
|
95 if ( count > 0 ) |
|
96 { |
|
97 break; |
|
98 } |
|
99 } |
|
100 } |
|
101 |
|
102 return ( count > 0 ); |
|
103 } |
|
104 } |
|
105 #endregion |
|
106 |
|
107 #region From DbgViewCode |
|
108 public override CodeCollection ActivateAndGetCollection( CodeSegDefinition aCodeSegment ) |
|
109 { |
|
110 CodeCollection ret = iRelocator.Activate( aCodeSegment ); |
|
111 return ret; |
|
112 } |
|
113 |
|
114 protected override bool DoGetInstructions( uint aAddress, TArmInstructionSet aInstructionSet, int aCount, out IArmInstruction[] aInstructions ) |
|
115 { |
|
116 bool ret = iQueryAPI.GetInstructions( aAddress, aInstructionSet, aCount, out aInstructions ); |
|
117 return ret; |
|
118 } |
|
119 |
|
120 public override IArmInstruction ConvertToInstruction( uint aAddress, TArmInstructionSet aInstructionSet, uint aRawValue ) |
|
121 { |
|
122 CodePlugin plugin = this.Plugin; |
|
123 IArmInstruction[] ret = plugin.ProvisioningManager.InstructionLibrary.ConvertToInstructions( aInstructionSet, new uint[ 1 ] { aRawValue }, aAddress ); |
|
124 System.Diagnostics.Debug.Assert( ret != null && ret.Length == 1 ); |
|
125 return ret[ 0 ]; |
|
126 } |
|
127 #endregion |
|
128 |
|
129 #region API |
|
130 #endregion |
|
131 |
|
132 #region Properties |
|
133 internal CodeSourceManager SourceManager |
|
134 { |
|
135 get { return Plugin.SourceManager; } |
|
136 } |
|
137 #endregion |
|
138 |
|
139 #region Internal methods |
|
140 internal CodePlugin Plugin |
|
141 { |
|
142 get { return base.Engine as CodePlugin; } |
|
143 } |
|
144 #endregion |
|
145 |
|
146 #region From DisposableObject |
|
147 protected override void CleanupManagedResources() |
|
148 { |
|
149 try |
|
150 { |
|
151 base.CleanupManagedResources(); |
|
152 } |
|
153 finally |
|
154 { |
|
155 iRelocator.Dispose(); |
|
156 } |
|
157 } |
|
158 #endregion |
|
159 |
|
160 #region Data members |
|
161 private readonly CodeQueryAPI iQueryAPI; |
|
162 private readonly CodeRelocator iRelocator; |
|
163 #endregion |
|
164 } |
|
165 } |