|
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.IO; |
|
20 using System.Collections.Generic; |
|
21 using System.Text; |
|
22 using System.Threading; |
|
23 using SymbianStructuresLib.Debug.Symbols; |
|
24 using SymbianStructuresLib.Debug.Symbols.Interfaces; |
|
25 using SymbianSymbolLib.SourceManagement.Source; |
|
26 using SymbianSymbolLib.SourceManagement.Provisioning; |
|
27 using SymbianUtils.FileTypes; |
|
28 using SymbianUtils; |
|
29 |
|
30 namespace SLPluginObey.Source |
|
31 { |
|
32 internal class ObeySource : SymSource, ISymbolCollectionRelocationHandler |
|
33 { |
|
34 #region Constructors |
|
35 public ObeySource( string aURI, SymSourceProvider aProvider, SymSource aOriginalMapSource ) |
|
36 : base( aURI, aProvider ) |
|
37 { |
|
38 foreach ( SymbolCollection mapCollection in aOriginalMapSource ) |
|
39 { |
|
40 mapCollection.IfaceRelocationHandler = this as ISymbolCollectionRelocationHandler; |
|
41 base.Add( mapCollection ); |
|
42 } |
|
43 iOriginalMapSource = aOriginalMapSource; |
|
44 } |
|
45 #endregion |
|
46 |
|
47 #region API |
|
48 #endregion |
|
49 |
|
50 #region From SymSource |
|
51 public override void Read( TSynchronicity aSynchronicity ) |
|
52 { |
|
53 // This method is typically called when the engine is primed with a list of files. |
|
54 // We've already read the OBY file content, so there's no need to do anything there |
|
55 // at all. In fact, this method is never invoked in that scenario because the OBY |
|
56 // file is never registered as a SymSource. |
|
57 // |
|
58 // The usual invocation context for this method is when a map file prime request is |
|
59 // received. Because we associated every MAP file [that we were able to locate from the |
|
60 // OBY data] with the OBY provider, we can intercept the requests to read the MAP content. |
|
61 // |
|
62 // This allows us to ignore those read requests that occur during priming, and thereby |
|
63 // allow "on demand" reading of MAP file content only when an explicit code segment |
|
64 // activation (relocation/fixup) API call is made to the SymbolView class. |
|
65 // |
|
66 // When the symbol collection is activated (relocated/fixed up) we will be notified by |
|
67 // way of the SymbolCollection's "relocated" event. This will then allow us to syncronously |
|
68 // read the MAP file content and update the collection with a list of real symbols. All of |
|
69 // this is managed by the ObeySource class. |
|
70 // |
|
71 // This therefore explains why this method is implemented, but is empty. |
|
72 // Also see Reader_EntryRead for further details. |
|
73 base.ReportEvent( TEvent.EReadingComplete ); |
|
74 } |
|
75 #endregion |
|
76 |
|
77 #region Properties |
|
78 public SymSource OriginalMapSource |
|
79 { |
|
80 get { return iOriginalMapSource; } |
|
81 } |
|
82 #endregion |
|
83 |
|
84 #region Event handlers |
|
85 #endregion |
|
86 |
|
87 #region Internal constants |
|
88 #endregion |
|
89 |
|
90 #region Internal methods |
|
91 #endregion |
|
92 |
|
93 #region ISymbolCollectionRelocationHandler Members |
|
94 void ISymbolCollectionRelocationHandler.PrepareForRelocation( SymbolCollection aCollection, uint aOldBase, uint aNewBase ) |
|
95 { |
|
96 // This is invoked when a map file is activated. Because we've probably not yet read the |
|
97 // source content, we will synchronously parse the map file now so that we have a full set |
|
98 // of symbols available to the client. |
|
99 if ( aCollection.IsEmptyApartFromDefaultSymbol ) |
|
100 { |
|
101 // This will read into the original map source and original map collection. |
|
102 iOriginalMapSource.Read( TSynchronicity.ESynchronous ); |
|
103 |
|
104 // If the specified aCollection is a clone, i.e. not the original, then we may need |
|
105 // to copy symbols over. |
|
106 if ( iOriginalMapSource.Count > 0 ) |
|
107 { |
|
108 SymbolCollection primaryMapCollection = iOriginalMapSource[ 0 ]; |
|
109 if ( aCollection != primaryMapCollection ) |
|
110 { |
|
111 aCollection.Clone( primaryMapCollection ); |
|
112 } |
|
113 } |
|
114 } |
|
115 } |
|
116 #endregion |
|
117 |
|
118 #region Data members |
|
119 private readonly SymSource iOriginalMapSource; |
|
120 #endregion |
|
121 } |
|
122 } |