|
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.Text; |
|
19 using System.IO; |
|
20 using System.Collections.Generic; |
|
21 using SymbianStructuresLib.Uids; |
|
22 using SymbianStructuresLib.CodeSegments; |
|
23 using SymbianDebugLib.PluginAPI.Types.Symbol; |
|
24 using SymbianUtils; |
|
25 using SymbianUtils.Range; |
|
26 using SymbianUtils.DataBuffer; |
|
27 using CrashItemLib.Crash; |
|
28 using CrashItemLib.Crash.Base; |
|
29 using CrashItemLib.Crash.Symbols; |
|
30 using CrashItemLib.Crash.Processes; |
|
31 |
|
32 namespace CrashItemLib.Crash.CodeSegs |
|
33 { |
|
34 public class CICodeSegList : CIElement, IEnumerable<CICodeSeg> |
|
35 { |
|
36 #region Constructors |
|
37 public CICodeSegList( CIProcess aProcess ) |
|
38 : base( aProcess.Container, aProcess ) |
|
39 { |
|
40 base.AddSupportedChildType( typeof( CICodeSeg ) ); |
|
41 base.AddSupportedChildType( typeof( CrashItemLib.Crash.Messages.CIMessage ) ); |
|
42 } |
|
43 |
|
44 public CICodeSegList( CIProcess aProcess, IEnumerable<CICodeSeg> aEnumerable ) |
|
45 : this( aProcess ) |
|
46 { |
|
47 foreach ( CICodeSeg cs in aEnumerable ) |
|
48 { |
|
49 AddChild( cs ); |
|
50 } |
|
51 } |
|
52 #endregion |
|
53 |
|
54 #region API |
|
55 public bool Contains( string aDeviceBinaryFileName ) |
|
56 { |
|
57 bool ret = false; |
|
58 // |
|
59 string deviceBinaryFileName = aDeviceBinaryFileName.ToUpper(); |
|
60 foreach ( CICodeSeg codeSeg in this ) |
|
61 { |
|
62 string codeSegName = Path.GetFileNameWithoutExtension( codeSeg.Name ).ToUpper(); |
|
63 if ( deviceBinaryFileName.Contains( codeSegName ) ) |
|
64 { |
|
65 ret = true; |
|
66 break; |
|
67 } |
|
68 } |
|
69 // |
|
70 return ret; |
|
71 } |
|
72 |
|
73 |
|
74 internal void DiscardImplicitCodeSegments() |
|
75 { |
|
76 int count = base.Count; |
|
77 for ( int i = count - 1; i >= 0; i-- ) |
|
78 { |
|
79 CICodeSeg cs = this[ i ] as CICodeSeg; |
|
80 if ( cs != null && !cs.IsExplicit ) |
|
81 { |
|
82 base.Trace( string.Format( "[CICodeSegList] DiscardImplicitCodeSegments() - dicarding: {0}", cs ) ); |
|
83 base.RemoveChild( cs ); |
|
84 } |
|
85 } |
|
86 } |
|
87 #endregion |
|
88 |
|
89 #region Properties |
|
90 public CIProcess OwningProcess |
|
91 { |
|
92 get { return (CIProcess) base.Parent; } |
|
93 } |
|
94 |
|
95 public CICodeSeg this[ uint aAddress ] |
|
96 { |
|
97 get |
|
98 { |
|
99 CICodeSeg ret = null; |
|
100 // |
|
101 foreach ( CICodeSeg cs in this ) |
|
102 { |
|
103 if ( cs.Contains( aAddress ) ) |
|
104 { |
|
105 ret = cs; |
|
106 break; |
|
107 } |
|
108 } |
|
109 // |
|
110 return ret; |
|
111 } |
|
112 } |
|
113 #endregion |
|
114 |
|
115 #region Operators |
|
116 public static implicit operator CodeSegDefinitionCollection( CICodeSegList aList ) |
|
117 { |
|
118 return aList.iCollection; |
|
119 } |
|
120 #endregion |
|
121 |
|
122 #region From IEnumerable<CICodeSeg> |
|
123 public new IEnumerator<CICodeSeg> GetEnumerator() |
|
124 { |
|
125 foreach ( CIElement element in base.Children ) |
|
126 { |
|
127 if ( element is CICodeSeg ) |
|
128 { |
|
129 CICodeSeg ret = (CICodeSeg) element; |
|
130 yield return ret; |
|
131 } |
|
132 } |
|
133 } |
|
134 |
|
135 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() |
|
136 { |
|
137 foreach ( CIElement element in base.Children ) |
|
138 { |
|
139 if ( element is CICodeSeg ) |
|
140 { |
|
141 CICodeSeg ret = (CICodeSeg) element; |
|
142 yield return ret; |
|
143 } |
|
144 } |
|
145 } |
|
146 #endregion |
|
147 |
|
148 #region From CIElement |
|
149 protected override void OnElementAddedToSelf( CIElement aElement ) |
|
150 { |
|
151 System.Diagnostics.Debug.Assert( aElement is CICodeSeg ); |
|
152 CICodeSeg codeSeg = (CICodeSeg) aElement; |
|
153 iCollection.Add( codeSeg ); |
|
154 // |
|
155 base.OnElementAddedToSelf( aElement ); |
|
156 } |
|
157 #endregion |
|
158 |
|
159 #region Data members |
|
160 private CodeSegDefinitionCollection iCollection = new CodeSegDefinitionCollection(); |
|
161 #endregion |
|
162 } |
|
163 } |