annotate agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgCDebugInfoBuilder.java @ 8849:e458120c6e1a

8002118: WindbgDebuggerLocal should not try to load 64-bit debug libraries for 32-bit JVM Reviewed-by: sspitsyn, zgu Contributed-by: peter.allwin@oracle.com
author sla
date Thu, 28 Mar 2013 15:39:52 +0100
parents c18cbe5936b8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.debugger.windbg;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.debugger.win32.coff.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.debugger.cdbg.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.debugger.cdbg.basic.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.utilities.Assert;
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 class WindbgCDebugInfoBuilder
a61af66fc99e Initial load
duke
parents:
diff changeset
36 implements DebugVC50SubsectionTypes, DebugVC50TypeLeafIndices, DebugVC50TypeEnums, DebugVC50SymbolTypes, DebugVC50MemberAttributes, CVAttributes, AccessControl {
a61af66fc99e Initial load
duke
parents:
diff changeset
37 private WindbgDebugger dbg;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 private Address base;
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 private DebugVC50 vc50;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 private BasicCDebugInfoDataBase db;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 private DebugVC50TypeIterator iter;
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 private DebugVC50SymbolIterator symIter;
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // Logical->physical segment mapping
a61af66fc99e Initial load
duke
parents:
diff changeset
47 private COFFFile file;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 private DebugVC50SSSegMap segMap;
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // Canonicalization of primitive types
a61af66fc99e Initial load
duke
parents:
diff changeset
51 private Map primIndexToTypeMap;
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // Global unnamed enumeration
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // (FIXME: must figure out how to handle nested type descriptions)
a61af66fc99e Initial load
duke
parents:
diff changeset
55 private BasicEnumType unnamedEnum;
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 private Stack blockStack;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 private int endsToSkip;
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 private static final int POINTER_SIZE = 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 WindbgCDebugInfoBuilder(WindbgDebugger dbg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 this.dbg = dbg;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 CDebugInfoDataBase buildDataBase(String dllName, Address base) {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 this.base = base;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 file = COFFFileParser.getParser().parse(dllName);
a61af66fc99e Initial load
duke
parents:
diff changeset
69 vc50 = getDebugVC50(file);
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 if (vc50 == null) return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 segMap = getSegMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 primIndexToTypeMap = new HashMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
76 blockStack = new Stack();
a61af66fc99e Initial load
duke
parents:
diff changeset
77 endsToSkip = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 db = new BasicCDebugInfoDataBase();
a61af66fc99e Initial load
duke
parents:
diff changeset
80 db.beginConstruction();
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // Get global types and add them to the database
a61af66fc99e Initial load
duke
parents:
diff changeset
83 DebugVC50SSGlobalTypes types = getGlobalTypes();
a61af66fc99e Initial load
duke
parents:
diff changeset
84 for (iter = types.getTypeIterator(); !iter.done(); iter.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 while (!iter.typeStringDone()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 switch (iter.typeStringLeaf()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 case LF_MODIFIER: {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 int idx = iter.getModifierIndex();
a61af66fc99e Initial load
duke
parents:
diff changeset
89 BasicType target = getTypeByIndex(idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
90 short windowsMods = iter.getModifierAttribute();
a61af66fc99e Initial load
duke
parents:
diff changeset
91 short mods = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 if ((windowsMods & MODIFIER_CONST_MASK) != 0) mods |= CONST;
a61af66fc99e Initial load
duke
parents:
diff changeset
93 if ((windowsMods & MODIFIER_VOLATILE_MASK) != 0) mods |= VOLATILE;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 putType(target.getCVVariant(mods));
a61af66fc99e Initial load
duke
parents:
diff changeset
95 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97 case LF_POINTER: {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 int idx = iter.getPointerType();
a61af66fc99e Initial load
duke
parents:
diff changeset
99 BasicType target = getTypeByIndex(idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
100 short windowsMods = iter.getModifierAttribute();
a61af66fc99e Initial load
duke
parents:
diff changeset
101 short mods = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 if ((windowsMods & POINTER_CONST_MASK) != 0) mods |= CONST;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 if ((windowsMods & POINTER_VOLATILE_MASK) != 0) mods |= VOLATILE;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 BasicPointerType ptrType = new BasicPointerType(POINTER_SIZE, target);
a61af66fc99e Initial load
duke
parents:
diff changeset
105 if (mods != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 ptrType = (BasicPointerType) ptrType.getCVVariant(mods);
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 putType(ptrType);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112 case LF_ARRAY: {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 BasicType elemType = getTypeByIndex(iter.getArrayElementType());
a61af66fc99e Initial load
duke
parents:
diff changeset
114 putType(new BasicArrayType(iter.getArrayName(), elemType, iter.getArrayLength()));
a61af66fc99e Initial load
duke
parents:
diff changeset
115 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117 case LF_CLASS:
a61af66fc99e Initial load
duke
parents:
diff changeset
118 case LF_STRUCTURE: {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 CompoundTypeKind kind = ((iter.typeStringLeaf() == LF_CLASS) ? CompoundTypeKind.CLASS
a61af66fc99e Initial load
duke
parents:
diff changeset
120 : CompoundTypeKind.STRUCT);
a61af66fc99e Initial load
duke
parents:
diff changeset
121 BasicCompoundType type = new BasicCompoundType(iter.getClassName(),
a61af66fc99e Initial load
duke
parents:
diff changeset
122 iter.getClassSize(),
a61af66fc99e Initial load
duke
parents:
diff changeset
123 kind);
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // Skip parsing of forward references to types
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // FIXME: do we have to resolve these later?
a61af66fc99e Initial load
duke
parents:
diff changeset
126 if ((iter.getClassProperty() & PROPERTY_FWDREF) == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 DebugVC50TypeIterator fieldIter = iter.getClassFieldListIterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
128 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
129 Assert.that(fieldIter.typeStringLeaf() == LF_FIELDLIST, "Expected field list");
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131 boolean advance = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
132 while (!fieldIter.typeStringDone()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
133 advance = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 switch (fieldIter.typeStringLeaf()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
135 case LF_FIELDLIST: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 case LF_BCLASS: {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 int accessControl = memberAttributeToAccessControl(fieldIter.getBClassAttribute());
a61af66fc99e Initial load
duke
parents:
diff changeset
138 Type baseType = getTypeByIndex(fieldIter.getBClassType());
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // FIXME: take offset into account
a61af66fc99e Initial load
duke
parents:
diff changeset
140 type.addBaseClass(new BasicBaseClass(accessControl, false, baseType));
a61af66fc99e Initial load
duke
parents:
diff changeset
141 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143 case LF_VBCLASS: {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 int accessControl = memberAttributeToAccessControl(fieldIter.getVBClassAttribute());
a61af66fc99e Initial load
duke
parents:
diff changeset
145 Type baseType = getTypeByIndex(fieldIter.getVBClassBaseClassType());
a61af66fc99e Initial load
duke
parents:
diff changeset
146 // FIXME: take offset and virtual base offset into account
a61af66fc99e Initial load
duke
parents:
diff changeset
147 type.addBaseClass(new BasicBaseClass(accessControl, true, baseType));
a61af66fc99e Initial load
duke
parents:
diff changeset
148 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // I don't think we need to handle indirect virtual base
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // classes since they should be handled indirectly through
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // the modeling of the type hierarchy
a61af66fc99e Initial load
duke
parents:
diff changeset
153 case LF_IVBCLASS: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
154 case LF_INDEX: {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 fieldIter = fieldIter.getIndexIterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
156 advance = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
157 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
159 case LF_MEMBER: {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 BasicField field = new BasicField(fieldIter.getMemberName(),
a61af66fc99e Initial load
duke
parents:
diff changeset
161 getTypeByIndex(fieldIter.getMemberType()),
a61af66fc99e Initial load
duke
parents:
diff changeset
162 memberAttributeToAccessControl(fieldIter.getMemberAttribute()),
a61af66fc99e Initial load
duke
parents:
diff changeset
163 false);
a61af66fc99e Initial load
duke
parents:
diff changeset
164 field.setOffset(fieldIter.getMemberOffset());
a61af66fc99e Initial load
duke
parents:
diff changeset
165 type.addField(field);
a61af66fc99e Initial load
duke
parents:
diff changeset
166 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168 case LF_STMEMBER: {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 BasicField field = new BasicField(fieldIter.getStaticName(),
a61af66fc99e Initial load
duke
parents:
diff changeset
170 getTypeByIndex(fieldIter.getStaticType()),
a61af66fc99e Initial load
duke
parents:
diff changeset
171 memberAttributeToAccessControl(fieldIter.getStaticAttribute()),
a61af66fc99e Initial load
duke
parents:
diff changeset
172 true);
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // The field's address will be found during resolution
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // of the debug info database
a61af66fc99e Initial load
duke
parents:
diff changeset
175 type.addField(field);
a61af66fc99e Initial load
duke
parents:
diff changeset
176 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // FIXME: handle methods
a61af66fc99e Initial load
duke
parents:
diff changeset
179 case LF_METHOD: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
180 case LF_ONEMETHOD: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // FIXME: handle nested types
a61af66fc99e Initial load
duke
parents:
diff changeset
182 case LF_NESTTYPE: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
183 case LF_NESTTYPEEX: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // NOTE: virtual functions not needed/handled yet for
a61af66fc99e Initial load
duke
parents:
diff changeset
185 // this debugging system (because we are not planning to
a61af66fc99e Initial load
duke
parents:
diff changeset
186 // handle calling methods in the target process at
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // runtime)
a61af66fc99e Initial load
duke
parents:
diff changeset
188 case LF_VFUNCTAB: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
189 case LF_FRIENDCLS: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
190 case LF_VFUNCOFF: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
191 case LF_MEMBERMODIFY: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
192 case LF_PAD0: case LF_PAD1: case LF_PAD2: case LF_PAD3:
a61af66fc99e Initial load
duke
parents:
diff changeset
193 case LF_PAD4: case LF_PAD5: case LF_PAD6: case LF_PAD7:
a61af66fc99e Initial load
duke
parents:
diff changeset
194 case LF_PAD8: case LF_PAD9: case LF_PAD10: case LF_PAD11:
a61af66fc99e Initial load
duke
parents:
diff changeset
195 case LF_PAD12: case LF_PAD13: case LF_PAD14: case LF_PAD15: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
196 default: System.err.println("WARNING: unexpected leaf index " +
a61af66fc99e Initial load
duke
parents:
diff changeset
197 fieldIter.typeStringLeaf() +
a61af66fc99e Initial load
duke
parents:
diff changeset
198 " in field list for type " + iter.getTypeIndex());
a61af66fc99e Initial load
duke
parents:
diff changeset
199 }
a61af66fc99e Initial load
duke
parents:
diff changeset
200 if (advance) {
a61af66fc99e Initial load
duke
parents:
diff changeset
201 fieldIter.typeStringNext();
a61af66fc99e Initial load
duke
parents:
diff changeset
202 }
a61af66fc99e Initial load
duke
parents:
diff changeset
203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
205 putType(type);
a61af66fc99e Initial load
duke
parents:
diff changeset
206 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
207 }
a61af66fc99e Initial load
duke
parents:
diff changeset
208 case LF_UNION: {
a61af66fc99e Initial load
duke
parents:
diff changeset
209 BasicCompoundType type = new BasicCompoundType(iter.getUnionName(),
a61af66fc99e Initial load
duke
parents:
diff changeset
210 iter.getUnionSize(),
a61af66fc99e Initial load
duke
parents:
diff changeset
211 CompoundTypeKind.UNION);
a61af66fc99e Initial load
duke
parents:
diff changeset
212 // Skip parsing of forward references to types
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // FIXME: do we have to resolve these later?
a61af66fc99e Initial load
duke
parents:
diff changeset
214 if ((iter.getClassProperty() & PROPERTY_FWDREF) == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 DebugVC50TypeIterator fieldIter = iter.getUnionFieldListIterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
216 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 Assert.that(fieldIter.typeStringLeaf() == LF_FIELDLIST, "Expected field list");
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219 boolean advance = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
220 while (!fieldIter.typeStringDone()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
221 advance = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
222 switch (fieldIter.typeStringLeaf()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 case LF_FIELDLIST: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
224 case LF_BCLASS: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
225 case LF_VBCLASS: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
226 case LF_IVBCLASS: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
227 case LF_INDEX: {
a61af66fc99e Initial load
duke
parents:
diff changeset
228 fieldIter = fieldIter.getIndexIterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
229 advance = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
230 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
231 }
a61af66fc99e Initial load
duke
parents:
diff changeset
232 case LF_MEMBER: {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 BasicField field = new BasicField(fieldIter.getMemberName(),
a61af66fc99e Initial load
duke
parents:
diff changeset
234 getTypeByIndex(fieldIter.getMemberType()),
a61af66fc99e Initial load
duke
parents:
diff changeset
235 memberAttributeToAccessControl(fieldIter.getMemberAttribute()),
a61af66fc99e Initial load
duke
parents:
diff changeset
236 false);
a61af66fc99e Initial load
duke
parents:
diff changeset
237 field.setOffset(fieldIter.getMemberOffset());
a61af66fc99e Initial load
duke
parents:
diff changeset
238 type.addField(field);
a61af66fc99e Initial load
duke
parents:
diff changeset
239 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
240 }
a61af66fc99e Initial load
duke
parents:
diff changeset
241 case LF_STMEMBER: {
a61af66fc99e Initial load
duke
parents:
diff changeset
242 System.err.println("WARNING: I didn't think unions could contain static fields...");
a61af66fc99e Initial load
duke
parents:
diff changeset
243 BasicField field = new BasicField(fieldIter.getStaticName(),
a61af66fc99e Initial load
duke
parents:
diff changeset
244 getTypeByIndex(fieldIter.getStaticType()),
a61af66fc99e Initial load
duke
parents:
diff changeset
245 memberAttributeToAccessControl(fieldIter.getStaticAttribute()),
a61af66fc99e Initial load
duke
parents:
diff changeset
246 true);
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // The field's address will be found during resolution
a61af66fc99e Initial load
duke
parents:
diff changeset
248 // of the debug info database
a61af66fc99e Initial load
duke
parents:
diff changeset
249 type.addField(field);
a61af66fc99e Initial load
duke
parents:
diff changeset
250 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
252 case LF_METHOD: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
253 case LF_ONEMETHOD: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
254 // FIXME: handle nested types
a61af66fc99e Initial load
duke
parents:
diff changeset
255 case LF_NESTTYPE: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
256 case LF_NESTTYPEEX: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
257 case LF_VFUNCTAB: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
258 case LF_FRIENDCLS: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
259 case LF_VFUNCOFF: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
260 case LF_MEMBERMODIFY: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
261 case LF_PAD0: case LF_PAD1: case LF_PAD2: case LF_PAD3:
a61af66fc99e Initial load
duke
parents:
diff changeset
262 case LF_PAD4: case LF_PAD5: case LF_PAD6: case LF_PAD7:
a61af66fc99e Initial load
duke
parents:
diff changeset
263 case LF_PAD8: case LF_PAD9: case LF_PAD10: case LF_PAD11:
a61af66fc99e Initial load
duke
parents:
diff changeset
264 case LF_PAD12: case LF_PAD13: case LF_PAD14: case LF_PAD15: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
265
a61af66fc99e Initial load
duke
parents:
diff changeset
266 default: System.err.println("WARNING: unexpected leaf index " +
a61af66fc99e Initial load
duke
parents:
diff changeset
267 fieldIter.typeStringLeaf() +
a61af66fc99e Initial load
duke
parents:
diff changeset
268 " in field list for union of type " + iter.getTypeIndex());
a61af66fc99e Initial load
duke
parents:
diff changeset
269 }
a61af66fc99e Initial load
duke
parents:
diff changeset
270 if (advance) {
a61af66fc99e Initial load
duke
parents:
diff changeset
271 fieldIter.typeStringNext();
a61af66fc99e Initial load
duke
parents:
diff changeset
272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
274 }
a61af66fc99e Initial load
duke
parents:
diff changeset
275 putType(type);
a61af66fc99e Initial load
duke
parents:
diff changeset
276 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
277 }
a61af66fc99e Initial load
duke
parents:
diff changeset
278 case LF_ENUM: {
a61af66fc99e Initial load
duke
parents:
diff changeset
279 String name = iter.getEnumName();
a61af66fc99e Initial load
duke
parents:
diff changeset
280 BasicEnumType enumType = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
281 if ((name == null) || (name.equals(""))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
282 if (unnamedEnum == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 unnamedEnum = new BasicEnumType(null, getTypeByIndex(iter.getEnumType()));
a61af66fc99e Initial load
duke
parents:
diff changeset
284 }
a61af66fc99e Initial load
duke
parents:
diff changeset
285 enumType = unnamedEnum;
a61af66fc99e Initial load
duke
parents:
diff changeset
286 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
287 enumType = new BasicEnumType(name, getTypeByIndex(iter.getEnumType()));
a61af66fc99e Initial load
duke
parents:
diff changeset
288 }
a61af66fc99e Initial load
duke
parents:
diff changeset
289 DebugVC50TypeIterator fieldIter = iter.getEnumFieldListIterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
290 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
291 Assert.that(fieldIter.typeStringLeaf() == LF_FIELDLIST, "Expected field list");
a61af66fc99e Initial load
duke
parents:
diff changeset
292 }
a61af66fc99e Initial load
duke
parents:
diff changeset
293 boolean advance = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
294 while (!fieldIter.typeStringDone()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
295 advance = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
296 switch (fieldIter.typeStringLeaf()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
297 case LF_FIELDLIST: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
298 case LF_ENUMERATE: {
a61af66fc99e Initial load
duke
parents:
diff changeset
299 String enumName = fieldIter.getEnumerateName();
a61af66fc99e Initial load
duke
parents:
diff changeset
300 long enumVal = fieldIter.getEnumerateValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
301 enumType.addEnum(enumName, enumVal);
a61af66fc99e Initial load
duke
parents:
diff changeset
302 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
303 }
a61af66fc99e Initial load
duke
parents:
diff changeset
304 case LF_INDEX: {
a61af66fc99e Initial load
duke
parents:
diff changeset
305 fieldIter = fieldIter.getIndexIterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
306 advance = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
307 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
308 }
a61af66fc99e Initial load
duke
parents:
diff changeset
309
a61af66fc99e Initial load
duke
parents:
diff changeset
310 case LF_PAD0: case LF_PAD1: case LF_PAD2: case LF_PAD3:
a61af66fc99e Initial load
duke
parents:
diff changeset
311 case LF_PAD4: case LF_PAD5: case LF_PAD6: case LF_PAD7:
a61af66fc99e Initial load
duke
parents:
diff changeset
312 case LF_PAD8: case LF_PAD9: case LF_PAD10: case LF_PAD11:
a61af66fc99e Initial load
duke
parents:
diff changeset
313 case LF_PAD12: case LF_PAD13: case LF_PAD14: case LF_PAD15: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
314
a61af66fc99e Initial load
duke
parents:
diff changeset
315 default: System.err.println("WARNING: unexpected leaf index " +
a61af66fc99e Initial load
duke
parents:
diff changeset
316 fieldIter.typeStringLeaf() +
a61af66fc99e Initial load
duke
parents:
diff changeset
317 " in field list for enum of type " + iter.getTypeIndex());
a61af66fc99e Initial load
duke
parents:
diff changeset
318 }
a61af66fc99e Initial load
duke
parents:
diff changeset
319
a61af66fc99e Initial load
duke
parents:
diff changeset
320 if (advance) {
a61af66fc99e Initial load
duke
parents:
diff changeset
321 fieldIter.typeStringNext();
a61af66fc99e Initial load
duke
parents:
diff changeset
322 }
a61af66fc99e Initial load
duke
parents:
diff changeset
323 }
a61af66fc99e Initial load
duke
parents:
diff changeset
324
a61af66fc99e Initial load
duke
parents:
diff changeset
325 putType(enumType);
a61af66fc99e Initial load
duke
parents:
diff changeset
326 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
327 }
a61af66fc99e Initial load
duke
parents:
diff changeset
328 case LF_PROCEDURE: {
a61af66fc99e Initial load
duke
parents:
diff changeset
329 Type retType = getTypeByIndex(iter.getProcedureReturnType());
a61af66fc99e Initial load
duke
parents:
diff changeset
330 BasicFunctionType func = new BasicFunctionType(null, POINTER_SIZE, retType);
a61af66fc99e Initial load
duke
parents:
diff changeset
331 DebugVC50TypeIterator argIter = iter.getProcedureArgumentListIterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
332 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
333 Assert.that(argIter.typeStringLeaf() == LF_ARGLIST, "Expected argument list");
a61af66fc99e Initial load
duke
parents:
diff changeset
334 }
a61af66fc99e Initial load
duke
parents:
diff changeset
335 for (int i = 0; i < argIter.getArgListCount(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
336 func.addArgumentType(getTypeByIndex(argIter.getArgListType(i)));
a61af66fc99e Initial load
duke
parents:
diff changeset
337 }
a61af66fc99e Initial load
duke
parents:
diff changeset
338 putType(func);
a61af66fc99e Initial load
duke
parents:
diff changeset
339 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
340 }
a61af66fc99e Initial load
duke
parents:
diff changeset
341 case LF_MFUNCTION: {
a61af66fc99e Initial load
duke
parents:
diff changeset
342 Type retType = getTypeByIndex(iter.getMFunctionReturnType());
a61af66fc99e Initial load
duke
parents:
diff changeset
343 Type container = getTypeByIndex(iter.getMFunctionContainingClass());
a61af66fc99e Initial load
duke
parents:
diff changeset
344 Type thisType = getTypeByIndex(iter.getMFunctionThis());
a61af66fc99e Initial load
duke
parents:
diff changeset
345 long thisAdjust = iter.getMFunctionThisAdjust();
a61af66fc99e Initial load
duke
parents:
diff changeset
346 BasicMemberFunctionType func = new BasicMemberFunctionType(null,
a61af66fc99e Initial load
duke
parents:
diff changeset
347 POINTER_SIZE,
a61af66fc99e Initial load
duke
parents:
diff changeset
348 retType,
a61af66fc99e Initial load
duke
parents:
diff changeset
349 container,
a61af66fc99e Initial load
duke
parents:
diff changeset
350 thisType,
a61af66fc99e Initial load
duke
parents:
diff changeset
351 thisAdjust);
a61af66fc99e Initial load
duke
parents:
diff changeset
352 DebugVC50TypeIterator argIter = iter.getMFunctionArgumentListIterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
353 for (int i = 0; i < argIter.getArgListCount(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
354 func.addArgumentType(getTypeByIndex(argIter.getArgListType(i)));
a61af66fc99e Initial load
duke
parents:
diff changeset
355 }
a61af66fc99e Initial load
duke
parents:
diff changeset
356 putType(func);
a61af66fc99e Initial load
duke
parents:
diff changeset
357 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
358 }
a61af66fc99e Initial load
duke
parents:
diff changeset
359 // FIXME: handle virtual function table shape description
a61af66fc99e Initial load
duke
parents:
diff changeset
360 case LF_VTSHAPE: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
361 case LF_BARRAY: System.err.println("FIXME: don't know what to do with LF_BARRAY leaves (convert to pointers?"); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
362 case LF_LABEL: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
363 case LF_NULL: break; // FIXME: do we need to handle this? With what?
a61af66fc99e Initial load
duke
parents:
diff changeset
364 case LF_DIMARRAY: System.err.println("FIXME: don't know what to do with LF_DIMARRAY leaves yet"); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
365 case LF_VFTPATH: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
366 case LF_PRECOMP: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
367 case LF_ENDPRECOMP: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
368 case LF_OEM: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
369 case LF_TYPESERVER: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
370
a61af66fc99e Initial load
duke
parents:
diff changeset
371 // Type records referenced from other type records
a61af66fc99e Initial load
duke
parents:
diff changeset
372
a61af66fc99e Initial load
duke
parents:
diff changeset
373 case LF_SKIP: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
374 case LF_ARGLIST: skipTypeRecord(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
375 case LF_DEFARG: System.err.println("FIXME: handle default arguments (dereference the type)"); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
376 case LF_FIELDLIST: skipTypeRecord(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
377 case LF_DERIVED: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
378 case LF_BITFIELD: {
a61af66fc99e Initial load
duke
parents:
diff changeset
379 Type underlyingType = getTypeByIndex(iter.getBitfieldFieldType());
a61af66fc99e Initial load
duke
parents:
diff changeset
380 BasicBitType bit = new BasicBitType(underlyingType,
a61af66fc99e Initial load
duke
parents:
diff changeset
381 (iter.getBitfieldLength() & 0xFF),
a61af66fc99e Initial load
duke
parents:
diff changeset
382 (iter.getBitfieldPosition() & 0xFF));
a61af66fc99e Initial load
duke
parents:
diff changeset
383 putType(bit);
a61af66fc99e Initial load
duke
parents:
diff changeset
384 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
385 }
a61af66fc99e Initial load
duke
parents:
diff changeset
386 case LF_METHODLIST: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
387 case LF_DIMCONU:
a61af66fc99e Initial load
duke
parents:
diff changeset
388 case LF_DIMCONLU:
a61af66fc99e Initial load
duke
parents:
diff changeset
389 case LF_DIMVARU:
a61af66fc99e Initial load
duke
parents:
diff changeset
390 case LF_DIMVARLU: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
391 case LF_REFSYM: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
392
a61af66fc99e Initial load
duke
parents:
diff changeset
393 case LF_PAD0: case LF_PAD1: case LF_PAD2: case LF_PAD3:
a61af66fc99e Initial load
duke
parents:
diff changeset
394 case LF_PAD4: case LF_PAD5: case LF_PAD6: case LF_PAD7:
a61af66fc99e Initial load
duke
parents:
diff changeset
395 case LF_PAD8: case LF_PAD9: case LF_PAD10: case LF_PAD11:
a61af66fc99e Initial load
duke
parents:
diff changeset
396 case LF_PAD12: case LF_PAD13: case LF_PAD14: case LF_PAD15: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
397
a61af66fc99e Initial load
duke
parents:
diff changeset
398 default: {
a61af66fc99e Initial load
duke
parents:
diff changeset
399 System.err.println("Unexpected leaf index " +
a61af66fc99e Initial load
duke
parents:
diff changeset
400 iter.typeStringLeaf() + " at offset 0x" +
a61af66fc99e Initial load
duke
parents:
diff changeset
401 Integer.toHexString(iter.typeStringOffset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
402 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
403 }
a61af66fc99e Initial load
duke
parents:
diff changeset
404 }
a61af66fc99e Initial load
duke
parents:
diff changeset
405
a61af66fc99e Initial load
duke
parents:
diff changeset
406
a61af66fc99e Initial load
duke
parents:
diff changeset
407 if (!iter.typeStringDone()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
408 iter.typeStringNext();
a61af66fc99e Initial load
duke
parents:
diff changeset
409 }
a61af66fc99e Initial load
duke
parents:
diff changeset
410 }
a61af66fc99e Initial load
duke
parents:
diff changeset
411 }
a61af66fc99e Initial load
duke
parents:
diff changeset
412
a61af66fc99e Initial load
duke
parents:
diff changeset
413 // Add all symbol directories to debug info
a61af66fc99e Initial load
duke
parents:
diff changeset
414 // (FIXME: must figure out how to handle module-by-module
a61af66fc99e Initial load
duke
parents:
diff changeset
415 // arrangement of at least the static symbols to have proper
a61af66fc99e Initial load
duke
parents:
diff changeset
416 // lookup -- should probably also take advantage of the PROCREF
a61af66fc99e Initial load
duke
parents:
diff changeset
417 // and UDT references to understand how to build the global
a61af66fc99e Initial load
duke
parents:
diff changeset
418 // database vs. the module-by-module one)
a61af66fc99e Initial load
duke
parents:
diff changeset
419 DebugVC50SubsectionDirectory dir = vc50.getSubsectionDirectory();
a61af66fc99e Initial load
duke
parents:
diff changeset
420 int moduleNumber = 0; // Debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
421 for (int i = 0; i < dir.getNumEntries(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
422 DebugVC50Subsection ss = dir.getSubsection(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
423 int ssType = ss.getSubsectionType();
a61af66fc99e Initial load
duke
parents:
diff changeset
424 boolean process = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
425
a61af66fc99e Initial load
duke
parents:
diff changeset
426 if ((ssType == SST_GLOBAL_SYM) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
427 (ssType == SST_GLOBAL_PUB) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
428 (ssType == SST_STATIC_SYM)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
429 DebugVC50SSSymbolBase syms = (DebugVC50SSSymbolBase) ss;
a61af66fc99e Initial load
duke
parents:
diff changeset
430 symIter = syms.getSymbolIterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
431 process = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
432 }
a61af66fc99e Initial load
duke
parents:
diff changeset
433
a61af66fc99e Initial load
duke
parents:
diff changeset
434 if (ssType == SST_ALIGN_SYM) {
a61af66fc99e Initial load
duke
parents:
diff changeset
435 DebugVC50SSAlignSym syms = (DebugVC50SSAlignSym) ss;
a61af66fc99e Initial load
duke
parents:
diff changeset
436 symIter = syms.getSymbolIterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
437 process = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
438 }
a61af66fc99e Initial load
duke
parents:
diff changeset
439
a61af66fc99e Initial load
duke
parents:
diff changeset
440 if (process) {
a61af66fc99e Initial load
duke
parents:
diff changeset
441 for (; !symIter.done(); symIter.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
442 switch (symIter.getType()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
443 case S_COMPILE: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
444 case S_SSEARCH: break; // FIXME: may need this later
a61af66fc99e Initial load
duke
parents:
diff changeset
445 case S_END: {
a61af66fc99e Initial load
duke
parents:
diff changeset
446 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
447 // FIXME: workaround for warnings until we figure out
a61af66fc99e Initial load
duke
parents:
diff changeset
448 // what to do with THUNK32 symbols
a61af66fc99e Initial load
duke
parents:
diff changeset
449 if (endsToSkip == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
450 blockStack.pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
451 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
452 --endsToSkip;
a61af66fc99e Initial load
duke
parents:
diff changeset
453 }
a61af66fc99e Initial load
duke
parents:
diff changeset
454 } catch (EmptyStackException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
455 System.err.println("WARNING: mismatched block begins/ends in debug information");
a61af66fc99e Initial load
duke
parents:
diff changeset
456 }
a61af66fc99e Initial load
duke
parents:
diff changeset
457 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
458 }
a61af66fc99e Initial load
duke
parents:
diff changeset
459 case S_SKIP: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
460 case S_CVRESERVE: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
461 case S_OBJNAME: break; // FIXME: may need this later
a61af66fc99e Initial load
duke
parents:
diff changeset
462 case S_ENDARG: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
463 case S_COBOLUDT: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
464 case S_MANYREG: break; // FIXME: may need to add support for this
a61af66fc99e Initial load
duke
parents:
diff changeset
465 case S_RETURN: break; // NOTE: would need this if adding support for calling functions
a61af66fc99e Initial load
duke
parents:
diff changeset
466 case S_ENTRYTHIS: break; // FIXME: may need to add support for this
a61af66fc99e Initial load
duke
parents:
diff changeset
467 case S_REGISTER: break; // FIXME: may need to add support for this
a61af66fc99e Initial load
duke
parents:
diff changeset
468 case S_CONSTANT: break; // FIXME: will need to add support for this
a61af66fc99e Initial load
duke
parents:
diff changeset
469 case S_UDT: break; // FIXME: need to see how these are used; are
a61af66fc99e Initial load
duke
parents:
diff changeset
470 // they redundant, or are they used to describe
a61af66fc99e Initial load
duke
parents:
diff changeset
471 // global variables as opposed to types?
a61af66fc99e Initial load
duke
parents:
diff changeset
472 case S_COBOLUDT2: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
473 case S_MANYREG2: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
474 case S_BPREL32: {
a61af66fc99e Initial load
duke
parents:
diff changeset
475 LocalSym sym = new BasicLocalSym(symIter.getBPRelName(),
a61af66fc99e Initial load
duke
parents:
diff changeset
476 getTypeByIndex(symIter.getBPRelType()),
a61af66fc99e Initial load
duke
parents:
diff changeset
477 symIter.getBPRelOffset());
a61af66fc99e Initial load
duke
parents:
diff changeset
478 addLocalToCurBlock(sym);
a61af66fc99e Initial load
duke
parents:
diff changeset
479 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
480 }
a61af66fc99e Initial load
duke
parents:
diff changeset
481 case S_LDATA32:
a61af66fc99e Initial load
duke
parents:
diff changeset
482 case S_GDATA32: {
a61af66fc99e Initial load
duke
parents:
diff changeset
483 // FIXME: must handle these separately from global data (have
a61af66fc99e Initial load
duke
parents:
diff changeset
484 // module scoping and only add these at the module level)
a61af66fc99e Initial load
duke
parents:
diff changeset
485 boolean isModuleLocal = (symIter.getType() == S_LDATA32);
a61af66fc99e Initial load
duke
parents:
diff changeset
486
a61af66fc99e Initial load
duke
parents:
diff changeset
487 GlobalSym sym = new BasicGlobalSym(symIter.getLGDataName(),
a61af66fc99e Initial load
duke
parents:
diff changeset
488 getTypeByIndex(symIter.getLGDataType()),
a61af66fc99e Initial load
duke
parents:
diff changeset
489 newAddress(symIter.getLGDataOffset(), symIter.getLGDataSegment()),
a61af66fc99e Initial load
duke
parents:
diff changeset
490 isModuleLocal);
a61af66fc99e Initial load
duke
parents:
diff changeset
491 // FIXME: must handle module-local symbols differently
a61af66fc99e Initial load
duke
parents:
diff changeset
492 addGlobalSym(sym);
a61af66fc99e Initial load
duke
parents:
diff changeset
493 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
494 }
a61af66fc99e Initial load
duke
parents:
diff changeset
495 case S_PUB32: break; // FIXME: figure out how these differ from
a61af66fc99e Initial load
duke
parents:
diff changeset
496 // above and how they are used
a61af66fc99e Initial load
duke
parents:
diff changeset
497 case S_LPROC32:
a61af66fc99e Initial load
duke
parents:
diff changeset
498 case S_GPROC32: {
a61af66fc99e Initial load
duke
parents:
diff changeset
499 BasicFunctionSym sym = new BasicFunctionSym(newLazyBlockSym(symIter.getLGProcParentOffset()),
a61af66fc99e Initial load
duke
parents:
diff changeset
500 symIter.getLGProcLength(),
a61af66fc99e Initial load
duke
parents:
diff changeset
501 newAddress(symIter.getLGProcOffset(), symIter.getLGProcSegment()),
a61af66fc99e Initial load
duke
parents:
diff changeset
502 symIter.getLGProcName(),
a61af66fc99e Initial load
duke
parents:
diff changeset
503 getTypeByIndex(symIter.getLGProcType()),
a61af66fc99e Initial load
duke
parents:
diff changeset
504 (symIter.getType() == S_LPROC32));
a61af66fc99e Initial load
duke
parents:
diff changeset
505
a61af66fc99e Initial load
duke
parents:
diff changeset
506 // FIXME: have to handle local procedures differently (have
a61af66fc99e Initial load
duke
parents:
diff changeset
507 // notion of modules and only add those procedures to the
a61af66fc99e Initial load
duke
parents:
diff changeset
508 // module they are defined in)
a61af66fc99e Initial load
duke
parents:
diff changeset
509 addBlock(sym);
a61af66fc99e Initial load
duke
parents:
diff changeset
510 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
511 }
a61af66fc99e Initial load
duke
parents:
diff changeset
512 case S_THUNK32: {
a61af66fc99e Initial load
duke
parents:
diff changeset
513 // FIXME: see whether we need to handle these
a61af66fc99e Initial load
duke
parents:
diff changeset
514 skipEnd();
a61af66fc99e Initial load
duke
parents:
diff changeset
515 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
516 }
a61af66fc99e Initial load
duke
parents:
diff changeset
517 case S_BLOCK32: {
a61af66fc99e Initial load
duke
parents:
diff changeset
518 BasicBlockSym sym = new BasicBlockSym(newLazyBlockSym(symIter.getBlockParentOffset()),
a61af66fc99e Initial load
duke
parents:
diff changeset
519 symIter.getBlockLength(),
a61af66fc99e Initial load
duke
parents:
diff changeset
520 newAddress(symIter.getBlockOffset(), symIter.getBlockSegment()),
a61af66fc99e Initial load
duke
parents:
diff changeset
521 symIter.getBlockName());
a61af66fc99e Initial load
duke
parents:
diff changeset
522 addBlock(sym);
a61af66fc99e Initial load
duke
parents:
diff changeset
523 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
524 }
a61af66fc99e Initial load
duke
parents:
diff changeset
525 case S_WITH32: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
526 case S_LABEL32: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
527 case S_CEXMODEL32: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
528 case S_VFTTABLE32: break; // FIXME: may need to handle this
a61af66fc99e Initial load
duke
parents:
diff changeset
529 // (most likely for run-time type determination)
a61af66fc99e Initial load
duke
parents:
diff changeset
530 case S_REGREL32: break; // FIXME: may need to add support for this
a61af66fc99e Initial load
duke
parents:
diff changeset
531 case S_LTHREAD32: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
532 case S_GTHREAD32: break; // FIXME: may need to add support for these
a61af66fc99e Initial load
duke
parents:
diff changeset
533 case S_PROCREF: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
534 case S_DATAREF: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
535 case S_ALIGN: break;
a61af66fc99e Initial load
duke
parents:
diff changeset
536 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
537 // These two unknown symbol types show up very frequently.
a61af66fc99e Initial load
duke
parents:
diff changeset
538 // Symbol type 0 appears to always be a no-op symbol of
a61af66fc99e Initial load
duke
parents:
diff changeset
539 // length 2 (i.e., length just covers the symbol type.)
a61af66fc99e Initial load
duke
parents:
diff changeset
540 // Symbol type 4115 appears to be a copyright notice for
a61af66fc99e Initial load
duke
parents:
diff changeset
541 // the Microsoft linker.
a61af66fc99e Initial load
duke
parents:
diff changeset
542 if ((symIter.getType() != 0) && (symIter.getType() != 4115)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
543 System.err.println(" NOTE: Unexpected symbol of type " +
a61af66fc99e Initial load
duke
parents:
diff changeset
544 symIter.getType() + " at offset 0x" +
a61af66fc99e Initial load
duke
parents:
diff changeset
545 Integer.toHexString(symIter.getOffset()));
a61af66fc99e Initial load
duke
parents:
diff changeset
546 }
a61af66fc99e Initial load
duke
parents:
diff changeset
547 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
548 }
a61af66fc99e Initial load
duke
parents:
diff changeset
549 }
a61af66fc99e Initial load
duke
parents:
diff changeset
550 }
a61af66fc99e Initial load
duke
parents:
diff changeset
551 }
a61af66fc99e Initial load
duke
parents:
diff changeset
552
a61af66fc99e Initial load
duke
parents:
diff changeset
553 // Add line number information for all modules
a61af66fc99e Initial load
duke
parents:
diff changeset
554 for (int i = 0; i < dir.getNumEntries(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
555 DebugVC50Subsection ss = dir.getSubsection(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
556 if (ss.getSubsectionType() == SST_SRC_MODULE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
557 DebugVC50SSSrcModule srcMod = (DebugVC50SSSrcModule) ss;
a61af66fc99e Initial load
duke
parents:
diff changeset
558 for (int sf = 0; sf < srcMod.getNumSourceFiles(); sf++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
559 DebugVC50SrcModFileDesc desc = srcMod.getSourceFileDesc(sf);
a61af66fc99e Initial load
duke
parents:
diff changeset
560 // Uniquify these to save space
a61af66fc99e Initial load
duke
parents:
diff changeset
561 String name = desc.getSourceFileName().intern();
a61af66fc99e Initial load
duke
parents:
diff changeset
562 for (int cs = 0; cs < desc.getNumCodeSegments(); cs++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
563 DebugVC50SrcModLineNumberMap map = desc.getLineNumberMap(cs);
a61af66fc99e Initial load
duke
parents:
diff changeset
564 SectionHeader seg = file.getHeader().getSectionHeader(map.getSegment());
a61af66fc99e Initial load
duke
parents:
diff changeset
565 for (int lp = 0; lp < map.getNumSourceLinePairs(); lp++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
566 Address startPC = base.addOffsetTo(seg.getVirtualAddress() + map.getCodeOffset(lp));
a61af66fc99e Initial load
duke
parents:
diff changeset
567 // Fake address for endPC -- will be filled in by BasicLineNumberMapping
a61af66fc99e Initial load
duke
parents:
diff changeset
568 Address endPC = base.addOffsetTo(seg.getSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
569 db.addLineNumberInfo(new BasicLineNumberInfo(name, map.getLineNumber(lp), startPC, endPC));
a61af66fc99e Initial load
duke
parents:
diff changeset
570 }
a61af66fc99e Initial load
duke
parents:
diff changeset
571 }
a61af66fc99e Initial load
duke
parents:
diff changeset
572 }
a61af66fc99e Initial load
duke
parents:
diff changeset
573 }
a61af66fc99e Initial load
duke
parents:
diff changeset
574 }
a61af66fc99e Initial load
duke
parents:
diff changeset
575
a61af66fc99e Initial load
duke
parents:
diff changeset
576 // Finish assembly of database
a61af66fc99e Initial load
duke
parents:
diff changeset
577 db.resolve(new ResolveListener() {
a61af66fc99e Initial load
duke
parents:
diff changeset
578 public void resolveFailed(Type containingType, LazyType failedResolve, String detail) {
a61af66fc99e Initial load
duke
parents:
diff changeset
579 System.err.println("WARNING: failed to resolve type of index " +
a61af66fc99e Initial load
duke
parents:
diff changeset
580 ((Integer) failedResolve.getKey()).intValue() +
a61af66fc99e Initial load
duke
parents:
diff changeset
581 " in type " + containingType.getName() + " (class " +
a61af66fc99e Initial load
duke
parents:
diff changeset
582 containingType.getClass().getName() + ") while " + detail);
a61af66fc99e Initial load
duke
parents:
diff changeset
583 }
a61af66fc99e Initial load
duke
parents:
diff changeset
584
a61af66fc99e Initial load
duke
parents:
diff changeset
585 public void resolveFailed(Type containingType, String staticFieldName) {
a61af66fc99e Initial load
duke
parents:
diff changeset
586 System.err.println("WARNING: failed to resolve address of static field \"" +
a61af66fc99e Initial load
duke
parents:
diff changeset
587 staticFieldName + "\" in type " + containingType.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
588 }
a61af66fc99e Initial load
duke
parents:
diff changeset
589
a61af66fc99e Initial load
duke
parents:
diff changeset
590 public void resolveFailed(Sym containingSymbol, LazyType failedResolve, String detail) {
a61af66fc99e Initial load
duke
parents:
diff changeset
591 System.err.println("WARNING: failed to resolve type of index " +
a61af66fc99e Initial load
duke
parents:
diff changeset
592 ((Integer) failedResolve.getKey()).intValue() +
a61af66fc99e Initial load
duke
parents:
diff changeset
593 " in symbol of type " + containingSymbol.getClass().getName() +
a61af66fc99e Initial load
duke
parents:
diff changeset
594 " while " + detail);
a61af66fc99e Initial load
duke
parents:
diff changeset
595 }
a61af66fc99e Initial load
duke
parents:
diff changeset
596
a61af66fc99e Initial load
duke
parents:
diff changeset
597 public void resolveFailed(Sym containingSymbol, LazyBlockSym failedResolve, String detail) {
a61af66fc99e Initial load
duke
parents:
diff changeset
598 System.err.println("WARNING: failed to resolve block at offset 0x" +
a61af66fc99e Initial load
duke
parents:
diff changeset
599 Integer.toHexString(((Integer) failedResolve.getKey()).intValue()) +
a61af66fc99e Initial load
duke
parents:
diff changeset
600 " in symbol of type " + containingSymbol.getClass().getName() +
a61af66fc99e Initial load
duke
parents:
diff changeset
601 " while " + detail);
a61af66fc99e Initial load
duke
parents:
diff changeset
602 }
a61af66fc99e Initial load
duke
parents:
diff changeset
603 });
a61af66fc99e Initial load
duke
parents:
diff changeset
604
a61af66fc99e Initial load
duke
parents:
diff changeset
605 db.endConstruction();
a61af66fc99e Initial load
duke
parents:
diff changeset
606
a61af66fc99e Initial load
duke
parents:
diff changeset
607 return db;
a61af66fc99e Initial load
duke
parents:
diff changeset
608 }
a61af66fc99e Initial load
duke
parents:
diff changeset
609
a61af66fc99e Initial load
duke
parents:
diff changeset
610
a61af66fc99e Initial load
duke
parents:
diff changeset
611 //----------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
612 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
613 //
a61af66fc99e Initial load
duke
parents:
diff changeset
614
a61af66fc99e Initial load
duke
parents:
diff changeset
615 private static DebugVC50 getDebugVC50(COFFFile file) {
a61af66fc99e Initial load
duke
parents:
diff changeset
616 COFFHeader header = file.getHeader();
a61af66fc99e Initial load
duke
parents:
diff changeset
617 OptionalHeader opt = header.getOptionalHeader();
a61af66fc99e Initial load
duke
parents:
diff changeset
618 if (opt == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
619 // Optional header not found
a61af66fc99e Initial load
duke
parents:
diff changeset
620 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
621 }
a61af66fc99e Initial load
duke
parents:
diff changeset
622 OptionalHeaderDataDirectories dd = opt.getDataDirectories();
a61af66fc99e Initial load
duke
parents:
diff changeset
623 if (dd == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
624 // Optional header data directories not found
a61af66fc99e Initial load
duke
parents:
diff changeset
625 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
626 }
a61af66fc99e Initial load
duke
parents:
diff changeset
627 DebugDirectory debug = dd.getDebugDirectory();
a61af66fc99e Initial load
duke
parents:
diff changeset
628 if (debug == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
629 // Debug directory not found
a61af66fc99e Initial load
duke
parents:
diff changeset
630 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
631 }
a61af66fc99e Initial load
duke
parents:
diff changeset
632 for (int i = 0; i < debug.getNumEntries(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
633 DebugDirectoryEntry entry = debug.getEntry(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
634 if (entry.getType() == DebugTypes.IMAGE_DEBUG_TYPE_CODEVIEW) {
a61af66fc99e Initial load
duke
parents:
diff changeset
635 return entry.getDebugVC50();
a61af66fc99e Initial load
duke
parents:
diff changeset
636 }
a61af66fc99e Initial load
duke
parents:
diff changeset
637 }
a61af66fc99e Initial load
duke
parents:
diff changeset
638
a61af66fc99e Initial load
duke
parents:
diff changeset
639 // CodeView information not found in debug directory
a61af66fc99e Initial load
duke
parents:
diff changeset
640 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
641 }
a61af66fc99e Initial load
duke
parents:
diff changeset
642
a61af66fc99e Initial load
duke
parents:
diff changeset
643 private DebugVC50SSSegMap getSegMap() {
a61af66fc99e Initial load
duke
parents:
diff changeset
644 return (DebugVC50SSSegMap) findSubsection(SST_SEG_MAP);
a61af66fc99e Initial load
duke
parents:
diff changeset
645 }
a61af66fc99e Initial load
duke
parents:
diff changeset
646
a61af66fc99e Initial load
duke
parents:
diff changeset
647 private DebugVC50SSGlobalTypes getGlobalTypes() {
a61af66fc99e Initial load
duke
parents:
diff changeset
648 return (DebugVC50SSGlobalTypes) findSubsection(SST_GLOBAL_TYPES);
a61af66fc99e Initial load
duke
parents:
diff changeset
649 }
a61af66fc99e Initial load
duke
parents:
diff changeset
650
a61af66fc99e Initial load
duke
parents:
diff changeset
651 private DebugVC50SSGlobalSym getGlobalSymbols() {
a61af66fc99e Initial load
duke
parents:
diff changeset
652 return (DebugVC50SSGlobalSym) findSubsection(SST_GLOBAL_SYM);
a61af66fc99e Initial load
duke
parents:
diff changeset
653 }
a61af66fc99e Initial load
duke
parents:
diff changeset
654
a61af66fc99e Initial load
duke
parents:
diff changeset
655 private DebugVC50Subsection findSubsection(short ssType) {
a61af66fc99e Initial load
duke
parents:
diff changeset
656 DebugVC50SubsectionDirectory dir = vc50.getSubsectionDirectory();
a61af66fc99e Initial load
duke
parents:
diff changeset
657 for (int i = 0; i < dir.getNumEntries(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
658 DebugVC50Subsection ss = dir.getSubsection(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
659 if (ss.getSubsectionType() == ssType) {
a61af66fc99e Initial load
duke
parents:
diff changeset
660 return ss;
a61af66fc99e Initial load
duke
parents:
diff changeset
661 }
a61af66fc99e Initial load
duke
parents:
diff changeset
662 }
a61af66fc99e Initial load
duke
parents:
diff changeset
663 throw new DebuggerException("Unable to find subsection of type " + ssType);
a61af66fc99e Initial load
duke
parents:
diff changeset
664 }
a61af66fc99e Initial load
duke
parents:
diff changeset
665
a61af66fc99e Initial load
duke
parents:
diff changeset
666 private void putType(Type t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
667 db.addType(new Integer(iter.getTypeIndex()), t);
a61af66fc99e Initial load
duke
parents:
diff changeset
668 }
a61af66fc99e Initial load
duke
parents:
diff changeset
669
a61af66fc99e Initial load
duke
parents:
diff changeset
670 private Address newAddress(int offset, short segment) {
a61af66fc99e Initial load
duke
parents:
diff changeset
671 int seg = segment & 0xFFFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
672 // NOTE: it isn't clear how to use the segMap to map from logical
a61af66fc99e Initial load
duke
parents:
diff changeset
673 // to physical segments. It seems it would make more sense if the
a61af66fc99e Initial load
duke
parents:
diff changeset
674 // SegDescs contained a physical segment number in addition to the
a61af66fc99e Initial load
duke
parents:
diff changeset
675 // offset within the physical segment of the logical one.
a61af66fc99e Initial load
duke
parents:
diff changeset
676
a61af66fc99e Initial load
duke
parents:
diff changeset
677 // Get the section header corresponding to this segment
a61af66fc99e Initial load
duke
parents:
diff changeset
678 SectionHeader section = file.getHeader().getSectionHeader(seg);
a61af66fc99e Initial load
duke
parents:
diff changeset
679
a61af66fc99e Initial load
duke
parents:
diff changeset
680 // Result is relative to image base
a61af66fc99e Initial load
duke
parents:
diff changeset
681 return base.addOffsetTo(section.getVirtualAddress() + offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
682 }
a61af66fc99e Initial load
duke
parents:
diff changeset
683
a61af66fc99e Initial load
duke
parents:
diff changeset
684 private BasicType getTypeByIndex(int intIndex) {
a61af66fc99e Initial load
duke
parents:
diff changeset
685 Integer index = new Integer(intIndex);
a61af66fc99e Initial load
duke
parents:
diff changeset
686
a61af66fc99e Initial load
duke
parents:
diff changeset
687 // Handle primitive types here.
a61af66fc99e Initial load
duke
parents:
diff changeset
688 if (intIndex <= 0x0FFF) {
a61af66fc99e Initial load
duke
parents:
diff changeset
689 BasicType type = (BasicType) primIndexToTypeMap.get(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
690 if (type != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
691 return type;
a61af66fc99e Initial load
duke
parents:
diff changeset
692 }
a61af66fc99e Initial load
duke
parents:
diff changeset
693 // Construct appropriate new primitive type
a61af66fc99e Initial load
duke
parents:
diff changeset
694 int primMode = intIndex & RESERVED_MODE_MASK;
a61af66fc99e Initial load
duke
parents:
diff changeset
695 if (primMode == RESERVED_MODE_DIRECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
696 int primType = intIndex & RESERVED_TYPE_MASK;
a61af66fc99e Initial load
duke
parents:
diff changeset
697 switch (primType) {
a61af66fc99e Initial load
duke
parents:
diff changeset
698 case RESERVED_TYPE_SIGNED_INT:
a61af66fc99e Initial load
duke
parents:
diff changeset
699 case RESERVED_TYPE_UNSIGNED_INT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
700 boolean unsigned = (primType == RESERVED_TYPE_UNSIGNED_INT);
a61af66fc99e Initial load
duke
parents:
diff changeset
701 int size = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
702 String name = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
703 switch (intIndex & RESERVED_SIZE_MASK) {
a61af66fc99e Initial load
duke
parents:
diff changeset
704 case RESERVED_SIZE_INT_1_BYTE: size = 1; name = "char"; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
705 case RESERVED_SIZE_INT_2_BYTE: size = 2; name = "short"; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
706 case RESERVED_SIZE_INT_4_BYTE: size = 4; name = "int"; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
707 case RESERVED_SIZE_INT_8_BYTE: size = 8; name = "__int64"; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
708 default: throw new DebuggerException("Illegal size of integer type " + intIndex);
a61af66fc99e Initial load
duke
parents:
diff changeset
709 }
a61af66fc99e Initial load
duke
parents:
diff changeset
710 type = new BasicIntType(name, size, unsigned);
a61af66fc99e Initial load
duke
parents:
diff changeset
711 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
712 }
a61af66fc99e Initial load
duke
parents:
diff changeset
713 case RESERVED_TYPE_BOOLEAN: {
a61af66fc99e Initial load
duke
parents:
diff changeset
714 int size = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
715 switch (intIndex & RESERVED_SIZE_MASK) {
a61af66fc99e Initial load
duke
parents:
diff changeset
716 case RESERVED_SIZE_INT_1_BYTE: size = 1; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
717 case RESERVED_SIZE_INT_2_BYTE: size = 2; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
718 case RESERVED_SIZE_INT_4_BYTE: size = 4; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
719 case RESERVED_SIZE_INT_8_BYTE: size = 8; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
720 default: throw new DebuggerException("Illegal size of boolean type " + intIndex);
a61af66fc99e Initial load
duke
parents:
diff changeset
721 }
a61af66fc99e Initial load
duke
parents:
diff changeset
722 type = new BasicIntType("bool", size, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
723 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
724 }
a61af66fc99e Initial load
duke
parents:
diff changeset
725 case RESERVED_TYPE_REAL: {
a61af66fc99e Initial load
duke
parents:
diff changeset
726 switch (intIndex & RESERVED_SIZE_MASK) {
a61af66fc99e Initial load
duke
parents:
diff changeset
727 case RESERVED_SIZE_REAL_32_BIT:
a61af66fc99e Initial load
duke
parents:
diff changeset
728 type = new BasicFloatType("float", 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
729 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
730 case RESERVED_SIZE_REAL_64_BIT:
a61af66fc99e Initial load
duke
parents:
diff changeset
731 type = new BasicDoubleType("double", 8);
a61af66fc99e Initial load
duke
parents:
diff changeset
732 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
733 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
734 throw new DebuggerException("Unsupported floating-point size in type " + intIndex);
a61af66fc99e Initial load
duke
parents:
diff changeset
735 }
a61af66fc99e Initial load
duke
parents:
diff changeset
736 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
737 }
a61af66fc99e Initial load
duke
parents:
diff changeset
738 case RESERVED_TYPE_REALLY_INT: {
a61af66fc99e Initial load
duke
parents:
diff changeset
739 switch (intIndex & RESERVED_SIZE_MASK) {
a61af66fc99e Initial load
duke
parents:
diff changeset
740 case RESERVED_SIZE_REALLY_INT_CHAR: type = new BasicIntType("char", 1, false); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
741 case RESERVED_SIZE_REALLY_INT_WCHAR: type = new BasicIntType("wchar", 2, false); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
742 case RESERVED_SIZE_REALLY_INT_2_BYTE: type = new BasicIntType("short", 2, false); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
743 case RESERVED_SIZE_REALLY_INT_2_BYTE_U: type = new BasicIntType("short", 2, true); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
744 case RESERVED_SIZE_REALLY_INT_4_BYTE: type = new BasicIntType("int", 4, false); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
745 case RESERVED_SIZE_REALLY_INT_4_BYTE_U: type = new BasicIntType("int", 4, true); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
746 case RESERVED_SIZE_REALLY_INT_8_BYTE: type = new BasicIntType("__int64", 8, false); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
747 case RESERVED_SIZE_REALLY_INT_8_BYTE_U: type = new BasicIntType("__int64", 8, true); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
748 default: throw new DebuggerException("Illegal REALLY_INT size in type " + intIndex);
a61af66fc99e Initial load
duke
parents:
diff changeset
749 }
a61af66fc99e Initial load
duke
parents:
diff changeset
750 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
751 }
a61af66fc99e Initial load
duke
parents:
diff changeset
752 case RESERVED_TYPE_SPECIAL: {
a61af66fc99e Initial load
duke
parents:
diff changeset
753 switch (intIndex & RESERVED_SIZE_MASK) {
a61af66fc99e Initial load
duke
parents:
diff changeset
754 case RESERVED_SIZE_SPECIAL_NO_TYPE:
a61af66fc99e Initial load
duke
parents:
diff changeset
755 case RESERVED_SIZE_SPECIAL_VOID: type = new BasicVoidType(); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
756 default: throw new DebuggerException("Don't know how to handle reserved special type " + intIndex);
a61af66fc99e Initial load
duke
parents:
diff changeset
757 }
a61af66fc99e Initial load
duke
parents:
diff changeset
758 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
759 }
a61af66fc99e Initial load
duke
parents:
diff changeset
760
a61af66fc99e Initial load
duke
parents:
diff changeset
761 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
762 throw new DebuggerException("Don't know how to handle reserved type " + intIndex);
a61af66fc99e Initial load
duke
parents:
diff changeset
763 }
a61af66fc99e Initial load
duke
parents:
diff changeset
764 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
765 // Fold all pointer types together since we only support
a61af66fc99e Initial load
duke
parents:
diff changeset
766 // flat-mode addressing anyway
a61af66fc99e Initial load
duke
parents:
diff changeset
767 Type targetType = getTypeByIndex(intIndex & (~RESERVED_MODE_MASK));
a61af66fc99e Initial load
duke
parents:
diff changeset
768
a61af66fc99e Initial load
duke
parents:
diff changeset
769 type = new BasicPointerType(POINTER_SIZE, targetType);
a61af66fc99e Initial load
duke
parents:
diff changeset
770 }
a61af66fc99e Initial load
duke
parents:
diff changeset
771 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
772 Assert.that(type != null, "Got null Type for primitive type " + intIndex);
a61af66fc99e Initial load
duke
parents:
diff changeset
773 }
a61af66fc99e Initial load
duke
parents:
diff changeset
774 primIndexToTypeMap.put(index, type);
a61af66fc99e Initial load
duke
parents:
diff changeset
775 return type;
a61af66fc99e Initial load
duke
parents:
diff changeset
776 }
a61af66fc99e Initial load
duke
parents:
diff changeset
777
a61af66fc99e Initial load
duke
parents:
diff changeset
778 // Not primitive type. Construct lazy reference to target type.
a61af66fc99e Initial load
duke
parents:
diff changeset
779 // (Is it worth canonicalizing these as well to save space?)
a61af66fc99e Initial load
duke
parents:
diff changeset
780 return new LazyType(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
781 }
a61af66fc99e Initial load
duke
parents:
diff changeset
782
a61af66fc99e Initial load
duke
parents:
diff changeset
783 private void addBlock(BlockSym block) {
a61af66fc99e Initial load
duke
parents:
diff changeset
784 db.addBlock(new Integer(symIter.getOffset()), block);
a61af66fc99e Initial load
duke
parents:
diff changeset
785 blockStack.push(block);
a61af66fc99e Initial load
duke
parents:
diff changeset
786 }
a61af66fc99e Initial load
duke
parents:
diff changeset
787
a61af66fc99e Initial load
duke
parents:
diff changeset
788 private void skipEnd() {
a61af66fc99e Initial load
duke
parents:
diff changeset
789 ++endsToSkip;
a61af66fc99e Initial load
duke
parents:
diff changeset
790 }
a61af66fc99e Initial load
duke
parents:
diff changeset
791
a61af66fc99e Initial load
duke
parents:
diff changeset
792 private BlockSym newLazyBlockSym(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
793 if (offset == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
794 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
795 }
a61af66fc99e Initial load
duke
parents:
diff changeset
796
a61af66fc99e Initial load
duke
parents:
diff changeset
797 return new LazyBlockSym(new Integer(offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
798 }
a61af66fc99e Initial load
duke
parents:
diff changeset
799
a61af66fc99e Initial load
duke
parents:
diff changeset
800 private int memberAttributeToAccessControl(short memberAttribute) {
a61af66fc99e Initial load
duke
parents:
diff changeset
801 int acc = memberAttribute & MEMATTR_ACCESS_MASK;
a61af66fc99e Initial load
duke
parents:
diff changeset
802 switch (acc) {
a61af66fc99e Initial load
duke
parents:
diff changeset
803 case MEMATTR_ACCESS_NO_PROTECTION: return NO_PROTECTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
804 case MEMATTR_ACCESS_PRIVATE: return PRIVATE;
a61af66fc99e Initial load
duke
parents:
diff changeset
805 case MEMATTR_ACCESS_PROTECTED: return PROTECTED;
a61af66fc99e Initial load
duke
parents:
diff changeset
806 case MEMATTR_ACCESS_PUBLIC: return PUBLIC;
a61af66fc99e Initial load
duke
parents:
diff changeset
807 default: throw new RuntimeException("Should not reach here");
a61af66fc99e Initial load
duke
parents:
diff changeset
808 }
a61af66fc99e Initial load
duke
parents:
diff changeset
809 }
a61af66fc99e Initial load
duke
parents:
diff changeset
810
a61af66fc99e Initial load
duke
parents:
diff changeset
811 private void addLocalToCurBlock(LocalSym local) {
a61af66fc99e Initial load
duke
parents:
diff changeset
812 ((BasicBlockSym) blockStack.peek()).addLocal(local);
a61af66fc99e Initial load
duke
parents:
diff changeset
813 }
a61af66fc99e Initial load
duke
parents:
diff changeset
814
a61af66fc99e Initial load
duke
parents:
diff changeset
815 private void addGlobalSym(GlobalSym sym) {
a61af66fc99e Initial load
duke
parents:
diff changeset
816 db.addGlobalSym(sym);
a61af66fc99e Initial load
duke
parents:
diff changeset
817 }
a61af66fc99e Initial load
duke
parents:
diff changeset
818
a61af66fc99e Initial load
duke
parents:
diff changeset
819 private void skipTypeRecord() {
a61af66fc99e Initial load
duke
parents:
diff changeset
820 while (!iter.typeStringDone()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
821 iter.typeStringNext();
a61af66fc99e Initial load
duke
parents:
diff changeset
822 }
a61af66fc99e Initial load
duke
parents:
diff changeset
823 }
a61af66fc99e Initial load
duke
parents:
diff changeset
824 }