annotate agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/COFFFileParser.java @ 17467:55fb97c4c58d hs25-b65

8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013 Summary: Copyright year updated for files modified during 2013 Reviewed-by: twisti, iveresov
author mikael
date Tue, 24 Dec 2013 11:48:39 -0800
parents d6cd0d55d0b5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
2 * Copyright (c) 2000, 2010, 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.win32.coff;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.nio.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import java.nio.channels.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.utilities.memo.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.utilities.Assert;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 import sun.jvm.hotspot.debugger.DataSource;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 import sun.jvm.hotspot.debugger.MappedByteBufferDataSource;
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 /** Top-level factory which parses COFF files, including object files,
a61af66fc99e Initial load
duke
parents:
diff changeset
38 Portable Executables and DLLs. Returns {@link
a61af66fc99e Initial load
duke
parents:
diff changeset
39 sun.jvm.hotspot.debugger.win32.coff.COFFFile} objects. This class is a
a61af66fc99e Initial load
duke
parents:
diff changeset
40 singleton. */
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 public class COFFFileParser {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 private static COFFFileParser soleInstance;
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // Constants from the file format documentation
a61af66fc99e Initial load
duke
parents:
diff changeset
46 private static final int COFF_HEADER_SIZE = 20;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 private static final int SECTION_HEADER_SIZE = 40;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 private static final int SYMBOL_SIZE = 18;
a61af66fc99e Initial load
duke
parents:
diff changeset
49 private static final int RELOCATION_SIZE = 10;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 private static final int LINE_NUMBER_SIZE = 6;
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 private static final String US_ASCII = "US-ASCII";
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 private COFFFileParser() {}
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 /** This class is a singleton; returns the sole instance. */
a61af66fc99e Initial load
duke
parents:
diff changeset
57 public static COFFFileParser getParser() {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 if (soleInstance == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 soleInstance = new COFFFileParser();
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
a61af66fc99e Initial load
duke
parents:
diff changeset
61 return soleInstance;
a61af66fc99e Initial load
duke
parents:
diff changeset
62 }
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 public COFFFile parse(String filename) throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 File file = new File(filename);
a61af66fc99e Initial load
duke
parents:
diff changeset
67 FileInputStream stream = new FileInputStream(file);
a61af66fc99e Initial load
duke
parents:
diff changeset
68 MappedByteBuffer buf = stream.getChannel().map(FileChannel.MapMode.READ_ONLY,
a61af66fc99e Initial load
duke
parents:
diff changeset
69 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
70 file.length());
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // This is pretty confusing. The file format is little-endian
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // and so is the CPU. In order for the multi-byte accessors to
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // work properly we must NOT change the endianness of the
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // MappedByteBuffer. Need to think about this some more and file
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // a bug if there is one. (FIXME)
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // buf.order(ByteOrder.nativeOrder());
a61af66fc99e Initial load
duke
parents:
diff changeset
78 return parse(new MappedByteBufferDataSource(buf));
a61af66fc99e Initial load
duke
parents:
diff changeset
79 } catch (FileNotFoundException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 throw new COFFException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
81 } catch (IOException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 throw new COFFException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
83 }
a61af66fc99e Initial load
duke
parents:
diff changeset
84 }
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 public COFFFile parse(DataSource source) throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 return new COFFFileImpl(source);
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 class COFFFileImpl implements COFFFile {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 private DataSource file;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 private long filePos;
a61af66fc99e Initial load
duke
parents:
diff changeset
93 private boolean isImage;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 private long imageHeaderOffset;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 private MemoizedObject header = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 return new COFFHeaderImpl();
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99 };
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 COFFFileImpl(DataSource file) throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 this.file = file;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 public boolean isImage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 return isImage;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 public COFFHeader getHeader() {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 return (COFFHeaderImpl) header.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 class COFFHeaderImpl implements COFFHeader {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 private short machine;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 private short numberOfSections;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 private int timeDateStamp;
a61af66fc99e Initial load
duke
parents:
diff changeset
118 private int pointerToSymbolTable;
a61af66fc99e Initial load
duke
parents:
diff changeset
119 private int numberOfSymbols;
a61af66fc99e Initial load
duke
parents:
diff changeset
120 private short sizeOfOptionalHeader;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 private short characteristics;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 private MemoizedObject[] sectionHeaders;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 private MemoizedObject[] symbols;
a61af66fc99e Initial load
duke
parents:
diff changeset
124
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
125 // Init stringTable at decl time since other fields init'ed in the
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
126 // constructor need the String Table.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
127 private MemoizedObject stringTable = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
128 public Object computeValue() {
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
129 // the String Table follows the Symbol Table
0
a61af66fc99e Initial load
duke
parents:
diff changeset
130 int ptr = getPointerToSymbolTable();
a61af66fc99e Initial load
duke
parents:
diff changeset
131 if (ptr == 0) {
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
132 // no Symbol Table so no String Table
0
a61af66fc99e Initial load
duke
parents:
diff changeset
133 return new StringTable(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
134 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
135 return new StringTable(ptr + SYMBOL_SIZE * getNumberOfSymbols());
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138 };
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 COFFHeaderImpl() {
a61af66fc99e Initial load
duke
parents:
diff changeset
141 seek(imageHeaderOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
142 machine = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
143 numberOfSections = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
144 timeDateStamp = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
145 pointerToSymbolTable = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
146 numberOfSymbols = readInt();
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
147 // String Table can be accessed at this point because
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
148 // pointerToSymbolTable and numberOfSymbols fields are set.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
149 sizeOfOptionalHeader = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
150 characteristics = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // Set up section headers
a61af66fc99e Initial load
duke
parents:
diff changeset
153 sectionHeaders = new MemoizedObject[numberOfSections];
a61af66fc99e Initial load
duke
parents:
diff changeset
154 for (int i = 0; i < numberOfSections; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 final int secHdrOffset = (int)
a61af66fc99e Initial load
duke
parents:
diff changeset
156 (imageHeaderOffset + COFF_HEADER_SIZE + sizeOfOptionalHeader + i * SECTION_HEADER_SIZE);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 sectionHeaders[i] = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
158 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 return new SectionHeaderImpl(secHdrOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161 };
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // Set up symbols
a61af66fc99e Initial load
duke
parents:
diff changeset
165 symbols = new MemoizedObject[numberOfSymbols];
a61af66fc99e Initial load
duke
parents:
diff changeset
166 for (int i = 0; i < numberOfSymbols; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
167 final int symbolOffset = pointerToSymbolTable + i * SYMBOL_SIZE;
a61af66fc99e Initial load
duke
parents:
diff changeset
168 symbols[i] = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
170 return new COFFSymbolImpl(symbolOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
171 }
a61af66fc99e Initial load
duke
parents:
diff changeset
172 };
a61af66fc99e Initial load
duke
parents:
diff changeset
173 }
a61af66fc99e Initial load
duke
parents:
diff changeset
174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 public short getMachineType() { return machine; }
a61af66fc99e Initial load
duke
parents:
diff changeset
177 public short getNumberOfSections() { return numberOfSections; }
a61af66fc99e Initial load
duke
parents:
diff changeset
178 public int getTimeDateStamp() { return timeDateStamp; }
a61af66fc99e Initial load
duke
parents:
diff changeset
179 public int getPointerToSymbolTable() { return pointerToSymbolTable; }
a61af66fc99e Initial load
duke
parents:
diff changeset
180 public int getNumberOfSymbols() { return numberOfSymbols; }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 public short getSizeOfOptionalHeader() { return sizeOfOptionalHeader; }
a61af66fc99e Initial load
duke
parents:
diff changeset
182 public OptionalHeader getOptionalHeader() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 if (getSizeOfOptionalHeader() == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186 return new OptionalHeaderImpl((int) (imageHeaderOffset + COFF_HEADER_SIZE));
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188 public short getCharacteristics() { return characteristics; }
a61af66fc99e Initial load
duke
parents:
diff changeset
189 public boolean hasCharacteristic(short characteristic) {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 return ((characteristics & characteristic) != 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
191 }
a61af66fc99e Initial load
duke
parents:
diff changeset
192 public SectionHeader getSectionHeader(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // NOTE zero-basing of index
a61af66fc99e Initial load
duke
parents:
diff changeset
194 return (SectionHeader) sectionHeaders[index - 1].getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
196 public COFFSymbol getCOFFSymbol(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
197 return (COFFSymbol) symbols[index].getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
198 }
a61af66fc99e Initial load
duke
parents:
diff changeset
199 public int getNumberOfStrings() {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 return getStringTable().getNum();
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202 public String getString(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 return getStringTable().get(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 StringTable getStringTable() { return (StringTable) stringTable.getValue(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
207
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // NOTE: can destroy current seek() position!
a61af66fc99e Initial load
duke
parents:
diff changeset
209 int rvaToFileOffset(int rva) {
a61af66fc99e Initial load
duke
parents:
diff changeset
210 if (rva == 0) return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
211 // Search for section containing RVA
a61af66fc99e Initial load
duke
parents:
diff changeset
212 for (int i = 1; i <= getNumberOfSections(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
213 SectionHeader sec = getSectionHeader(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
214 int va = sec.getVirtualAddress();
a61af66fc99e Initial load
duke
parents:
diff changeset
215 int sz = sec.getSize();
a61af66fc99e Initial load
duke
parents:
diff changeset
216 if ((va <= rva) && (rva < (va + sz))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 return sec.getPointerToRawData() + (rva - va);
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
220 throw new COFFException("Unable to find RVA 0x" +
a61af66fc99e Initial load
duke
parents:
diff changeset
221 Integer.toHexString(rva) +
a61af66fc99e Initial load
duke
parents:
diff changeset
222 " in any section");
a61af66fc99e Initial load
duke
parents:
diff changeset
223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
224
a61af66fc99e Initial load
duke
parents:
diff changeset
225 class OptionalHeaderImpl implements OptionalHeader {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 private short magic;
a61af66fc99e Initial load
duke
parents:
diff changeset
227 private MemoizedObject standardFields;
a61af66fc99e Initial load
duke
parents:
diff changeset
228 private MemoizedObject windowsSpecificFields;
a61af66fc99e Initial load
duke
parents:
diff changeset
229 private MemoizedObject dataDirectories;
a61af66fc99e Initial load
duke
parents:
diff changeset
230
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
231 // We use an offset of 2 because OptionalHeaderStandardFieldsImpl doesn't
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
232 // include the 'magic' field.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
233 private static final int STANDARD_FIELDS_OFFSET = 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
234 private static final int PE32_WINDOWS_SPECIFIC_FIELDS_OFFSET = 28;
a61af66fc99e Initial load
duke
parents:
diff changeset
235 private static final int PE32_DATA_DIRECTORIES_OFFSET = 96;
a61af66fc99e Initial load
duke
parents:
diff changeset
236 private static final int PE32_PLUS_WINDOWS_SPECIFIC_FIELDS_OFFSET = 24;
a61af66fc99e Initial load
duke
parents:
diff changeset
237 private static final int PE32_PLUS_DATA_DIRECTORIES_OFFSET = 112;
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 OptionalHeaderImpl(final int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
240 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
241 magic = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
242
a61af66fc99e Initial load
duke
parents:
diff changeset
243 final boolean isPE32Plus = (magic == MAGIC_PE32_PLUS);
a61af66fc99e Initial load
duke
parents:
diff changeset
244 final int standardFieldsOffset = offset + STANDARD_FIELDS_OFFSET;
a61af66fc99e Initial load
duke
parents:
diff changeset
245 final int windowsSpecificFieldsOffset = offset +
a61af66fc99e Initial load
duke
parents:
diff changeset
246 (isPE32Plus
a61af66fc99e Initial load
duke
parents:
diff changeset
247 ? PE32_PLUS_WINDOWS_SPECIFIC_FIELDS_OFFSET
a61af66fc99e Initial load
duke
parents:
diff changeset
248 : PE32_WINDOWS_SPECIFIC_FIELDS_OFFSET);
a61af66fc99e Initial load
duke
parents:
diff changeset
249 final int dataDirectoriesOffset = offset +
a61af66fc99e Initial load
duke
parents:
diff changeset
250 (isPE32Plus
a61af66fc99e Initial load
duke
parents:
diff changeset
251 ? PE32_PLUS_DATA_DIRECTORIES_OFFSET
a61af66fc99e Initial load
duke
parents:
diff changeset
252 : PE32_DATA_DIRECTORIES_OFFSET);
a61af66fc99e Initial load
duke
parents:
diff changeset
253
a61af66fc99e Initial load
duke
parents:
diff changeset
254 standardFields = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
255 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 return new OptionalHeaderStandardFieldsImpl(standardFieldsOffset,
a61af66fc99e Initial load
duke
parents:
diff changeset
257 isPE32Plus);
a61af66fc99e Initial load
duke
parents:
diff changeset
258 }
a61af66fc99e Initial load
duke
parents:
diff changeset
259 };
a61af66fc99e Initial load
duke
parents:
diff changeset
260 windowsSpecificFields = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
262 return new OptionalHeaderWindowsSpecificFieldsImpl(windowsSpecificFieldsOffset,
a61af66fc99e Initial load
duke
parents:
diff changeset
263 isPE32Plus);
a61af66fc99e Initial load
duke
parents:
diff changeset
264 }
a61af66fc99e Initial load
duke
parents:
diff changeset
265 };
a61af66fc99e Initial load
duke
parents:
diff changeset
266 dataDirectories = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
268 return new OptionalHeaderDataDirectoriesImpl(dataDirectoriesOffset,
a61af66fc99e Initial load
duke
parents:
diff changeset
269 getWindowsSpecificFields().getNumberOfRvaAndSizes());
a61af66fc99e Initial load
duke
parents:
diff changeset
270 }
a61af66fc99e Initial load
duke
parents:
diff changeset
271 };
a61af66fc99e Initial load
duke
parents:
diff changeset
272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
273
a61af66fc99e Initial load
duke
parents:
diff changeset
274 public short getMagicNumber() {
a61af66fc99e Initial load
duke
parents:
diff changeset
275 return magic;
a61af66fc99e Initial load
duke
parents:
diff changeset
276 }
a61af66fc99e Initial load
duke
parents:
diff changeset
277
a61af66fc99e Initial load
duke
parents:
diff changeset
278 public OptionalHeaderStandardFields getStandardFields() {
a61af66fc99e Initial load
duke
parents:
diff changeset
279 return (OptionalHeaderStandardFields) standardFields.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
280 }
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282 public OptionalHeaderWindowsSpecificFields getWindowsSpecificFields() {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 return (OptionalHeaderWindowsSpecificFields) windowsSpecificFields.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
284 }
a61af66fc99e Initial load
duke
parents:
diff changeset
285 public OptionalHeaderDataDirectories getDataDirectories() {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 return (OptionalHeaderDataDirectories) dataDirectories.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
287 }
a61af66fc99e Initial load
duke
parents:
diff changeset
288 }
a61af66fc99e Initial load
duke
parents:
diff changeset
289
a61af66fc99e Initial load
duke
parents:
diff changeset
290 class OptionalHeaderStandardFieldsImpl implements OptionalHeaderStandardFields {
a61af66fc99e Initial load
duke
parents:
diff changeset
291 private boolean isPE32Plus;
a61af66fc99e Initial load
duke
parents:
diff changeset
292 private byte majorLinkerVersion;
a61af66fc99e Initial load
duke
parents:
diff changeset
293 private byte minorLinkerVersion;
a61af66fc99e Initial load
duke
parents:
diff changeset
294 private int sizeOfCode;
a61af66fc99e Initial load
duke
parents:
diff changeset
295 private int sizeOfInitializedData;
a61af66fc99e Initial load
duke
parents:
diff changeset
296 private int sizeOfUninitializedData;
a61af66fc99e Initial load
duke
parents:
diff changeset
297 private int addressOfEntryPoint;
a61af66fc99e Initial load
duke
parents:
diff changeset
298 private int baseOfCode;
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
299 private int baseOfData; // only set in PE32
0
a61af66fc99e Initial load
duke
parents:
diff changeset
300
a61af66fc99e Initial load
duke
parents:
diff changeset
301 OptionalHeaderStandardFieldsImpl(int offset,
a61af66fc99e Initial load
duke
parents:
diff changeset
302 boolean isPE32Plus) {
a61af66fc99e Initial load
duke
parents:
diff changeset
303 this.isPE32Plus = isPE32Plus;
a61af66fc99e Initial load
duke
parents:
diff changeset
304 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
305 majorLinkerVersion = readByte();
a61af66fc99e Initial load
duke
parents:
diff changeset
306 minorLinkerVersion = readByte();
a61af66fc99e Initial load
duke
parents:
diff changeset
307 sizeOfCode = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
308 sizeOfInitializedData = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
309 sizeOfUninitializedData = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
310 addressOfEntryPoint = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
311 baseOfCode = readInt();
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
312 if (!isPE32Plus) {
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
313 // only available in PE32
0
a61af66fc99e Initial load
duke
parents:
diff changeset
314 baseOfData = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
315 }
a61af66fc99e Initial load
duke
parents:
diff changeset
316 }
a61af66fc99e Initial load
duke
parents:
diff changeset
317
a61af66fc99e Initial load
duke
parents:
diff changeset
318 public byte getMajorLinkerVersion() { return majorLinkerVersion; }
a61af66fc99e Initial load
duke
parents:
diff changeset
319 public byte getMinorLinkerVersion() { return minorLinkerVersion; }
a61af66fc99e Initial load
duke
parents:
diff changeset
320 public int getSizeOfCode() { return sizeOfCode; }
a61af66fc99e Initial load
duke
parents:
diff changeset
321 public int getSizeOfInitializedData() { return sizeOfInitializedData; }
a61af66fc99e Initial load
duke
parents:
diff changeset
322 public int getSizeOfUninitializedData() { return sizeOfUninitializedData; }
a61af66fc99e Initial load
duke
parents:
diff changeset
323 public int getAddressOfEntryPoint() { return addressOfEntryPoint; }
a61af66fc99e Initial load
duke
parents:
diff changeset
324 public int getBaseOfCode() { return baseOfCode; }
a61af66fc99e Initial load
duke
parents:
diff changeset
325 public int getBaseOfData() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
326 if (isPE32Plus) {
a61af66fc99e Initial load
duke
parents:
diff changeset
327 throw new COFFException("Not present in PE32+ files");
a61af66fc99e Initial load
duke
parents:
diff changeset
328 }
a61af66fc99e Initial load
duke
parents:
diff changeset
329 return baseOfData;
a61af66fc99e Initial load
duke
parents:
diff changeset
330 }
a61af66fc99e Initial load
duke
parents:
diff changeset
331 }
a61af66fc99e Initial load
duke
parents:
diff changeset
332
a61af66fc99e Initial load
duke
parents:
diff changeset
333 class OptionalHeaderWindowsSpecificFieldsImpl implements OptionalHeaderWindowsSpecificFields {
a61af66fc99e Initial load
duke
parents:
diff changeset
334 private long imageBase;
a61af66fc99e Initial load
duke
parents:
diff changeset
335 private int sectionAlignment;
a61af66fc99e Initial load
duke
parents:
diff changeset
336 private int fileAlignment;
a61af66fc99e Initial load
duke
parents:
diff changeset
337 private short majorOperatingSystemVersion;
a61af66fc99e Initial load
duke
parents:
diff changeset
338 private short minorOperatingSystemVersion;
a61af66fc99e Initial load
duke
parents:
diff changeset
339 private short majorImageVersion;
a61af66fc99e Initial load
duke
parents:
diff changeset
340 private short minorImageVersion;
a61af66fc99e Initial load
duke
parents:
diff changeset
341 private short majorSubsystemVersion;
a61af66fc99e Initial load
duke
parents:
diff changeset
342 private short minorSubsystemVersion;
a61af66fc99e Initial load
duke
parents:
diff changeset
343 private int sizeOfImage;
a61af66fc99e Initial load
duke
parents:
diff changeset
344 private int sizeOfHeaders;
a61af66fc99e Initial load
duke
parents:
diff changeset
345 private int checkSum;
a61af66fc99e Initial load
duke
parents:
diff changeset
346 private short subsystem;
a61af66fc99e Initial load
duke
parents:
diff changeset
347 private short dllCharacteristics;
a61af66fc99e Initial load
duke
parents:
diff changeset
348 private long sizeOfStackReserve;
a61af66fc99e Initial load
duke
parents:
diff changeset
349 private long sizeOfStackCommit;
a61af66fc99e Initial load
duke
parents:
diff changeset
350 private long sizeOfHeapReserve;
a61af66fc99e Initial load
duke
parents:
diff changeset
351 private long sizeOfHeapCommit;
a61af66fc99e Initial load
duke
parents:
diff changeset
352 private int loaderFlags;
a61af66fc99e Initial load
duke
parents:
diff changeset
353 private int numberOfRvaAndSizes;
a61af66fc99e Initial load
duke
parents:
diff changeset
354
a61af66fc99e Initial load
duke
parents:
diff changeset
355 OptionalHeaderWindowsSpecificFieldsImpl(int offset, boolean isPE32Plus) {
a61af66fc99e Initial load
duke
parents:
diff changeset
356 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
357
a61af66fc99e Initial load
duke
parents:
diff changeset
358 if (!isPE32Plus) {
a61af66fc99e Initial load
duke
parents:
diff changeset
359 imageBase = maskInt(readInt());
a61af66fc99e Initial load
duke
parents:
diff changeset
360 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
361 imageBase = readLong();
a61af66fc99e Initial load
duke
parents:
diff changeset
362 }
a61af66fc99e Initial load
duke
parents:
diff changeset
363 sectionAlignment = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
364 fileAlignment = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
365 majorOperatingSystemVersion = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
366 minorOperatingSystemVersion = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
367 majorImageVersion = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
368 minorImageVersion = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
369 majorSubsystemVersion = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
370 minorSubsystemVersion = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
371 readInt(); // Reserved
a61af66fc99e Initial load
duke
parents:
diff changeset
372 sizeOfImage = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
373 sizeOfHeaders = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
374 checkSum = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
375 subsystem = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
376 dllCharacteristics = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
377 if (!isPE32Plus) {
a61af66fc99e Initial load
duke
parents:
diff changeset
378 sizeOfStackReserve = maskInt(readInt());
a61af66fc99e Initial load
duke
parents:
diff changeset
379 sizeOfStackCommit = maskInt(readInt());
a61af66fc99e Initial load
duke
parents:
diff changeset
380 sizeOfHeapReserve = maskInt(readInt());
a61af66fc99e Initial load
duke
parents:
diff changeset
381 sizeOfHeapCommit = maskInt(readInt());
a61af66fc99e Initial load
duke
parents:
diff changeset
382 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
383 sizeOfStackReserve = readLong();
a61af66fc99e Initial load
duke
parents:
diff changeset
384 sizeOfStackCommit = readLong();
a61af66fc99e Initial load
duke
parents:
diff changeset
385 sizeOfHeapReserve = readLong();
a61af66fc99e Initial load
duke
parents:
diff changeset
386 sizeOfHeapCommit = readLong();
a61af66fc99e Initial load
duke
parents:
diff changeset
387 }
a61af66fc99e Initial load
duke
parents:
diff changeset
388 loaderFlags = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
389 numberOfRvaAndSizes = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
390 }
a61af66fc99e Initial load
duke
parents:
diff changeset
391
a61af66fc99e Initial load
duke
parents:
diff changeset
392 public long getImageBase() { return imageBase; }
a61af66fc99e Initial load
duke
parents:
diff changeset
393 public int getSectionAlignment() { return sectionAlignment; }
a61af66fc99e Initial load
duke
parents:
diff changeset
394 public int getFileAlignment() { return fileAlignment; }
a61af66fc99e Initial load
duke
parents:
diff changeset
395 public short getMajorOperatingSystemVersion() { return majorOperatingSystemVersion; }
a61af66fc99e Initial load
duke
parents:
diff changeset
396 public short getMinorOperatingSystemVersion() { return minorOperatingSystemVersion; }
a61af66fc99e Initial load
duke
parents:
diff changeset
397 public short getMajorImageVersion() { return majorImageVersion; }
a61af66fc99e Initial load
duke
parents:
diff changeset
398 public short getMinorImageVersion() { return minorImageVersion; }
a61af66fc99e Initial load
duke
parents:
diff changeset
399 public short getMajorSubsystemVersion() { return majorSubsystemVersion; }
a61af66fc99e Initial load
duke
parents:
diff changeset
400 public short getMinorSubsystemVersion() { return minorSubsystemVersion; }
a61af66fc99e Initial load
duke
parents:
diff changeset
401 public int getSizeOfImage() { return sizeOfImage; }
a61af66fc99e Initial load
duke
parents:
diff changeset
402 public int getSizeOfHeaders() { return sizeOfHeaders; }
a61af66fc99e Initial load
duke
parents:
diff changeset
403 public int getCheckSum() { return checkSum; }
a61af66fc99e Initial load
duke
parents:
diff changeset
404 public short getSubsystem() { return subsystem; }
a61af66fc99e Initial load
duke
parents:
diff changeset
405 public short getDLLCharacteristics() { return dllCharacteristics; }
a61af66fc99e Initial load
duke
parents:
diff changeset
406 public long getSizeOfStackReserve() { return sizeOfStackReserve; }
a61af66fc99e Initial load
duke
parents:
diff changeset
407 public long getSizeOfStackCommit() { return sizeOfStackCommit; }
a61af66fc99e Initial load
duke
parents:
diff changeset
408 public long getSizeOfHeapReserve() { return sizeOfHeapReserve; }
a61af66fc99e Initial load
duke
parents:
diff changeset
409 public long getSizeOfHeapCommit() { return sizeOfHeapCommit; }
a61af66fc99e Initial load
duke
parents:
diff changeset
410 public int getLoaderFlags() { return loaderFlags; }
a61af66fc99e Initial load
duke
parents:
diff changeset
411 public int getNumberOfRvaAndSizes() { return numberOfRvaAndSizes; }
a61af66fc99e Initial load
duke
parents:
diff changeset
412
a61af66fc99e Initial load
duke
parents:
diff changeset
413 private long maskInt(long arg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
414 return (arg & 0x00000000FFFFFFFFL);
a61af66fc99e Initial load
duke
parents:
diff changeset
415 }
a61af66fc99e Initial load
duke
parents:
diff changeset
416 }
a61af66fc99e Initial load
duke
parents:
diff changeset
417
a61af66fc99e Initial load
duke
parents:
diff changeset
418 class OptionalHeaderDataDirectoriesImpl implements OptionalHeaderDataDirectories {
a61af66fc99e Initial load
duke
parents:
diff changeset
419 private int numberOfRvaAndSizes;
a61af66fc99e Initial load
duke
parents:
diff changeset
420 private MemoizedObject[] dataDirectories;
a61af66fc99e Initial load
duke
parents:
diff changeset
421 private MemoizedObject exportDirectoryTable;
a61af66fc99e Initial load
duke
parents:
diff changeset
422 private MemoizedObject debugDirectory;
a61af66fc99e Initial load
duke
parents:
diff changeset
423
a61af66fc99e Initial load
duke
parents:
diff changeset
424 private static final int DATA_DIRECTORY_SIZE = 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
425
a61af66fc99e Initial load
duke
parents:
diff changeset
426 OptionalHeaderDataDirectoriesImpl(int offset,
a61af66fc99e Initial load
duke
parents:
diff changeset
427 int numberOfRvaAndSizes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
428 this.numberOfRvaAndSizes = numberOfRvaAndSizes;
a61af66fc99e Initial load
duke
parents:
diff changeset
429 dataDirectories = new MemoizedObject[numberOfRvaAndSizes];
a61af66fc99e Initial load
duke
parents:
diff changeset
430 for (int i = 0; i < numberOfRvaAndSizes; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
431 final int dirOffset = offset + (i * DATA_DIRECTORY_SIZE);
a61af66fc99e Initial load
duke
parents:
diff changeset
432 dataDirectories[i] = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
433 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
434 return new DataDirectoryImpl(dirOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
435 }
a61af66fc99e Initial load
duke
parents:
diff changeset
436 };
a61af66fc99e Initial load
duke
parents:
diff changeset
437 }
a61af66fc99e Initial load
duke
parents:
diff changeset
438
a61af66fc99e Initial load
duke
parents:
diff changeset
439 exportDirectoryTable = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
440 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
441 DataDirectory dir = getExportTable();
a61af66fc99e Initial load
duke
parents:
diff changeset
442 if (dir.getRVA() == 0 || dir.getSize() == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
443 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
444 }
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
445 // ExportDirectoryTableImpl needs both the RVA and the
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
446 // RVA converted to a file offset.
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
447 return new
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
448 ExportDirectoryTableImpl(dir.getRVA(), dir.getSize());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
449 }
a61af66fc99e Initial load
duke
parents:
diff changeset
450 };
a61af66fc99e Initial load
duke
parents:
diff changeset
451
a61af66fc99e Initial load
duke
parents:
diff changeset
452 debugDirectory = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
453 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
454 DataDirectory dir = getDebug();
a61af66fc99e Initial load
duke
parents:
diff changeset
455 if (dir.getRVA() == 0 || dir.getSize() == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
456 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
457 }
a61af66fc99e Initial load
duke
parents:
diff changeset
458 return new DebugDirectoryImpl(rvaToFileOffset(dir.getRVA()), dir.getSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
459 }
a61af66fc99e Initial load
duke
parents:
diff changeset
460 };
a61af66fc99e Initial load
duke
parents:
diff changeset
461 }
a61af66fc99e Initial load
duke
parents:
diff changeset
462
a61af66fc99e Initial load
duke
parents:
diff changeset
463 public DataDirectory getExportTable() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
464 return (DataDirectory) dataDirectories[checkIndex(0)].getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
465 }
a61af66fc99e Initial load
duke
parents:
diff changeset
466 public DataDirectory getImportTable() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
467 return (DataDirectory) dataDirectories[checkIndex(1)].getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
468 }
a61af66fc99e Initial load
duke
parents:
diff changeset
469 public DataDirectory getResourceTable() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
470 return (DataDirectory) dataDirectories[checkIndex(2)].getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
471 }
a61af66fc99e Initial load
duke
parents:
diff changeset
472 public DataDirectory getExceptionTable() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
473 return (DataDirectory) dataDirectories[checkIndex(3)].getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
474 }
a61af66fc99e Initial load
duke
parents:
diff changeset
475 public DataDirectory getCertificateTable() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
476 return (DataDirectory) dataDirectories[checkIndex(4)].getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
477 }
a61af66fc99e Initial load
duke
parents:
diff changeset
478 public DataDirectory getBaseRelocationTable() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
479 return (DataDirectory) dataDirectories[checkIndex(5)].getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
480 }
a61af66fc99e Initial load
duke
parents:
diff changeset
481 public DataDirectory getDebug() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
482 return (DataDirectory) dataDirectories[checkIndex(6)].getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
483 }
a61af66fc99e Initial load
duke
parents:
diff changeset
484 public DataDirectory getArchitecture() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
485 return (DataDirectory) dataDirectories[checkIndex(7)].getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
486 }
a61af66fc99e Initial load
duke
parents:
diff changeset
487 public DataDirectory getGlobalPtr() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
488 return (DataDirectory) dataDirectories[checkIndex(8)].getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
489 }
a61af66fc99e Initial load
duke
parents:
diff changeset
490 public DataDirectory getTLSTable() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
491 return (DataDirectory) dataDirectories[checkIndex(9)].getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
492 }
a61af66fc99e Initial load
duke
parents:
diff changeset
493 public DataDirectory getLoadConfigTable() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
494 return (DataDirectory) dataDirectories[checkIndex(10)].getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
495 }
a61af66fc99e Initial load
duke
parents:
diff changeset
496 public DataDirectory getBoundImportTable() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
497 return (DataDirectory) dataDirectories[checkIndex(11)].getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
498 }
a61af66fc99e Initial load
duke
parents:
diff changeset
499 public DataDirectory getImportAddressTable() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
500 return (DataDirectory) dataDirectories[checkIndex(12)].getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
501 }
a61af66fc99e Initial load
duke
parents:
diff changeset
502 public DataDirectory getDelayImportDescriptor() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
503 return (DataDirectory) dataDirectories[checkIndex(13)].getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
504 }
a61af66fc99e Initial load
duke
parents:
diff changeset
505 public DataDirectory getCOMPlusRuntimeHeader() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
506 return (DataDirectory) dataDirectories[checkIndex(14)].getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
507 }
a61af66fc99e Initial load
duke
parents:
diff changeset
508
a61af66fc99e Initial load
duke
parents:
diff changeset
509 public ExportDirectoryTable getExportDirectoryTable() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
510 return (ExportDirectoryTable) exportDirectoryTable.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
511 }
a61af66fc99e Initial load
duke
parents:
diff changeset
512
a61af66fc99e Initial load
duke
parents:
diff changeset
513 public DebugDirectory getDebugDirectory() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
514 return (DebugDirectory) debugDirectory.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
515 }
a61af66fc99e Initial load
duke
parents:
diff changeset
516
a61af66fc99e Initial load
duke
parents:
diff changeset
517 private int checkIndex(int index) throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
518 if ((index < 0) || (index >= dataDirectories.length)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
519 throw new COFFException("Directory " + index + " unavailable (only " +
a61af66fc99e Initial load
duke
parents:
diff changeset
520 numberOfRvaAndSizes + " tables present)");
a61af66fc99e Initial load
duke
parents:
diff changeset
521 }
a61af66fc99e Initial load
duke
parents:
diff changeset
522 return index;
a61af66fc99e Initial load
duke
parents:
diff changeset
523 }
a61af66fc99e Initial load
duke
parents:
diff changeset
524 }
a61af66fc99e Initial load
duke
parents:
diff changeset
525
a61af66fc99e Initial load
duke
parents:
diff changeset
526 class DataDirectoryImpl implements DataDirectory {
a61af66fc99e Initial load
duke
parents:
diff changeset
527 int rva;
a61af66fc99e Initial load
duke
parents:
diff changeset
528 int size;
a61af66fc99e Initial load
duke
parents:
diff changeset
529
a61af66fc99e Initial load
duke
parents:
diff changeset
530 DataDirectoryImpl(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
531 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
532 rva = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
533 size = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
534 }
a61af66fc99e Initial load
duke
parents:
diff changeset
535
a61af66fc99e Initial load
duke
parents:
diff changeset
536 public int getRVA() { return rva; }
a61af66fc99e Initial load
duke
parents:
diff changeset
537 public int getSize() { return size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
538 }
a61af66fc99e Initial load
duke
parents:
diff changeset
539
a61af66fc99e Initial load
duke
parents:
diff changeset
540 class ExportDirectoryTableImpl implements ExportDirectoryTable {
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
541 private int exportDataDirRVA;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
542 private int offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
543 private int size;
a61af66fc99e Initial load
duke
parents:
diff changeset
544
a61af66fc99e Initial load
duke
parents:
diff changeset
545 private int exportFlags;
a61af66fc99e Initial load
duke
parents:
diff changeset
546 private int timeDateStamp;
a61af66fc99e Initial load
duke
parents:
diff changeset
547 private short majorVersion;
a61af66fc99e Initial load
duke
parents:
diff changeset
548 private short minorVersion;
a61af66fc99e Initial load
duke
parents:
diff changeset
549 private int nameRVA;
a61af66fc99e Initial load
duke
parents:
diff changeset
550 private int ordinalBase;
a61af66fc99e Initial load
duke
parents:
diff changeset
551 private int addressTableEntries;
a61af66fc99e Initial load
duke
parents:
diff changeset
552 private int numberOfNamePointers;
a61af66fc99e Initial load
duke
parents:
diff changeset
553 private int exportAddressTableRVA;
a61af66fc99e Initial load
duke
parents:
diff changeset
554 private int namePointerTableRVA;
a61af66fc99e Initial load
duke
parents:
diff changeset
555 private int ordinalTableRVA;
a61af66fc99e Initial load
duke
parents:
diff changeset
556
a61af66fc99e Initial load
duke
parents:
diff changeset
557 private MemoizedObject dllName;
a61af66fc99e Initial load
duke
parents:
diff changeset
558
a61af66fc99e Initial load
duke
parents:
diff changeset
559 private MemoizedObject exportNameTable;
a61af66fc99e Initial load
duke
parents:
diff changeset
560 private MemoizedObject exportNamePointerTable;
a61af66fc99e Initial load
duke
parents:
diff changeset
561 private MemoizedObject exportOrdinalTable;
a61af66fc99e Initial load
duke
parents:
diff changeset
562 private MemoizedObject exportAddressTable;
a61af66fc99e Initial load
duke
parents:
diff changeset
563
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
564 ExportDirectoryTableImpl(int exportDataDirRVA, int size) {
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
565 this.exportDataDirRVA = exportDataDirRVA;
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
566 offset = rvaToFileOffset(exportDataDirRVA);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
567 this.size = size;
a61af66fc99e Initial load
duke
parents:
diff changeset
568 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
569 exportFlags = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
570 timeDateStamp = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
571 majorVersion = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
572 minorVersion = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
573 nameRVA = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
574 ordinalBase = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
575 addressTableEntries = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
576 numberOfNamePointers = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
577 exportAddressTableRVA = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
578 namePointerTableRVA = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
579 ordinalTableRVA = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
580
a61af66fc99e Initial load
duke
parents:
diff changeset
581 dllName = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
582 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
583 seek(rvaToFileOffset(getNameRVA()));
a61af66fc99e Initial load
duke
parents:
diff changeset
584 return readCString();
a61af66fc99e Initial load
duke
parents:
diff changeset
585 }
a61af66fc99e Initial load
duke
parents:
diff changeset
586 };
a61af66fc99e Initial load
duke
parents:
diff changeset
587
a61af66fc99e Initial load
duke
parents:
diff changeset
588 exportNamePointerTable = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
589 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
590 int[] pointers = new int[getNumberOfNamePointers()];
a61af66fc99e Initial load
duke
parents:
diff changeset
591 seek(rvaToFileOffset(getNamePointerTableRVA()));
a61af66fc99e Initial load
duke
parents:
diff changeset
592 // Must make two passes to avoid rvaToFileOffset
a61af66fc99e Initial load
duke
parents:
diff changeset
593 // destroying seek() position
a61af66fc99e Initial load
duke
parents:
diff changeset
594 for (int i = 0; i < pointers.length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
595 pointers[i] = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
596 }
a61af66fc99e Initial load
duke
parents:
diff changeset
597 for (int i = 0; i < pointers.length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
598 pointers[i] = rvaToFileOffset(pointers[i]);
a61af66fc99e Initial load
duke
parents:
diff changeset
599 }
a61af66fc99e Initial load
duke
parents:
diff changeset
600 return pointers;
a61af66fc99e Initial load
duke
parents:
diff changeset
601 }
a61af66fc99e Initial load
duke
parents:
diff changeset
602 };
a61af66fc99e Initial load
duke
parents:
diff changeset
603
a61af66fc99e Initial load
duke
parents:
diff changeset
604 exportNameTable = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
605 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
606 return new ExportNameTable(getExportNamePointerTable());
a61af66fc99e Initial load
duke
parents:
diff changeset
607 }
a61af66fc99e Initial load
duke
parents:
diff changeset
608 };
a61af66fc99e Initial load
duke
parents:
diff changeset
609
a61af66fc99e Initial load
duke
parents:
diff changeset
610 exportOrdinalTable = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
611 public Object computeValue() {
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
612 // number of ordinals is same as the number of name pointers
0
a61af66fc99e Initial load
duke
parents:
diff changeset
613 short[] ordinals = new short[getNumberOfNamePointers()];
a61af66fc99e Initial load
duke
parents:
diff changeset
614 seek(rvaToFileOffset(getOrdinalTableRVA()));
a61af66fc99e Initial load
duke
parents:
diff changeset
615 for (int i = 0; i < ordinals.length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
616 ordinals[i] = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
617 }
a61af66fc99e Initial load
duke
parents:
diff changeset
618 return ordinals;
a61af66fc99e Initial load
duke
parents:
diff changeset
619 }
a61af66fc99e Initial load
duke
parents:
diff changeset
620 };
a61af66fc99e Initial load
duke
parents:
diff changeset
621
a61af66fc99e Initial load
duke
parents:
diff changeset
622 exportAddressTable = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
623 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
624 int[] addresses = new int[getNumberOfAddressTableEntries()];
a61af66fc99e Initial load
duke
parents:
diff changeset
625 seek(rvaToFileOffset(getExportAddressTableRVA()));
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
626 // The Export Address Table values are a union of two
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
627 // possible values:
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
628 // Export RVA - The address of the exported symbol when
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
629 // loaded into memory, relative to the image base.
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
630 // This value doesn't get converted into a file offset.
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
631 // Forwarder RVA - The pointer to a null-terminated ASCII
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
632 // string in the export section. This value gets
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
633 // converted into a file offset because we have to
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
634 // fetch the string.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
635 for (int i = 0; i < addresses.length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
636 addresses[i] = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
637 }
a61af66fc99e Initial load
duke
parents:
diff changeset
638 return addresses;
a61af66fc99e Initial load
duke
parents:
diff changeset
639 }
a61af66fc99e Initial load
duke
parents:
diff changeset
640 };
a61af66fc99e Initial load
duke
parents:
diff changeset
641 }
a61af66fc99e Initial load
duke
parents:
diff changeset
642
a61af66fc99e Initial load
duke
parents:
diff changeset
643 public int getExportFlags() { return exportFlags; }
a61af66fc99e Initial load
duke
parents:
diff changeset
644 public int getTimeDateStamp() { return timeDateStamp; }
a61af66fc99e Initial load
duke
parents:
diff changeset
645 public short getMajorVersion() { return majorVersion; }
a61af66fc99e Initial load
duke
parents:
diff changeset
646 public short getMinorVersion() { return minorVersion; }
a61af66fc99e Initial load
duke
parents:
diff changeset
647 public int getNameRVA() { return nameRVA; }
a61af66fc99e Initial load
duke
parents:
diff changeset
648
a61af66fc99e Initial load
duke
parents:
diff changeset
649 public String getDLLName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
650 return (String) dllName.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
651 }
a61af66fc99e Initial load
duke
parents:
diff changeset
652
a61af66fc99e Initial load
duke
parents:
diff changeset
653 public int getOrdinalBase() { return ordinalBase; }
a61af66fc99e Initial load
duke
parents:
diff changeset
654 public int getNumberOfAddressTableEntries() { return addressTableEntries; }
a61af66fc99e Initial load
duke
parents:
diff changeset
655 public int getNumberOfNamePointers() { return numberOfNamePointers; }
a61af66fc99e Initial load
duke
parents:
diff changeset
656 public int getExportAddressTableRVA() { return exportAddressTableRVA; }
a61af66fc99e Initial load
duke
parents:
diff changeset
657 public int getNamePointerTableRVA() { return namePointerTableRVA; }
a61af66fc99e Initial load
duke
parents:
diff changeset
658 public int getOrdinalTableRVA() { return ordinalTableRVA; }
a61af66fc99e Initial load
duke
parents:
diff changeset
659
a61af66fc99e Initial load
duke
parents:
diff changeset
660 public String getExportName(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
661 return getExportNameTable().get(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
662 }
a61af66fc99e Initial load
duke
parents:
diff changeset
663
a61af66fc99e Initial load
duke
parents:
diff changeset
664 public short getExportOrdinal(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
665 return getExportOrdinalTable()[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
666 }
a61af66fc99e Initial load
duke
parents:
diff changeset
667
a61af66fc99e Initial load
duke
parents:
diff changeset
668 public boolean isExportAddressForwarder(short ordinal) {
a61af66fc99e Initial load
duke
parents:
diff changeset
669 int addr = getExportAddress(ordinal);
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
670 return ((exportDataDirRVA <= addr) &&
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
671 (addr < (exportDataDirRVA + size)));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
672 }
a61af66fc99e Initial load
duke
parents:
diff changeset
673
a61af66fc99e Initial load
duke
parents:
diff changeset
674 public String getExportAddressForwarder(short ordinal) {
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
675 seek(rvaToFileOffset(getExportAddress(ordinal)));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
676 return readCString();
a61af66fc99e Initial load
duke
parents:
diff changeset
677 }
a61af66fc99e Initial load
duke
parents:
diff changeset
678
a61af66fc99e Initial load
duke
parents:
diff changeset
679 public int getExportAddress(short ordinal) {
a61af66fc99e Initial load
duke
parents:
diff changeset
680
a61af66fc99e Initial load
duke
parents:
diff changeset
681 ///////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
682 // FIXME: MAJOR HACK //
a61af66fc99e Initial load
duke
parents:
diff changeset
683 ///////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
684
a61af66fc99e Initial load
duke
parents:
diff changeset
685 // According to the documentation, the first line here is
a61af66fc99e Initial load
duke
parents:
diff changeset
686 // correct. However, it doesn't seem to work. The second
a61af66fc99e Initial load
duke
parents:
diff changeset
687 // one, however, does.
a61af66fc99e Initial load
duke
parents:
diff changeset
688
a61af66fc99e Initial load
duke
parents:
diff changeset
689 // OK, it's probably due to using negative indices in the
a61af66fc99e Initial load
duke
parents:
diff changeset
690 // export address table in "real life"...need to rethink
a61af66fc99e Initial load
duke
parents:
diff changeset
691 // this when I'm more awake
a61af66fc99e Initial load
duke
parents:
diff changeset
692
a61af66fc99e Initial load
duke
parents:
diff changeset
693 // return getExportAddressTable()[ordinal - ordinalBase];
a61af66fc99e Initial load
duke
parents:
diff changeset
694 return getExportAddressTable()[ordinal];
a61af66fc99e Initial load
duke
parents:
diff changeset
695 }
a61af66fc99e Initial load
duke
parents:
diff changeset
696
a61af66fc99e Initial load
duke
parents:
diff changeset
697 private ExportNameTable getExportNameTable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
698 return (ExportNameTable) exportNameTable.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
699 }
a61af66fc99e Initial load
duke
parents:
diff changeset
700
a61af66fc99e Initial load
duke
parents:
diff changeset
701 private int[] getExportNamePointerTable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
702 return (int[]) exportNamePointerTable.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
703 }
a61af66fc99e Initial load
duke
parents:
diff changeset
704
a61af66fc99e Initial load
duke
parents:
diff changeset
705 private short[] getExportOrdinalTable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
706 return (short[]) exportOrdinalTable.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
707 }
a61af66fc99e Initial load
duke
parents:
diff changeset
708
a61af66fc99e Initial load
duke
parents:
diff changeset
709 private int[] getExportAddressTable() {
a61af66fc99e Initial load
duke
parents:
diff changeset
710 return (int[]) exportAddressTable.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
711 }
a61af66fc99e Initial load
duke
parents:
diff changeset
712 }
a61af66fc99e Initial load
duke
parents:
diff changeset
713
a61af66fc99e Initial load
duke
parents:
diff changeset
714 class ExportNameTable {
a61af66fc99e Initial load
duke
parents:
diff changeset
715 private MemoizedObject[] names;
a61af66fc99e Initial load
duke
parents:
diff changeset
716
a61af66fc99e Initial load
duke
parents:
diff changeset
717 ExportNameTable(final int[] exportNamePointerTable) {
a61af66fc99e Initial load
duke
parents:
diff changeset
718 names = new MemoizedObject[exportNamePointerTable.length];
a61af66fc99e Initial load
duke
parents:
diff changeset
719 for (int i = 0; i < exportNamePointerTable.length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
720 final int idx = i;
a61af66fc99e Initial load
duke
parents:
diff changeset
721 names[idx] = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
722 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
723 seek(exportNamePointerTable[idx]);
a61af66fc99e Initial load
duke
parents:
diff changeset
724 return readCString();
a61af66fc99e Initial load
duke
parents:
diff changeset
725 }
a61af66fc99e Initial load
duke
parents:
diff changeset
726 };
a61af66fc99e Initial load
duke
parents:
diff changeset
727 };
a61af66fc99e Initial load
duke
parents:
diff changeset
728 }
a61af66fc99e Initial load
duke
parents:
diff changeset
729
a61af66fc99e Initial load
duke
parents:
diff changeset
730 String get(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
731 return (String) names[i].getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
732 }
a61af66fc99e Initial load
duke
parents:
diff changeset
733 }
a61af66fc99e Initial load
duke
parents:
diff changeset
734
a61af66fc99e Initial load
duke
parents:
diff changeset
735 class DebugDirectoryImpl implements DebugDirectory {
a61af66fc99e Initial load
duke
parents:
diff changeset
736 private int offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
737 private int size;
a61af66fc99e Initial load
duke
parents:
diff changeset
738 private int numEntries;
a61af66fc99e Initial load
duke
parents:
diff changeset
739
a61af66fc99e Initial load
duke
parents:
diff changeset
740 private static final int DEBUG_DIRECTORY_ENTRY_SIZE = 28;
a61af66fc99e Initial load
duke
parents:
diff changeset
741
a61af66fc99e Initial load
duke
parents:
diff changeset
742 DebugDirectoryImpl(int offset, int size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
743 this.offset = offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
744 this.size = size;
a61af66fc99e Initial load
duke
parents:
diff changeset
745
a61af66fc99e Initial load
duke
parents:
diff changeset
746 if ((size % DEBUG_DIRECTORY_ENTRY_SIZE) != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
747 throw new COFFException("Corrupt DebugDirectory at offset 0x" +
a61af66fc99e Initial load
duke
parents:
diff changeset
748 Integer.toHexString(offset));
a61af66fc99e Initial load
duke
parents:
diff changeset
749 }
a61af66fc99e Initial load
duke
parents:
diff changeset
750
a61af66fc99e Initial load
duke
parents:
diff changeset
751 numEntries = size / DEBUG_DIRECTORY_ENTRY_SIZE;
a61af66fc99e Initial load
duke
parents:
diff changeset
752 }
a61af66fc99e Initial load
duke
parents:
diff changeset
753
a61af66fc99e Initial load
duke
parents:
diff changeset
754 public int getNumEntries() { return numEntries; }
a61af66fc99e Initial load
duke
parents:
diff changeset
755 public DebugDirectoryEntry getEntry(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
756 if ((i < 0) || (i >= getNumEntries())) throw new IndexOutOfBoundsException();
a61af66fc99e Initial load
duke
parents:
diff changeset
757 return new DebugDirectoryEntryImpl(offset + i * DEBUG_DIRECTORY_ENTRY_SIZE);
a61af66fc99e Initial load
duke
parents:
diff changeset
758 }
a61af66fc99e Initial load
duke
parents:
diff changeset
759 }
a61af66fc99e Initial load
duke
parents:
diff changeset
760
a61af66fc99e Initial load
duke
parents:
diff changeset
761 class DebugDirectoryEntryImpl implements DebugDirectoryEntry, DebugTypes {
a61af66fc99e Initial load
duke
parents:
diff changeset
762 private int characteristics;
a61af66fc99e Initial load
duke
parents:
diff changeset
763 private int timeDateStamp;
a61af66fc99e Initial load
duke
parents:
diff changeset
764 private short majorVersion;
a61af66fc99e Initial load
duke
parents:
diff changeset
765 private short minorVersion;
a61af66fc99e Initial load
duke
parents:
diff changeset
766 private int type;
a61af66fc99e Initial load
duke
parents:
diff changeset
767 private int sizeOfData;
a61af66fc99e Initial load
duke
parents:
diff changeset
768 private int addressOfRawData;
a61af66fc99e Initial load
duke
parents:
diff changeset
769 private int pointerToRawData;
a61af66fc99e Initial load
duke
parents:
diff changeset
770
a61af66fc99e Initial load
duke
parents:
diff changeset
771 DebugDirectoryEntryImpl(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
772 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
773 characteristics = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
774 timeDateStamp = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
775 majorVersion = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
776 minorVersion = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
777 type = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
778 sizeOfData = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
779 addressOfRawData = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
780 pointerToRawData = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
781 }
a61af66fc99e Initial load
duke
parents:
diff changeset
782
a61af66fc99e Initial load
duke
parents:
diff changeset
783 public int getCharacteristics() { return characteristics; }
a61af66fc99e Initial load
duke
parents:
diff changeset
784 public int getTimeDateStamp() { return timeDateStamp; }
a61af66fc99e Initial load
duke
parents:
diff changeset
785 public short getMajorVersion() { return majorVersion; }
a61af66fc99e Initial load
duke
parents:
diff changeset
786 public short getMinorVersion() { return minorVersion; }
a61af66fc99e Initial load
duke
parents:
diff changeset
787 public int getType() { return type; }
a61af66fc99e Initial load
duke
parents:
diff changeset
788 public int getSizeOfData() { return sizeOfData; }
a61af66fc99e Initial load
duke
parents:
diff changeset
789 public int getAddressOfRawData() { return addressOfRawData; }
a61af66fc99e Initial load
duke
parents:
diff changeset
790 public int getPointerToRawData() { return pointerToRawData; }
a61af66fc99e Initial load
duke
parents:
diff changeset
791
a61af66fc99e Initial load
duke
parents:
diff changeset
792 public DebugVC50 getDebugVC50() {
a61af66fc99e Initial load
duke
parents:
diff changeset
793 // See whether we can recognize VC++ 5.0 debug information.
a61af66fc99e Initial load
duke
parents:
diff changeset
794 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
795 if (getType() != IMAGE_DEBUG_TYPE_CODEVIEW) return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
796
a61af66fc99e Initial load
duke
parents:
diff changeset
797 int offset = getPointerToRawData();
a61af66fc99e Initial load
duke
parents:
diff changeset
798 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
799 if (readByte() == 'N' &&
a61af66fc99e Initial load
duke
parents:
diff changeset
800 readByte() == 'B' &&
a61af66fc99e Initial load
duke
parents:
diff changeset
801 readByte() == '1' &&
a61af66fc99e Initial load
duke
parents:
diff changeset
802 readByte() == '1') {
a61af66fc99e Initial load
duke
parents:
diff changeset
803 return new DebugVC50Impl(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
804 }
a61af66fc99e Initial load
duke
parents:
diff changeset
805 } catch (COFFException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
806 e.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
807 }
a61af66fc99e Initial load
duke
parents:
diff changeset
808 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
809 }
a61af66fc99e Initial load
duke
parents:
diff changeset
810
a61af66fc99e Initial load
duke
parents:
diff changeset
811 public byte getRawDataByte(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
812 if (i < 0 || i >= getSizeOfData()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
813 throw new IndexOutOfBoundsException();
a61af66fc99e Initial load
duke
parents:
diff changeset
814 }
a61af66fc99e Initial load
duke
parents:
diff changeset
815 seek(getPointerToRawData() + i);
a61af66fc99e Initial load
duke
parents:
diff changeset
816 return readByte();
a61af66fc99e Initial load
duke
parents:
diff changeset
817 }
a61af66fc99e Initial load
duke
parents:
diff changeset
818 }
a61af66fc99e Initial load
duke
parents:
diff changeset
819
a61af66fc99e Initial load
duke
parents:
diff changeset
820 class DebugVC50Impl implements DebugVC50, DebugVC50TypeLeafIndices {
a61af66fc99e Initial load
duke
parents:
diff changeset
821 private int lfaBase;
a61af66fc99e Initial load
duke
parents:
diff changeset
822
a61af66fc99e Initial load
duke
parents:
diff changeset
823 private int subsectionDirectoryOffset;
a61af66fc99e Initial load
duke
parents:
diff changeset
824 private MemoizedObject subsectionDirectory;
a61af66fc99e Initial load
duke
parents:
diff changeset
825
a61af66fc99e Initial load
duke
parents:
diff changeset
826 DebugVC50Impl(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
827 lfaBase = offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
828 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
829 readInt(); // Discard NB11
a61af66fc99e Initial load
duke
parents:
diff changeset
830 subsectionDirectoryOffset = globalOffset(readInt());
a61af66fc99e Initial load
duke
parents:
diff changeset
831
a61af66fc99e Initial load
duke
parents:
diff changeset
832 // Ensure information is complete
a61af66fc99e Initial load
duke
parents:
diff changeset
833 verify();
a61af66fc99e Initial load
duke
parents:
diff changeset
834
a61af66fc99e Initial load
duke
parents:
diff changeset
835 subsectionDirectory = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
836 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
837 return new DebugVC50SubsectionDirectoryImpl(getSubsectionDirectoryOffset());
a61af66fc99e Initial load
duke
parents:
diff changeset
838 }
a61af66fc99e Initial load
duke
parents:
diff changeset
839 };
a61af66fc99e Initial load
duke
parents:
diff changeset
840 }
a61af66fc99e Initial load
duke
parents:
diff changeset
841
a61af66fc99e Initial load
duke
parents:
diff changeset
842 public int getSubsectionDirectoryOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
843 return subsectionDirectoryOffset;
a61af66fc99e Initial load
duke
parents:
diff changeset
844 }
a61af66fc99e Initial load
duke
parents:
diff changeset
845
a61af66fc99e Initial load
duke
parents:
diff changeset
846 public DebugVC50SubsectionDirectory getSubsectionDirectory() {
a61af66fc99e Initial load
duke
parents:
diff changeset
847 return (DebugVC50SubsectionDirectory) subsectionDirectory.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
848 }
a61af66fc99e Initial load
duke
parents:
diff changeset
849
a61af66fc99e Initial load
duke
parents:
diff changeset
850 private int globalOffset(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
851 return offset + lfaBase;
a61af66fc99e Initial load
duke
parents:
diff changeset
852 }
a61af66fc99e Initial load
duke
parents:
diff changeset
853
a61af66fc99e Initial load
duke
parents:
diff changeset
854 private void verify() {
a61af66fc99e Initial load
duke
parents:
diff changeset
855 // Seek to subsection directory manually and look for
a61af66fc99e Initial load
duke
parents:
diff changeset
856 // signature following it. This finishes validating that we
a61af66fc99e Initial load
duke
parents:
diff changeset
857 // have VC++ 5.0 debug info. Throw COFFException if not
a61af66fc99e Initial load
duke
parents:
diff changeset
858 // found; will cause caller to return null.
a61af66fc99e Initial load
duke
parents:
diff changeset
859 seek(subsectionDirectoryOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
860 int headerLength = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
861 int entryLength = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
862 int numEntries = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
863 int endOffset = subsectionDirectoryOffset + headerLength + numEntries * entryLength;
a61af66fc99e Initial load
duke
parents:
diff changeset
864 seek(endOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
865
a61af66fc99e Initial load
duke
parents:
diff changeset
866 if (readByte() == 'N' &&
a61af66fc99e Initial load
duke
parents:
diff changeset
867 readByte() == 'B' &&
a61af66fc99e Initial load
duke
parents:
diff changeset
868 readByte() == '1' &&
a61af66fc99e Initial load
duke
parents:
diff changeset
869 readByte() == '1') {
a61af66fc99e Initial load
duke
parents:
diff changeset
870 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
871 }
a61af66fc99e Initial load
duke
parents:
diff changeset
872
a61af66fc99e Initial load
duke
parents:
diff changeset
873 throw new COFFException("Did not find NB11 signature at end of debug info");
a61af66fc99e Initial load
duke
parents:
diff changeset
874 }
a61af66fc99e Initial load
duke
parents:
diff changeset
875
a61af66fc99e Initial load
duke
parents:
diff changeset
876 class DebugVC50SubsectionDirectoryImpl
a61af66fc99e Initial load
duke
parents:
diff changeset
877 implements DebugVC50SubsectionDirectory,
a61af66fc99e Initial load
duke
parents:
diff changeset
878 DebugVC50SubsectionTypes {
a61af66fc99e Initial load
duke
parents:
diff changeset
879 private int offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
880 private short dirHeaderLength;
a61af66fc99e Initial load
duke
parents:
diff changeset
881 private short dirEntryLength;
a61af66fc99e Initial load
duke
parents:
diff changeset
882 private int numEntries;
a61af66fc99e Initial load
duke
parents:
diff changeset
883
a61af66fc99e Initial load
duke
parents:
diff changeset
884 DebugVC50SubsectionDirectoryImpl(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
885 this.offset = offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
886 // Read header
a61af66fc99e Initial load
duke
parents:
diff changeset
887 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
888 dirHeaderLength = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
889 dirEntryLength = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
890 numEntries = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
891 }
a61af66fc99e Initial load
duke
parents:
diff changeset
892
a61af66fc99e Initial load
duke
parents:
diff changeset
893 public short getHeaderLength() { return dirHeaderLength; }
a61af66fc99e Initial load
duke
parents:
diff changeset
894 public short getEntryLength() { return dirEntryLength; }
a61af66fc99e Initial load
duke
parents:
diff changeset
895 public int getNumEntries() { return numEntries; }
a61af66fc99e Initial load
duke
parents:
diff changeset
896
a61af66fc99e Initial load
duke
parents:
diff changeset
897 public DebugVC50Subsection getSubsection(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
898 // Fetch the subsection type and instantiate the correct
a61af66fc99e Initial load
duke
parents:
diff changeset
899 // type of subsection based on it
a61af66fc99e Initial load
duke
parents:
diff changeset
900 seek(offset + dirHeaderLength + (i * dirEntryLength));
a61af66fc99e Initial load
duke
parents:
diff changeset
901 short ssType = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
902 short iMod = readShort(); // Unneeded?
a61af66fc99e Initial load
duke
parents:
diff changeset
903 int lfo = globalOffset(readInt());
a61af66fc99e Initial load
duke
parents:
diff changeset
904 int cb = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
905 switch (ssType) {
a61af66fc99e Initial load
duke
parents:
diff changeset
906 case SST_MODULE:
a61af66fc99e Initial load
duke
parents:
diff changeset
907 return new DebugVC50SSModuleImpl(ssType, iMod, cb, lfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
908 case SST_TYPES:
a61af66fc99e Initial load
duke
parents:
diff changeset
909 return new DebugVC50SSTypesImpl(ssType, iMod, cb, lfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
910 case SST_PUBLIC:
a61af66fc99e Initial load
duke
parents:
diff changeset
911 return new DebugVC50SSPublicImpl(ssType, iMod, cb, lfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
912 case SST_PUBLIC_SYM:
a61af66fc99e Initial load
duke
parents:
diff changeset
913 return new DebugVC50SSPublicSymImpl(ssType, iMod, cb, lfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
914 case SST_SYMBOLS:
a61af66fc99e Initial load
duke
parents:
diff changeset
915 return new DebugVC50SSSymbolsImpl(ssType, iMod, cb, lfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
916 case SST_ALIGN_SYM:
a61af66fc99e Initial load
duke
parents:
diff changeset
917 return new DebugVC50SSAlignSymImpl(ssType, iMod, cb, lfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
918 case SST_SRC_LN_SEG:
a61af66fc99e Initial load
duke
parents:
diff changeset
919 return new DebugVC50SSSrcLnSegImpl(ssType, iMod, cb, lfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
920 case SST_SRC_MODULE:
a61af66fc99e Initial load
duke
parents:
diff changeset
921 return new DebugVC50SSSrcModuleImpl(ssType, iMod, cb, lfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
922 case SST_LIBRARIES:
a61af66fc99e Initial load
duke
parents:
diff changeset
923 return new DebugVC50SSLibrariesImpl(ssType, iMod, cb, lfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
924 case SST_GLOBAL_SYM:
a61af66fc99e Initial load
duke
parents:
diff changeset
925 return new DebugVC50SSGlobalSymImpl(ssType, iMod, cb, lfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
926 case SST_GLOBAL_PUB:
a61af66fc99e Initial load
duke
parents:
diff changeset
927 return new DebugVC50SSGlobalPubImpl(ssType, iMod, cb, lfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
928 case SST_GLOBAL_TYPES:
a61af66fc99e Initial load
duke
parents:
diff changeset
929 return new DebugVC50SSGlobalTypesImpl(ssType, iMod, cb, lfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
930 case SST_MPC:
a61af66fc99e Initial load
duke
parents:
diff changeset
931 return new DebugVC50SSMPCImpl(ssType, iMod, cb, lfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
932 case SST_SEG_MAP:
a61af66fc99e Initial load
duke
parents:
diff changeset
933 return new DebugVC50SSSegMapImpl(ssType, iMod, cb, lfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
934 case SST_SEG_NAME:
a61af66fc99e Initial load
duke
parents:
diff changeset
935 return new DebugVC50SSSegNameImpl(ssType, iMod, cb, lfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
936 case SST_PRE_COMP:
a61af66fc99e Initial load
duke
parents:
diff changeset
937 return new DebugVC50SSPreCompImpl(ssType, iMod, cb, lfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
938 case SST_UNUSED:
a61af66fc99e Initial load
duke
parents:
diff changeset
939 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
940 case SST_OFFSET_MAP_16:
a61af66fc99e Initial load
duke
parents:
diff changeset
941 return new DebugVC50SSOffsetMap16Impl(ssType, iMod, cb, lfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
942 case SST_OFFSET_MAP_32:
a61af66fc99e Initial load
duke
parents:
diff changeset
943 return new DebugVC50SSOffsetMap32Impl(ssType, iMod, cb, lfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
944 case SST_FILE_INDEX:
a61af66fc99e Initial load
duke
parents:
diff changeset
945 return new DebugVC50SSFileIndexImpl(ssType, iMod, cb, lfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
946 case SST_STATIC_SYM:
a61af66fc99e Initial load
duke
parents:
diff changeset
947 return new DebugVC50SSStaticSymImpl(ssType, iMod, cb, lfo);
a61af66fc99e Initial load
duke
parents:
diff changeset
948 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
949 throw new COFFException("Unknown section type " + ssType);
a61af66fc99e Initial load
duke
parents:
diff changeset
950 }
a61af66fc99e Initial load
duke
parents:
diff changeset
951 }
a61af66fc99e Initial load
duke
parents:
diff changeset
952 }
a61af66fc99e Initial load
duke
parents:
diff changeset
953
a61af66fc99e Initial load
duke
parents:
diff changeset
954 ////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
955 // //
a61af66fc99e Initial load
duke
parents:
diff changeset
956 // Implementations of subsections //
a61af66fc99e Initial load
duke
parents:
diff changeset
957 // //
a61af66fc99e Initial load
duke
parents:
diff changeset
958 ////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
959
a61af66fc99e Initial load
duke
parents:
diff changeset
960 class DebugVC50SubsectionImpl implements DebugVC50Subsection {
a61af66fc99e Initial load
duke
parents:
diff changeset
961 private short ssType;
a61af66fc99e Initial load
duke
parents:
diff changeset
962 private short iMod;
a61af66fc99e Initial load
duke
parents:
diff changeset
963 private int ssSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
964
a61af66fc99e Initial load
duke
parents:
diff changeset
965 DebugVC50SubsectionImpl(short ssType, short iMod, int ssSize, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
966 this.ssType = ssType;
a61af66fc99e Initial load
duke
parents:
diff changeset
967 this.iMod = iMod;
a61af66fc99e Initial load
duke
parents:
diff changeset
968 this.ssSize = ssSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
969 }
a61af66fc99e Initial load
duke
parents:
diff changeset
970
a61af66fc99e Initial load
duke
parents:
diff changeset
971 public short getSubsectionType() { return ssType; }
a61af66fc99e Initial load
duke
parents:
diff changeset
972 public short getSubsectionModuleIndex() { return iMod; }
a61af66fc99e Initial load
duke
parents:
diff changeset
973 public int getSubsectionSize() { return ssSize; }
a61af66fc99e Initial load
duke
parents:
diff changeset
974 }
a61af66fc99e Initial load
duke
parents:
diff changeset
975
a61af66fc99e Initial load
duke
parents:
diff changeset
976 class DebugVC50SSModuleImpl extends DebugVC50SubsectionImpl implements DebugVC50SSModule {
a61af66fc99e Initial load
duke
parents:
diff changeset
977 private int offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
978 private short ovlNumber;
a61af66fc99e Initial load
duke
parents:
diff changeset
979 private short iLib;
a61af66fc99e Initial load
duke
parents:
diff changeset
980 private short cSeg;
a61af66fc99e Initial load
duke
parents:
diff changeset
981 private short style;
a61af66fc99e Initial load
duke
parents:
diff changeset
982 private MemoizedObject segInfo;
a61af66fc99e Initial load
duke
parents:
diff changeset
983 private MemoizedObject name;
a61af66fc99e Initial load
duke
parents:
diff changeset
984
a61af66fc99e Initial load
duke
parents:
diff changeset
985 private static final int HEADER_SIZE = 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
986 private static final int SEG_INFO_SIZE = 12;
a61af66fc99e Initial load
duke
parents:
diff changeset
987
a61af66fc99e Initial load
duke
parents:
diff changeset
988 DebugVC50SSModuleImpl(short ssType, short iMod, int ssSize, final int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
989 super(ssType, iMod, ssSize, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
990 this.offset = offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
991 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
992 ovlNumber = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
993 iLib = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
994 cSeg = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
995 style = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
996 segInfo = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
997 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
998 int base = offset + HEADER_SIZE;
a61af66fc99e Initial load
duke
parents:
diff changeset
999 DebugVC50SegInfo[] res = new DebugVC50SegInfo[cSeg];
a61af66fc99e Initial load
duke
parents:
diff changeset
1000 for (int i = 0; i < cSeg; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1001 res[i] = new DebugVC50SegInfoImpl(base);
a61af66fc99e Initial load
duke
parents:
diff changeset
1002 base += SEG_INFO_SIZE;
a61af66fc99e Initial load
duke
parents:
diff changeset
1003 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1004 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
1005 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1006 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1007 name = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1008 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1009 return readLengthPrefixedStringAt(offset + (HEADER_SIZE + cSeg * SEG_INFO_SIZE));
a61af66fc99e Initial load
duke
parents:
diff changeset
1010 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1011 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1012 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1013
a61af66fc99e Initial load
duke
parents:
diff changeset
1014 public short getOverlayNumber() { return ovlNumber; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1015 public short getLibrariesIndex() { return iLib; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1016 public short getNumCodeSegments() { return cSeg; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1017 public short getDebuggingStyle() { return style; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1018 public DebugVC50SegInfo getSegInfo(int i) { return ((DebugVC50SegInfo[]) segInfo.getValue())[i]; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1019 public String getName() { return (String) name.getValue(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
1020 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1021
a61af66fc99e Initial load
duke
parents:
diff changeset
1022 class DebugVC50SegInfoImpl implements DebugVC50SegInfo {
a61af66fc99e Initial load
duke
parents:
diff changeset
1023 private short seg;
a61af66fc99e Initial load
duke
parents:
diff changeset
1024 private int offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
1025 private int cbSeg;
a61af66fc99e Initial load
duke
parents:
diff changeset
1026
a61af66fc99e Initial load
duke
parents:
diff changeset
1027 DebugVC50SegInfoImpl(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1028 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1029 seg = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1030 readShort(); // pad
a61af66fc99e Initial load
duke
parents:
diff changeset
1031 offset = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1032 cbSeg = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1033 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1034
a61af66fc99e Initial load
duke
parents:
diff changeset
1035 public short getSegment() { return seg; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1036 public int getOffset() { return offset; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1037 public int getSegmentCodeSize() { return cbSeg; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1038 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1039
a61af66fc99e Initial load
duke
parents:
diff changeset
1040 class DebugVC50SSTypesImpl extends DebugVC50SubsectionImpl implements DebugVC50SSTypes {
a61af66fc99e Initial load
duke
parents:
diff changeset
1041 DebugVC50SSTypesImpl(short ssType, short iMod, int ssSize, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1042 super(ssType, iMod, ssSize, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1043 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1044 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1045
a61af66fc99e Initial load
duke
parents:
diff changeset
1046 class DebugVC50SSPublicImpl extends DebugVC50SubsectionImpl implements DebugVC50SSPublic {
a61af66fc99e Initial load
duke
parents:
diff changeset
1047 DebugVC50SSPublicImpl(short ssType, short iMod, int ssSize, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1048 super(ssType, iMod, ssSize, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1049 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1050 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1051
a61af66fc99e Initial load
duke
parents:
diff changeset
1052 class DebugVC50SSPublicSymImpl extends DebugVC50SubsectionImpl implements DebugVC50SSPublicSym {
a61af66fc99e Initial load
duke
parents:
diff changeset
1053 DebugVC50SSPublicSymImpl(short ssType, short iMod, int ssSize, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1054 super(ssType, iMod, ssSize, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1055 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1056 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1057
a61af66fc99e Initial load
duke
parents:
diff changeset
1058 class DebugVC50SSSymbolsImpl extends DebugVC50SubsectionImpl implements DebugVC50SSSymbols {
a61af66fc99e Initial load
duke
parents:
diff changeset
1059 DebugVC50SSSymbolsImpl(short ssType, short iMod, int ssSize, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1060 super(ssType, iMod, ssSize, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1061 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1062 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1063
a61af66fc99e Initial load
duke
parents:
diff changeset
1064 class DebugVC50SSAlignSymImpl extends DebugVC50SubsectionImpl implements DebugVC50SSAlignSym {
a61af66fc99e Initial load
duke
parents:
diff changeset
1065 private int offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
1066
a61af66fc99e Initial load
duke
parents:
diff changeset
1067 DebugVC50SSAlignSymImpl(short ssType, short iMod, int ssSize, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1068 super(ssType, iMod, ssSize, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1069 this.offset = offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
1070 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1071
a61af66fc99e Initial load
duke
parents:
diff changeset
1072 public DebugVC50SymbolIterator getSymbolIterator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1073 return new DebugVC50SymbolIteratorImpl(offset, getSubsectionSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
1074 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1075 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1076
a61af66fc99e Initial load
duke
parents:
diff changeset
1077 class DebugVC50SSSrcLnSegImpl extends DebugVC50SubsectionImpl implements DebugVC50SSSrcLnSeg {
a61af66fc99e Initial load
duke
parents:
diff changeset
1078 DebugVC50SSSrcLnSegImpl(short ssType, short iMod, int ssSize, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1079 super(ssType, iMod, ssSize, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1080 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1081 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1082
a61af66fc99e Initial load
duke
parents:
diff changeset
1083 class DebugVC50SSSrcModuleImpl extends DebugVC50SubsectionImpl implements DebugVC50SSSrcModule {
a61af66fc99e Initial load
duke
parents:
diff changeset
1084 private int offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
1085 private short cFile;
a61af66fc99e Initial load
duke
parents:
diff changeset
1086 private short cSeg;
a61af66fc99e Initial load
duke
parents:
diff changeset
1087 private MemoizedObject baseSrcFiles;
a61af66fc99e Initial load
duke
parents:
diff changeset
1088 private MemoizedObject segOffsets;
a61af66fc99e Initial load
duke
parents:
diff changeset
1089 private MemoizedObject segs;
a61af66fc99e Initial load
duke
parents:
diff changeset
1090
a61af66fc99e Initial load
duke
parents:
diff changeset
1091 DebugVC50SSSrcModuleImpl(short ssType, short iMod, int ssSize, final int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1092 super(ssType, iMod, ssSize, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1093
a61af66fc99e Initial load
duke
parents:
diff changeset
1094 this.offset = offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
1095 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1096 cFile = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1097 cSeg = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1098
a61af66fc99e Initial load
duke
parents:
diff changeset
1099 baseSrcFiles = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1100 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1101 int[] offsets = new int[getNumSourceFiles()];
a61af66fc99e Initial load
duke
parents:
diff changeset
1102 seek(offset + 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1103 for (int i = 0; i < getNumSourceFiles(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1104 offsets[i] = offset + readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1106 DebugVC50SrcModFileDescImpl[] res = new DebugVC50SrcModFileDescImpl[offsets.length];
a61af66fc99e Initial load
duke
parents:
diff changeset
1107 for (int i = 0; i < res.length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1108 res[i] = new DebugVC50SrcModFileDescImpl(offsets[i], offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1110 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
1111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1112 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1113
a61af66fc99e Initial load
duke
parents:
diff changeset
1114 segOffsets = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1115 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1116 seek(offset + 4 * (getNumSourceFiles() + 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1117 int[] res = new int[2 * getNumCodeSegments()];
a61af66fc99e Initial load
duke
parents:
diff changeset
1118 for (int i = 0; i < 2 * getNumCodeSegments(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1119 res[i] = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1121 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
1122 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1123 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1124
a61af66fc99e Initial load
duke
parents:
diff changeset
1125 segs = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1126 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1127 seek(offset + 4 * (getNumSourceFiles() + 1) + 8 * getNumCodeSegments());
a61af66fc99e Initial load
duke
parents:
diff changeset
1128 short[] res = new short[getNumCodeSegments()];
a61af66fc99e Initial load
duke
parents:
diff changeset
1129 for (int i = 0; i < getNumCodeSegments(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1130 res[i] = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1132 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
1133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1134 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1135 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1136
a61af66fc99e Initial load
duke
parents:
diff changeset
1137 public int getNumSourceFiles() { return cFile & 0xFFFF; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1138 public int getNumCodeSegments() { return cSeg & 0xFFFF; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1139 public DebugVC50SrcModFileDesc getSourceFileDesc(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1140 return ((DebugVC50SrcModFileDescImpl[]) baseSrcFiles.getValue())[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
1141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1142
a61af66fc99e Initial load
duke
parents:
diff changeset
1143 public int getSegmentStartOffset(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1144 return ((int[]) segOffsets.getValue())[2*i];
a61af66fc99e Initial load
duke
parents:
diff changeset
1145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1146
a61af66fc99e Initial load
duke
parents:
diff changeset
1147 public int getSegmentEndOffset(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1148 return ((int[]) segOffsets.getValue())[2*i+1];
a61af66fc99e Initial load
duke
parents:
diff changeset
1149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1150
a61af66fc99e Initial load
duke
parents:
diff changeset
1151 public int getSegment(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1152 return ((short[]) segs.getValue())[i] & 0xFFFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
1153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1154 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1155
a61af66fc99e Initial load
duke
parents:
diff changeset
1156 class DebugVC50SrcModFileDescImpl implements DebugVC50SrcModFileDesc {
a61af66fc99e Initial load
duke
parents:
diff changeset
1157 private short cSeg;
a61af66fc99e Initial load
duke
parents:
diff changeset
1158 private MemoizedObject baseSrcLn;
a61af66fc99e Initial load
duke
parents:
diff changeset
1159 private MemoizedObject segOffsets;
a61af66fc99e Initial load
duke
parents:
diff changeset
1160 private MemoizedObject name;
a61af66fc99e Initial load
duke
parents:
diff changeset
1161
a61af66fc99e Initial load
duke
parents:
diff changeset
1162 DebugVC50SrcModFileDescImpl(final int offset, final int baseOffset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1163 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1164 cSeg = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1165
a61af66fc99e Initial load
duke
parents:
diff changeset
1166 baseSrcLn = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1167 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1168 seek(offset + 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1169 int[] offsets = new int[getNumCodeSegments()];
a61af66fc99e Initial load
duke
parents:
diff changeset
1170 for (int i = 0; i < getNumCodeSegments(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1171 offsets[i] = baseOffset + readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1172 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1173 DebugVC50SrcModLineNumberMapImpl[] res =
a61af66fc99e Initial load
duke
parents:
diff changeset
1174 new DebugVC50SrcModLineNumberMapImpl[getNumCodeSegments()];
a61af66fc99e Initial load
duke
parents:
diff changeset
1175 for (int i = 0; i < getNumCodeSegments(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1176 res[i] = new DebugVC50SrcModLineNumberMapImpl(offsets[i]);
a61af66fc99e Initial load
duke
parents:
diff changeset
1177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1178 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
1179 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1180 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1181
a61af66fc99e Initial load
duke
parents:
diff changeset
1182 segOffsets = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1183 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1184 seek(offset + 4 * (getNumCodeSegments() + 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1185 int[] res = new int[2 * getNumCodeSegments()];
a61af66fc99e Initial load
duke
parents:
diff changeset
1186 for (int i = 0; i < 2 * getNumCodeSegments(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1187 res[i] = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1188 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1189 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
1190 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1191 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1192
a61af66fc99e Initial load
duke
parents:
diff changeset
1193 name = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1194 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1195 seek(offset + 4 + 12 * getNumCodeSegments());
a61af66fc99e Initial load
duke
parents:
diff changeset
1196 // NOTE: spec says name length is two bytes, but it's really one
a61af66fc99e Initial load
duke
parents:
diff changeset
1197 int cbName = readByte() & 0xFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
1198 byte[] res = new byte[cbName];
a61af66fc99e Initial load
duke
parents:
diff changeset
1199 readBytes(res);
a61af66fc99e Initial load
duke
parents:
diff changeset
1200 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
1201 return new String(res, US_ASCII);
a61af66fc99e Initial load
duke
parents:
diff changeset
1202 } catch (UnsupportedEncodingException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1203 throw new COFFException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
1204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1206 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1207 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1208
a61af66fc99e Initial load
duke
parents:
diff changeset
1209 public int getNumCodeSegments() { return cSeg & 0xFFFF; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1210
a61af66fc99e Initial load
duke
parents:
diff changeset
1211 public DebugVC50SrcModLineNumberMap getLineNumberMap(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1212 return ((DebugVC50SrcModLineNumberMapImpl[]) baseSrcLn.getValue())[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
1213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1214
a61af66fc99e Initial load
duke
parents:
diff changeset
1215 public int getSegmentStartOffset(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1216 return ((int[]) segOffsets.getValue())[2*i];
a61af66fc99e Initial load
duke
parents:
diff changeset
1217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1218
a61af66fc99e Initial load
duke
parents:
diff changeset
1219 public int getSegmentEndOffset(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1220 return ((int[]) segOffsets.getValue())[2*i+1];
a61af66fc99e Initial load
duke
parents:
diff changeset
1221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1222
a61af66fc99e Initial load
duke
parents:
diff changeset
1223 public String getSourceFileName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1224 return (String) name.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
1225 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1227
a61af66fc99e Initial load
duke
parents:
diff changeset
1228 class DebugVC50SrcModLineNumberMapImpl implements DebugVC50SrcModLineNumberMap {
a61af66fc99e Initial load
duke
parents:
diff changeset
1229 private short seg;
a61af66fc99e Initial load
duke
parents:
diff changeset
1230 private short cPair;
a61af66fc99e Initial load
duke
parents:
diff changeset
1231 private MemoizedObject offsets;
a61af66fc99e Initial load
duke
parents:
diff changeset
1232 private MemoizedObject lineNumbers;
a61af66fc99e Initial load
duke
parents:
diff changeset
1233
a61af66fc99e Initial load
duke
parents:
diff changeset
1234 DebugVC50SrcModLineNumberMapImpl(final int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1235 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1236 seg = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1237 cPair = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1238 offsets = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1239 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1240 seek(offset + 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1241 int[] res = new int[getNumSourceLinePairs()];
a61af66fc99e Initial load
duke
parents:
diff changeset
1242 for (int i = 0; i < getNumSourceLinePairs(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1243 res[i] = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1244 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1245 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
1246 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1247 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1248
a61af66fc99e Initial load
duke
parents:
diff changeset
1249 lineNumbers = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1250 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1251 seek(offset + 4 * (getNumSourceLinePairs() + 1));
a61af66fc99e Initial load
duke
parents:
diff changeset
1252 short[] res = new short[getNumSourceLinePairs()];
a61af66fc99e Initial load
duke
parents:
diff changeset
1253 for (int i = 0; i < getNumSourceLinePairs(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1254 res[i] = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1255 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1256 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
1257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1258 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1259 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1260
a61af66fc99e Initial load
duke
parents:
diff changeset
1261 public int getSegment() { return seg; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1262 public int getNumSourceLinePairs() { return cPair; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1263 public int getCodeOffset(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1264 return ((int[]) offsets.getValue())[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
1265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1266 public int getLineNumber(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1267 return ((short[]) lineNumbers.getValue())[i] & 0xFFFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
1268 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1269 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1270
a61af66fc99e Initial load
duke
parents:
diff changeset
1271 class DebugVC50SSLibrariesImpl extends DebugVC50SubsectionImpl implements DebugVC50SSLibraries {
a61af66fc99e Initial load
duke
parents:
diff changeset
1272 DebugVC50SSLibrariesImpl(short ssType, short iMod, int ssSize, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1273 super(ssType, iMod, ssSize, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1274 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1275
a61af66fc99e Initial load
duke
parents:
diff changeset
1276 // FIXME: NOT FINISHED
a61af66fc99e Initial load
duke
parents:
diff changeset
1277 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1278
a61af66fc99e Initial load
duke
parents:
diff changeset
1279 class DebugVC50SSSymbolBaseImpl extends DebugVC50SubsectionImpl implements DebugVC50SSSymbolBase {
a61af66fc99e Initial load
duke
parents:
diff changeset
1280 private int offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
1281 private short symHash;
a61af66fc99e Initial load
duke
parents:
diff changeset
1282 private short addrHash;
a61af66fc99e Initial load
duke
parents:
diff changeset
1283 private int cbSymbol;
a61af66fc99e Initial load
duke
parents:
diff changeset
1284 private int cbSymHash;
a61af66fc99e Initial load
duke
parents:
diff changeset
1285 private int cbAddrHash;
a61af66fc99e Initial load
duke
parents:
diff changeset
1286
a61af66fc99e Initial load
duke
parents:
diff changeset
1287 private static final int HEADER_SIZE = 16;
a61af66fc99e Initial load
duke
parents:
diff changeset
1288
a61af66fc99e Initial load
duke
parents:
diff changeset
1289 DebugVC50SSSymbolBaseImpl(short ssType, short iMod, int ssSize, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1290 super(ssType, iMod, ssSize, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1291 this.offset = offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
1292 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1293 symHash = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1294 addrHash = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1295 cbSymbol = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1296 cbSymHash = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1297 cbAddrHash = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1298 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1299
a61af66fc99e Initial load
duke
parents:
diff changeset
1300 public short getSymHashIndex() { return symHash; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1301 public short getAddrHashIndex() { return addrHash; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1302 public int getSymTabSize() { return cbSymbol; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1303 public int getSymHashSize() { return cbSymHash; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1304 public int getAddrHashSize() { return cbAddrHash; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1305
a61af66fc99e Initial load
duke
parents:
diff changeset
1306 public DebugVC50SymbolIterator getSymbolIterator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1307 return new DebugVC50SymbolIteratorImpl(offset + HEADER_SIZE, cbSymbol);
a61af66fc99e Initial load
duke
parents:
diff changeset
1308 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1309 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1310
a61af66fc99e Initial load
duke
parents:
diff changeset
1311 class DebugVC50SSGlobalSymImpl extends DebugVC50SSSymbolBaseImpl implements DebugVC50SSGlobalSym {
a61af66fc99e Initial load
duke
parents:
diff changeset
1312 DebugVC50SSGlobalSymImpl(short ssType, short iMod, int ssSize, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1313 super(ssType, iMod, ssSize, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1314 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1315 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1316 class DebugVC50SSGlobalPubImpl extends DebugVC50SSSymbolBaseImpl implements DebugVC50SSGlobalPub {
a61af66fc99e Initial load
duke
parents:
diff changeset
1317 DebugVC50SSGlobalPubImpl(short ssType, short iMod, int ssSize, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1318 super(ssType, iMod, ssSize, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1319 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1320 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1321
a61af66fc99e Initial load
duke
parents:
diff changeset
1322 class DebugVC50SSGlobalTypesImpl extends DebugVC50SubsectionImpl implements DebugVC50SSGlobalTypes {
a61af66fc99e Initial load
duke
parents:
diff changeset
1323 private int offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
1324 private int cType;
a61af66fc99e Initial load
duke
parents:
diff changeset
1325
a61af66fc99e Initial load
duke
parents:
diff changeset
1326 DebugVC50SSGlobalTypesImpl(short ssType, short iMod, int ssSize, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1327 super(ssType, iMod, ssSize, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1328 this.offset = offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
1329 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1330 readInt(); // Discard "flags"
a61af66fc99e Initial load
duke
parents:
diff changeset
1331 cType = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1332 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1333
a61af66fc99e Initial load
duke
parents:
diff changeset
1334 public int getNumTypes() { return cType; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1335 // FIXME: should memoize these
a61af66fc99e Initial load
duke
parents:
diff changeset
1336 public int getTypeOffset(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1337 seek(offset + 4 * (i + 2));
a61af66fc99e Initial load
duke
parents:
diff changeset
1338 return readInt() + offsetOfFirstType();
a61af66fc99e Initial load
duke
parents:
diff changeset
1339 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1340
a61af66fc99e Initial load
duke
parents:
diff changeset
1341 public DebugVC50TypeIterator getTypeIterator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1342 return new DebugVC50TypeIteratorImpl(this,
a61af66fc99e Initial load
duke
parents:
diff changeset
1343 offsetOfFirstType(),
a61af66fc99e Initial load
duke
parents:
diff changeset
1344 cType);
a61af66fc99e Initial load
duke
parents:
diff changeset
1345 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1346
a61af66fc99e Initial load
duke
parents:
diff changeset
1347 private int offsetOfFirstType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1348 return offset + 4 * (getNumTypes() + 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1349 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1350 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1351
a61af66fc99e Initial load
duke
parents:
diff changeset
1352 class DebugVC50SSMPCImpl extends DebugVC50SubsectionImpl implements DebugVC50SSMPC {
a61af66fc99e Initial load
duke
parents:
diff changeset
1353 DebugVC50SSMPCImpl(short ssType, short iMod, int ssSize, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1354 super(ssType, iMod, ssSize, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1355 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1356 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1357
a61af66fc99e Initial load
duke
parents:
diff changeset
1358 class DebugVC50SSSegMapImpl extends DebugVC50SubsectionImpl implements DebugVC50SSSegMap {
a61af66fc99e Initial load
duke
parents:
diff changeset
1359 private short cSeg;
a61af66fc99e Initial load
duke
parents:
diff changeset
1360 private short cSegLog;
a61af66fc99e Initial load
duke
parents:
diff changeset
1361 private MemoizedObject segDescs;
a61af66fc99e Initial load
duke
parents:
diff changeset
1362
a61af66fc99e Initial load
duke
parents:
diff changeset
1363 DebugVC50SSSegMapImpl(short ssType, short iMod, int ssSize, final int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1364 super(ssType, iMod, ssSize, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1365 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1366 cSeg = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1367 cSegLog = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1368 segDescs = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1369 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1370 DebugVC50SegDesc[] descs = new DebugVC50SegDesc[cSeg];
a61af66fc99e Initial load
duke
parents:
diff changeset
1371 for (int i = 0; i < cSeg; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1372 descs[i] = new DebugVC50SegDescImpl(offset + 4 + (20 * i));
a61af66fc99e Initial load
duke
parents:
diff changeset
1373 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1374 return descs;
a61af66fc99e Initial load
duke
parents:
diff changeset
1375 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1376 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1377 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1378
a61af66fc99e Initial load
duke
parents:
diff changeset
1379 public short getNumSegDesc() { return cSeg; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1380 public short getNumLogicalSegDesc() { return cSegLog; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1381 public DebugVC50SegDesc getSegDesc(int i) { return ((DebugVC50SegDesc[]) segDescs.getValue())[i]; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1382 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1383
a61af66fc99e Initial load
duke
parents:
diff changeset
1384 class DebugVC50SegDescImpl implements DebugVC50SegDesc {
a61af66fc99e Initial load
duke
parents:
diff changeset
1385 private short flags;
a61af66fc99e Initial load
duke
parents:
diff changeset
1386 private short ovl;
a61af66fc99e Initial load
duke
parents:
diff changeset
1387 private short group;
a61af66fc99e Initial load
duke
parents:
diff changeset
1388 private short frame;
a61af66fc99e Initial load
duke
parents:
diff changeset
1389 private short iSegName;
a61af66fc99e Initial load
duke
parents:
diff changeset
1390 private short iClassName;
a61af66fc99e Initial load
duke
parents:
diff changeset
1391 private int offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
1392 private int cbSeg;
a61af66fc99e Initial load
duke
parents:
diff changeset
1393
a61af66fc99e Initial load
duke
parents:
diff changeset
1394 DebugVC50SegDescImpl(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1395 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1396 flags = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1397 ovl = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1398 group = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1399 frame = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1400 iSegName = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1401 iClassName = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1402 offset = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1403 cbSeg = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1404 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1405
a61af66fc99e Initial load
duke
parents:
diff changeset
1406 public short getFlags() { return flags; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1407 public short getOverlayNum() { return ovl; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1408 public short getGroup() { return group; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1409 public short getFrame() { return frame; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1410 public short getName() { return iSegName; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1411 public short getClassName() { return iClassName; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1412 public int getOffset() { return offset; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1413 public int getSize() { return cbSeg; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1414 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1415
a61af66fc99e Initial load
duke
parents:
diff changeset
1416
a61af66fc99e Initial load
duke
parents:
diff changeset
1417 class DebugVC50SSSegNameImpl extends DebugVC50SubsectionImpl implements DebugVC50SSSegName {
a61af66fc99e Initial load
duke
parents:
diff changeset
1418 private int offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
1419 private int size;
a61af66fc99e Initial load
duke
parents:
diff changeset
1420 private MemoizedObject names;
a61af66fc99e Initial load
duke
parents:
diff changeset
1421
a61af66fc99e Initial load
duke
parents:
diff changeset
1422 DebugVC50SSSegNameImpl(short ssType, short iMod, int ssSize, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1423 super(ssType, iMod, ssSize, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1424 this.offset = offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
1425 this.size = ssSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
1426 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1427 names = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1428 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1429 int i = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1430 List data = new ArrayList();
a61af66fc99e Initial load
duke
parents:
diff changeset
1431 while (i < size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1432 String s = readCString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1433 data.add(s);
a61af66fc99e Initial load
duke
parents:
diff changeset
1434 i += s.length();
a61af66fc99e Initial load
duke
parents:
diff changeset
1435 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1436 String[] res = new String[data.size()];
a61af66fc99e Initial load
duke
parents:
diff changeset
1437 res = (String[]) data.toArray(res);
a61af66fc99e Initial load
duke
parents:
diff changeset
1438 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
1439 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1440 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1441 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1442
a61af66fc99e Initial load
duke
parents:
diff changeset
1443 public String getSegName(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1444 return ((String[]) names.getValue())[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
1445 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1446 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1447
a61af66fc99e Initial load
duke
parents:
diff changeset
1448 class DebugVC50SSPreCompImpl extends DebugVC50SubsectionImpl implements DebugVC50SSPreComp {
a61af66fc99e Initial load
duke
parents:
diff changeset
1449 DebugVC50SSPreCompImpl(short ssType, short iMod, int ssSize, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1450 super(ssType, iMod, ssSize, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1451 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1452 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1453
a61af66fc99e Initial load
duke
parents:
diff changeset
1454 class DebugVC50SSOffsetMap16Impl extends DebugVC50SubsectionImpl implements DebugVC50SSOffsetMap16 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1455 DebugVC50SSOffsetMap16Impl(short ssType, short iMod, int ssSize, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1456 super(ssType, iMod, ssSize, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1457 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1458 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1459
a61af66fc99e Initial load
duke
parents:
diff changeset
1460 class DebugVC50SSOffsetMap32Impl extends DebugVC50SubsectionImpl implements DebugVC50SSOffsetMap32 {
a61af66fc99e Initial load
duke
parents:
diff changeset
1461 DebugVC50SSOffsetMap32Impl(short ssType, short iMod, int ssSize, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1462 super(ssType, iMod, ssSize, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1463 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1464 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1465
a61af66fc99e Initial load
duke
parents:
diff changeset
1466 class DebugVC50SSFileIndexImpl extends DebugVC50SubsectionImpl implements DebugVC50SSFileIndex {
a61af66fc99e Initial load
duke
parents:
diff changeset
1467 private int offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
1468 private short cMod; // Number of modules in the executable
a61af66fc99e Initial load
duke
parents:
diff changeset
1469 private short cRef; // Total number of file name references
a61af66fc99e Initial load
duke
parents:
diff changeset
1470 private MemoizedObject modStart;
a61af66fc99e Initial load
duke
parents:
diff changeset
1471 private MemoizedObject cRefCnt;
a61af66fc99e Initial load
duke
parents:
diff changeset
1472 // FIXME: probably useless; needs fixup to be converted into
a61af66fc99e Initial load
duke
parents:
diff changeset
1473 // indices rather than offsets
a61af66fc99e Initial load
duke
parents:
diff changeset
1474 private MemoizedObject nameRef;
a61af66fc99e Initial load
duke
parents:
diff changeset
1475 private MemoizedObject names;
a61af66fc99e Initial load
duke
parents:
diff changeset
1476
a61af66fc99e Initial load
duke
parents:
diff changeset
1477 DebugVC50SSFileIndexImpl(short ssType, short iMod, int ssSize, final int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1478 super(ssType, iMod, ssSize, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1479 this.offset = offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
1480 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1481 cMod = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1482 cRef = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1483 modStart = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1484 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1485 short[] vals = new short[cMod];
a61af66fc99e Initial load
duke
parents:
diff changeset
1486 seek(4 + offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1487 for (int i = 0; i < cMod; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1488 vals[i] = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1489 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1490 return vals;
a61af66fc99e Initial load
duke
parents:
diff changeset
1491 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1492 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1493 cRefCnt = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1494 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1495 short[] vals = new short[cMod];
a61af66fc99e Initial load
duke
parents:
diff changeset
1496 seek(4 + offset + (2 * cMod));
a61af66fc99e Initial load
duke
parents:
diff changeset
1497 for (int i = 0; i < cMod; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1498 vals[i] = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1499 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1500 return vals;
a61af66fc99e Initial load
duke
parents:
diff changeset
1501 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1502 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1503 nameRef = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1504 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1505 int[] vals = new int[cRef];
a61af66fc99e Initial load
duke
parents:
diff changeset
1506 seek(4 + offset + (4 * cMod));
a61af66fc99e Initial load
duke
parents:
diff changeset
1507 for (int i = 0; i < cMod; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1508 vals[i] = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1509 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1510 return vals;
a61af66fc99e Initial load
duke
parents:
diff changeset
1511 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1512 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1513 names = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1514 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1515 String[] vals = new String[cRef];
a61af66fc99e Initial load
duke
parents:
diff changeset
1516 for (int i = 0; i < cRef; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1517 vals[i] = readCString();
a61af66fc99e Initial load
duke
parents:
diff changeset
1518 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1519 return vals;
a61af66fc99e Initial load
duke
parents:
diff changeset
1520 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1521 };
a61af66fc99e Initial load
duke
parents:
diff changeset
1522 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1523
a61af66fc99e Initial load
duke
parents:
diff changeset
1524 public short getNumModules() { return cMod; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1525 public short getNumReferences() { return cRef; }
a61af66fc99e Initial load
duke
parents:
diff changeset
1526 public short[] getModStart() { return (short[]) modStart.getValue(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
1527 public short[] getRefCount() { return (short[]) cRefCnt.getValue(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
1528 public int[] getNameRef() { return (int[]) nameRef.getValue(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
1529 public String[] getNames() { return (String[]) names.getValue(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
1530 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1531
a61af66fc99e Initial load
duke
parents:
diff changeset
1532 class DebugVC50SSStaticSymImpl extends DebugVC50SSSymbolBaseImpl implements DebugVC50SSStaticSym {
a61af66fc99e Initial load
duke
parents:
diff changeset
1533 DebugVC50SSStaticSymImpl(short ssType, short iMod, int ssSize, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1534 super(ssType, iMod, ssSize, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
1535 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1536 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1537
a61af66fc99e Initial load
duke
parents:
diff changeset
1538 //////////////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1539 // //
a61af66fc99e Initial load
duke
parents:
diff changeset
1540 // Implementations of symbol and type iterators //
a61af66fc99e Initial load
duke
parents:
diff changeset
1541 // //
a61af66fc99e Initial load
duke
parents:
diff changeset
1542 //////////////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1543
a61af66fc99e Initial load
duke
parents:
diff changeset
1544 class DebugVC50SymbolIteratorImpl implements DebugVC50SymbolIterator {
a61af66fc99e Initial load
duke
parents:
diff changeset
1545 private int base;
a61af66fc99e Initial load
duke
parents:
diff changeset
1546 private int size;
a61af66fc99e Initial load
duke
parents:
diff changeset
1547 private int pos;
a61af66fc99e Initial load
duke
parents:
diff changeset
1548 private int curSymSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
1549 private int curSymType;
a61af66fc99e Initial load
duke
parents:
diff changeset
1550
a61af66fc99e Initial load
duke
parents:
diff changeset
1551 private static final int HEADER_SIZE = 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
1552
a61af66fc99e Initial load
duke
parents:
diff changeset
1553 DebugVC50SymbolIteratorImpl(int base, int size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1554 this(base, size, base);
a61af66fc99e Initial load
duke
parents:
diff changeset
1555 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1556
a61af66fc99e Initial load
duke
parents:
diff changeset
1557 private DebugVC50SymbolIteratorImpl(int base, int size, int pos) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1558 this.base = base;
a61af66fc99e Initial load
duke
parents:
diff changeset
1559 this.size = size;
a61af66fc99e Initial load
duke
parents:
diff changeset
1560 this.pos = pos;
a61af66fc99e Initial load
duke
parents:
diff changeset
1561 seek(pos);
a61af66fc99e Initial load
duke
parents:
diff changeset
1562 curSymSize = readShort() & 0xFFFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
1563 curSymType = readShort() & 0xFFFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
1564 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1565
a61af66fc99e Initial load
duke
parents:
diff changeset
1566 public boolean done() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1567 return (pos == (base + size));
a61af66fc99e Initial load
duke
parents:
diff changeset
1568 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1569
a61af66fc99e Initial load
duke
parents:
diff changeset
1570 public void next() throws NoSuchElementException {
a61af66fc99e Initial load
duke
parents:
diff changeset
1571 if (done()) throw new NoSuchElementException("No more symbols");
a61af66fc99e Initial load
duke
parents:
diff changeset
1572 pos += curSymSize + 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
1573 seek(pos);
a61af66fc99e Initial load
duke
parents:
diff changeset
1574 curSymSize = readShort() & 0xFFFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
1575 curSymType = readShort() & 0xFFFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
1576 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1577
a61af66fc99e Initial load
duke
parents:
diff changeset
1578 public short getLength() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1579 return (short) curSymSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
1580 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1581
a61af66fc99e Initial load
duke
parents:
diff changeset
1582 public int getType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1583 return curSymType;
a61af66fc99e Initial load
duke
parents:
diff changeset
1584 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1585
a61af66fc99e Initial load
duke
parents:
diff changeset
1586 public int getOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1587 return pos + HEADER_SIZE;
a61af66fc99e Initial load
duke
parents:
diff changeset
1588 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1589
a61af66fc99e Initial load
duke
parents:
diff changeset
1590 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1591 // S_COMPILE accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
1592 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1593
a61af66fc99e Initial load
duke
parents:
diff changeset
1594 public byte getCompilerTargetProcessor() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1595 symSeek(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1596 return readByte();
a61af66fc99e Initial load
duke
parents:
diff changeset
1597 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1598
a61af66fc99e Initial load
duke
parents:
diff changeset
1599 public int getCompilerFlags() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1600 symSeek(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
1601 int res = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1602 for (int i = 0; i < 3; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1603 int b = readByte() & 0xFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
1604 res = (res << 8) | b;
a61af66fc99e Initial load
duke
parents:
diff changeset
1605 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1606 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
1607 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1608
a61af66fc99e Initial load
duke
parents:
diff changeset
1609 public String getComplierVersion() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1610 return readLengthPrefixedStringAt(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1611 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1612
a61af66fc99e Initial load
duke
parents:
diff changeset
1613 //////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1614 // S_REGISTER accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
1615 //////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1616
a61af66fc99e Initial load
duke
parents:
diff changeset
1617 public int getRegisterSymbolType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1618 symSeek(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1619 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1620 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1621
a61af66fc99e Initial load
duke
parents:
diff changeset
1622 public short getRegisterEnum() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1623 symSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1624 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1625 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1626
a61af66fc99e Initial load
duke
parents:
diff changeset
1627 public String getRegisterSymbolName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1628 return readLengthPrefixedStringAt(6);
a61af66fc99e Initial load
duke
parents:
diff changeset
1629 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1630
a61af66fc99e Initial load
duke
parents:
diff changeset
1631 //////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1632 // S_CONSTANT accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
1633 //////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1634
a61af66fc99e Initial load
duke
parents:
diff changeset
1635 public int getConstantType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1636 symSeek(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1637 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1638 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1639
a61af66fc99e Initial load
duke
parents:
diff changeset
1640 public int getConstantValueAsInt() throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
1641 return readIntNumericLeafAt(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1642 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1643
a61af66fc99e Initial load
duke
parents:
diff changeset
1644 public long getConstantValueAsLong() throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
1645 return readLongNumericLeafAt(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1646 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1647
a61af66fc99e Initial load
duke
parents:
diff changeset
1648 public float getConstantValueAsFloat() throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
1649 return readFloatNumericLeafAt(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1650 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1651
a61af66fc99e Initial load
duke
parents:
diff changeset
1652 public double getConstantValueAsDouble() throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
1653 return readDoubleNumericLeafAt(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1654 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1655
a61af66fc99e Initial load
duke
parents:
diff changeset
1656 public String getConstantName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1657 return readLengthPrefixedStringAt(4 + numericLeafLengthAt(4));
a61af66fc99e Initial load
duke
parents:
diff changeset
1658 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1659
a61af66fc99e Initial load
duke
parents:
diff changeset
1660 /////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1661 // S_UDT accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
1662 /////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1663
a61af66fc99e Initial load
duke
parents:
diff changeset
1664 public int getUDTType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1665 symSeek(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1666 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1667 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1668
a61af66fc99e Initial load
duke
parents:
diff changeset
1669 public String getUDTName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1670 return readLengthPrefixedStringAt(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1671 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1672
a61af66fc99e Initial load
duke
parents:
diff changeset
1673 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1674 // S_SSEARCH accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
1675 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1676
a61af66fc99e Initial load
duke
parents:
diff changeset
1677 public int getSearchSymbolOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1678 symSeek(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1679 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1680 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1681
a61af66fc99e Initial load
duke
parents:
diff changeset
1682 public short getSearchSegment() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1683 symSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1684 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1685 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1686
a61af66fc99e Initial load
duke
parents:
diff changeset
1687 /////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1688 // S_END accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
1689 /////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1690
a61af66fc99e Initial load
duke
parents:
diff changeset
1691 // (No accessors)
a61af66fc99e Initial load
duke
parents:
diff changeset
1692
a61af66fc99e Initial load
duke
parents:
diff changeset
1693 //////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1694 // S_SKIP accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
1695 //////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1696
a61af66fc99e Initial load
duke
parents:
diff changeset
1697 // (No accessors)
a61af66fc99e Initial load
duke
parents:
diff changeset
1698
a61af66fc99e Initial load
duke
parents:
diff changeset
1699 ///////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1700 // S_CVRESERVE accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
1701 ///////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1702
a61af66fc99e Initial load
duke
parents:
diff changeset
1703 // (No accessors)
a61af66fc99e Initial load
duke
parents:
diff changeset
1704
a61af66fc99e Initial load
duke
parents:
diff changeset
1705 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1706 // S_OBJNAME accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
1707 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1708
a61af66fc99e Initial load
duke
parents:
diff changeset
1709 public int getObjectCodeViewSignature() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1710 symSeek(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1711 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1712 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1713
a61af66fc99e Initial load
duke
parents:
diff changeset
1714 public String getObjectName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1715 return readLengthPrefixedStringAt(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1716 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1717
a61af66fc99e Initial load
duke
parents:
diff changeset
1718 ////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1719 // S_ENDARG accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
1720 ////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1721
a61af66fc99e Initial load
duke
parents:
diff changeset
1722 // (No accessors)
a61af66fc99e Initial load
duke
parents:
diff changeset
1723
a61af66fc99e Initial load
duke
parents:
diff changeset
1724 //////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1725 // S_COBOLUDT accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
1726 //////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1727
a61af66fc99e Initial load
duke
parents:
diff changeset
1728 // (Elided as they are irrelevant)
a61af66fc99e Initial load
duke
parents:
diff changeset
1729
a61af66fc99e Initial load
duke
parents:
diff changeset
1730 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1731 // S_MANYREG accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
1732 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1733
a61af66fc99e Initial load
duke
parents:
diff changeset
1734 public int getManyRegType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1735 symSeek(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1736 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1737 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1738
a61af66fc99e Initial load
duke
parents:
diff changeset
1739 public byte getManyRegCount() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1740 symSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1741 return readByte();
a61af66fc99e Initial load
duke
parents:
diff changeset
1742 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1743
a61af66fc99e Initial load
duke
parents:
diff changeset
1744 public byte getManyRegRegister(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1745 symSeek(5 + i);
a61af66fc99e Initial load
duke
parents:
diff changeset
1746 return readByte();
a61af66fc99e Initial load
duke
parents:
diff changeset
1747 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1748
a61af66fc99e Initial load
duke
parents:
diff changeset
1749 public String getManyRegName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1750 return readLengthPrefixedStringAt(5 + getManyRegCount());
a61af66fc99e Initial load
duke
parents:
diff changeset
1751 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1752
a61af66fc99e Initial load
duke
parents:
diff changeset
1753 ////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1754 // S_RETURN accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
1755 ////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1756
a61af66fc99e Initial load
duke
parents:
diff changeset
1757 public short getReturnFlags() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1758 symSeek(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1759 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1760 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1761
a61af66fc99e Initial load
duke
parents:
diff changeset
1762 public byte getReturnStyle() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1763 symSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
1764 return readByte();
a61af66fc99e Initial load
duke
parents:
diff changeset
1765 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1766
a61af66fc99e Initial load
duke
parents:
diff changeset
1767 public byte getReturnRegisterCount() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1768 symSeek(3);
a61af66fc99e Initial load
duke
parents:
diff changeset
1769 return readByte();
a61af66fc99e Initial load
duke
parents:
diff changeset
1770 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1771
a61af66fc99e Initial load
duke
parents:
diff changeset
1772 public byte getReturnRegister(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1773 symSeek(4 + i);
a61af66fc99e Initial load
duke
parents:
diff changeset
1774 return readByte();
a61af66fc99e Initial load
duke
parents:
diff changeset
1775 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1776
a61af66fc99e Initial load
duke
parents:
diff changeset
1777 ///////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1778 // S_ENTRYTHIS accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
1779 ///////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1780
a61af66fc99e Initial load
duke
parents:
diff changeset
1781 public void advanceToEntryThisSymbol() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1782 seek(pos + 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1783 int tmpSymSize = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1784 int tmpSymType = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1785 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1786 // Make sure that ends of inner and outer symbols line
a61af66fc99e Initial load
duke
parents:
diff changeset
1787 // up, otherwise need more work
a61af66fc99e Initial load
duke
parents:
diff changeset
1788 Assert.that(pos + curSymSize + 2 == pos + 4 + tmpSymSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
1789 "advanceToEntryThisSymbol needs more work");
a61af66fc99e Initial load
duke
parents:
diff changeset
1790 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1791 pos += 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
1792 curSymSize = tmpSymSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
1793 curSymType = tmpSymType;
a61af66fc99e Initial load
duke
parents:
diff changeset
1794 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1795
a61af66fc99e Initial load
duke
parents:
diff changeset
1796 ///////////////////////////////////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1797 // //
a61af66fc99e Initial load
duke
parents:
diff changeset
1798 // //
a61af66fc99e Initial load
duke
parents:
diff changeset
1799 // Symbols for (Intel) 16:32 Segmented and 32-bit Flat Architectures //
a61af66fc99e Initial load
duke
parents:
diff changeset
1800 // //
a61af66fc99e Initial load
duke
parents:
diff changeset
1801 // //
a61af66fc99e Initial load
duke
parents:
diff changeset
1802 ///////////////////////////////////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1803
a61af66fc99e Initial load
duke
parents:
diff changeset
1804 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1805 // S_BPREL32 accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
1806 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1807
a61af66fc99e Initial load
duke
parents:
diff changeset
1808 public int getBPRelOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1809 symSeek(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1810 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1811 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1812
a61af66fc99e Initial load
duke
parents:
diff changeset
1813 public int getBPRelType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1814 symSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1815 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1816 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1817
a61af66fc99e Initial load
duke
parents:
diff changeset
1818 public String getBPRelName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1819 return readLengthPrefixedStringAt(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
1820 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1821
a61af66fc99e Initial load
duke
parents:
diff changeset
1822 ///////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1823 // S_LDATA32 and S_GDATA32 accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
1824 ///////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1825
a61af66fc99e Initial load
duke
parents:
diff changeset
1826 public int getLGDataType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1827 symSeek(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1828 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1829 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1830
a61af66fc99e Initial load
duke
parents:
diff changeset
1831 public int getLGDataOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1832 symSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1833 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1834 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1835
a61af66fc99e Initial load
duke
parents:
diff changeset
1836 public short getLGDataSegment() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1837 symSeek(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
1838 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1839 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1840
a61af66fc99e Initial load
duke
parents:
diff changeset
1841 public String getLGDataName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1842 return readLengthPrefixedStringAt(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
1843 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1844
a61af66fc99e Initial load
duke
parents:
diff changeset
1845 ///////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1846 // S_PUB32 accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
1847 ///////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1848
a61af66fc99e Initial load
duke
parents:
diff changeset
1849 // FIXME: has the same format as the above; consider updating
a61af66fc99e Initial load
duke
parents:
diff changeset
1850 // documentation. No separate accessors provided.
a61af66fc99e Initial load
duke
parents:
diff changeset
1851
a61af66fc99e Initial load
duke
parents:
diff changeset
1852 ///////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1853 // S_LPROC32 and S_GPROC32 accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
1854 ///////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1855
a61af66fc99e Initial load
duke
parents:
diff changeset
1856 public DebugVC50SymbolIterator getLGProcParent() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1857 int offs = getLGProcParentOffset();
a61af66fc99e Initial load
duke
parents:
diff changeset
1858 if (offs == 0) return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1859 return new DebugVC50SymbolIteratorImpl(base, size, offs);
a61af66fc99e Initial load
duke
parents:
diff changeset
1860 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1861
a61af66fc99e Initial load
duke
parents:
diff changeset
1862 public int getLGProcParentOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1863 symSeek(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1864 int offs = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1865 if (offs == 0) return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1866 return base + offs;
a61af66fc99e Initial load
duke
parents:
diff changeset
1867 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1868
a61af66fc99e Initial load
duke
parents:
diff changeset
1869 public DebugVC50SymbolIterator getLGProcEnd() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1870 int offs = getLGProcEndOffset();
a61af66fc99e Initial load
duke
parents:
diff changeset
1871 return new DebugVC50SymbolIteratorImpl(base, size, offs);
a61af66fc99e Initial load
duke
parents:
diff changeset
1872 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1873
a61af66fc99e Initial load
duke
parents:
diff changeset
1874 public int getLGProcEndOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1875 symSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1876 int offs = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1877 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1878 Assert.that(offs != 0, "should not have null end offset for procedure symbols");
a61af66fc99e Initial load
duke
parents:
diff changeset
1879 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1880 return base + offs;
a61af66fc99e Initial load
duke
parents:
diff changeset
1881 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1882
a61af66fc99e Initial load
duke
parents:
diff changeset
1883 public DebugVC50SymbolIterator getLGProcNext() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1884 int offs = getLGProcNextOffset();
a61af66fc99e Initial load
duke
parents:
diff changeset
1885 if (offs == 0) return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1886 return new DebugVC50SymbolIteratorImpl(base, size, offs);
a61af66fc99e Initial load
duke
parents:
diff changeset
1887 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1888
a61af66fc99e Initial load
duke
parents:
diff changeset
1889 public int getLGProcNextOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1890 symSeek(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
1891 int offs = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1892 if (offs == 0) return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1893 return base + offs;
a61af66fc99e Initial load
duke
parents:
diff changeset
1894 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1895
a61af66fc99e Initial load
duke
parents:
diff changeset
1896 public int getLGProcLength() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1897 symSeek(12);
a61af66fc99e Initial load
duke
parents:
diff changeset
1898 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1899 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1900
a61af66fc99e Initial load
duke
parents:
diff changeset
1901 public int getLGProcDebugStart() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1902 symSeek(16);
a61af66fc99e Initial load
duke
parents:
diff changeset
1903 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1904 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1905
a61af66fc99e Initial load
duke
parents:
diff changeset
1906 public int getLGProcDebugEnd() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1907 symSeek(20);
a61af66fc99e Initial load
duke
parents:
diff changeset
1908 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1909 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1910
a61af66fc99e Initial load
duke
parents:
diff changeset
1911 public int getLGProcType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1912 symSeek(24);
a61af66fc99e Initial load
duke
parents:
diff changeset
1913 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1914 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1915
a61af66fc99e Initial load
duke
parents:
diff changeset
1916 public int getLGProcOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1917 symSeek(28);
a61af66fc99e Initial load
duke
parents:
diff changeset
1918 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1919 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1920
a61af66fc99e Initial load
duke
parents:
diff changeset
1921 public short getLGProcSegment() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1922 symSeek(32);
a61af66fc99e Initial load
duke
parents:
diff changeset
1923 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1924 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1925
a61af66fc99e Initial load
duke
parents:
diff changeset
1926 public byte getLGProcFlags() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1927 symSeek(34);
a61af66fc99e Initial load
duke
parents:
diff changeset
1928 return readByte();
a61af66fc99e Initial load
duke
parents:
diff changeset
1929 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1930
a61af66fc99e Initial load
duke
parents:
diff changeset
1931 public String getLGProcName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1932 return readLengthPrefixedStringAt(35);
a61af66fc99e Initial load
duke
parents:
diff changeset
1933 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1934
a61af66fc99e Initial load
duke
parents:
diff changeset
1935 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1936 // S_THUNK32 accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
1937 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
1938
a61af66fc99e Initial load
duke
parents:
diff changeset
1939 public DebugVC50SymbolIterator getThunkParent() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1940 int offs = getThunkParentOffset();
a61af66fc99e Initial load
duke
parents:
diff changeset
1941 if (offs == 0) return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1942 return new DebugVC50SymbolIteratorImpl(base, size, offs);
a61af66fc99e Initial load
duke
parents:
diff changeset
1943 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1944
a61af66fc99e Initial load
duke
parents:
diff changeset
1945 public int getThunkParentOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1946 symSeek(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
1947 int offs = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1948 if (offs == 0) return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1949 return base + offs;
a61af66fc99e Initial load
duke
parents:
diff changeset
1950 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1951
a61af66fc99e Initial load
duke
parents:
diff changeset
1952 public DebugVC50SymbolIterator getThunkEnd() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1953 symSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1954 int offs = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1955 return new DebugVC50SymbolIteratorImpl(base, size, offs);
a61af66fc99e Initial load
duke
parents:
diff changeset
1956 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1957
a61af66fc99e Initial load
duke
parents:
diff changeset
1958 public int getThunkEndOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1959 symSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
1960 int offs = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1961 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
1962 Assert.that(offs != 0, "should not have null end offset for thunk symbols");
a61af66fc99e Initial load
duke
parents:
diff changeset
1963 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1964 return base + offs;
a61af66fc99e Initial load
duke
parents:
diff changeset
1965 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1966
a61af66fc99e Initial load
duke
parents:
diff changeset
1967 public DebugVC50SymbolIterator getThunkNext() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1968 int offs = getThunkNextOffset();
a61af66fc99e Initial load
duke
parents:
diff changeset
1969 if (offs == 0) return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
1970 return new DebugVC50SymbolIteratorImpl(base, size, base + offs);
a61af66fc99e Initial load
duke
parents:
diff changeset
1971 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1972
a61af66fc99e Initial load
duke
parents:
diff changeset
1973 public int getThunkNextOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1974 symSeek(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
1975 int offs = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1976 if (offs == 0) return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
1977 return base + offs;
a61af66fc99e Initial load
duke
parents:
diff changeset
1978 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1979
a61af66fc99e Initial load
duke
parents:
diff changeset
1980 public int getThunkOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1981 symSeek(12);
a61af66fc99e Initial load
duke
parents:
diff changeset
1982 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
1983 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1984
a61af66fc99e Initial load
duke
parents:
diff changeset
1985 public short getThunkSegment() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1986 symSeek(16);
a61af66fc99e Initial load
duke
parents:
diff changeset
1987 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1988 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1989
a61af66fc99e Initial load
duke
parents:
diff changeset
1990 public short getThunkLength() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1991 symSeek(18);
a61af66fc99e Initial load
duke
parents:
diff changeset
1992 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
1993 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1994
a61af66fc99e Initial load
duke
parents:
diff changeset
1995 public byte getThunkType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
1996 symSeek(20);
a61af66fc99e Initial load
duke
parents:
diff changeset
1997 return readByte();
a61af66fc99e Initial load
duke
parents:
diff changeset
1998 }
a61af66fc99e Initial load
duke
parents:
diff changeset
1999
a61af66fc99e Initial load
duke
parents:
diff changeset
2000 public String getThunkName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2001 return readLengthPrefixedStringAt(21);
a61af66fc99e Initial load
duke
parents:
diff changeset
2002 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2003
a61af66fc99e Initial load
duke
parents:
diff changeset
2004 public short getThunkAdjustorThisDelta() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2005 symSeek(21 + lengthPrefixedStringLengthAt(21));
a61af66fc99e Initial load
duke
parents:
diff changeset
2006 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2007 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2008
a61af66fc99e Initial load
duke
parents:
diff changeset
2009 public String getThunkAdjustorTargetName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2010 return readLengthPrefixedStringAt(23 + lengthPrefixedStringLengthAt(21));
a61af66fc99e Initial load
duke
parents:
diff changeset
2011 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2012
a61af66fc99e Initial load
duke
parents:
diff changeset
2013 public short getThunkVCallDisplacement() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2014 symSeek(21 + lengthPrefixedStringLengthAt(21));
a61af66fc99e Initial load
duke
parents:
diff changeset
2015 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2016 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2017
a61af66fc99e Initial load
duke
parents:
diff changeset
2018 public int getThunkPCodeOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2019 symSeek(21 + lengthPrefixedStringLengthAt(21));
a61af66fc99e Initial load
duke
parents:
diff changeset
2020 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2021 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2022
a61af66fc99e Initial load
duke
parents:
diff changeset
2023 public short getThunkPCodeSegment() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2024 symSeek(25 + lengthPrefixedStringLengthAt(21));
a61af66fc99e Initial load
duke
parents:
diff changeset
2025 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2026 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2027
a61af66fc99e Initial load
duke
parents:
diff changeset
2028 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2029 // S_BLOCK32 accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2030 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2031
a61af66fc99e Initial load
duke
parents:
diff changeset
2032 public DebugVC50SymbolIterator getBlockParent() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2033 int offs = getBlockParentOffset();
a61af66fc99e Initial load
duke
parents:
diff changeset
2034 if (offs == 0) return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
2035 return new DebugVC50SymbolIteratorImpl(base, size, offs);
a61af66fc99e Initial load
duke
parents:
diff changeset
2036 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2037
a61af66fc99e Initial load
duke
parents:
diff changeset
2038 public int getBlockParentOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2039 symSeek(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2040 int offs = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2041 if (offs == 0) return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
2042 return base + offs;
a61af66fc99e Initial load
duke
parents:
diff changeset
2043 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2044
a61af66fc99e Initial load
duke
parents:
diff changeset
2045 public DebugVC50SymbolIterator getBlockEnd() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2046 symSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2047 int offs = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2048 return new DebugVC50SymbolIteratorImpl(base, size, offs);
a61af66fc99e Initial load
duke
parents:
diff changeset
2049 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2050
a61af66fc99e Initial load
duke
parents:
diff changeset
2051 public int getBlockEndOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2052 symSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2053 int offs = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2054 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2055 Assert.that(offs != 0, "should not have null end offset for block symbols");
a61af66fc99e Initial load
duke
parents:
diff changeset
2056 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2057 return base + offs;
a61af66fc99e Initial load
duke
parents:
diff changeset
2058 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2059
a61af66fc99e Initial load
duke
parents:
diff changeset
2060 public int getBlockLength() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2061 symSeek(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2062 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2063 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2064
a61af66fc99e Initial load
duke
parents:
diff changeset
2065 public int getBlockOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2066 symSeek(12);
a61af66fc99e Initial load
duke
parents:
diff changeset
2067 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2068 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2069
a61af66fc99e Initial load
duke
parents:
diff changeset
2070 public short getBlockSegment() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2071 symSeek(16);
a61af66fc99e Initial load
duke
parents:
diff changeset
2072 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2073 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2074
a61af66fc99e Initial load
duke
parents:
diff changeset
2075 public String getBlockName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2076 return readLengthPrefixedStringAt(18);
a61af66fc99e Initial load
duke
parents:
diff changeset
2077 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2078
a61af66fc99e Initial load
duke
parents:
diff changeset
2079 ////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2080 // S_WITH32 accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2081 ////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2082
a61af66fc99e Initial load
duke
parents:
diff changeset
2083 // FIXME: this is a Pascal construct; ignored for now
a61af66fc99e Initial load
duke
parents:
diff changeset
2084
a61af66fc99e Initial load
duke
parents:
diff changeset
2085 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2086 // S_LABEL32 accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2087 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2088
a61af66fc99e Initial load
duke
parents:
diff changeset
2089 public int getLabelOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2090 symSeek(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2091 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2092 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2093
a61af66fc99e Initial load
duke
parents:
diff changeset
2094 public short getLabelSegment() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2095 symSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2096 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2097 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2098
a61af66fc99e Initial load
duke
parents:
diff changeset
2099 public byte getLabelFlags() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2100 symSeek(6);
a61af66fc99e Initial load
duke
parents:
diff changeset
2101 return readByte();
a61af66fc99e Initial load
duke
parents:
diff changeset
2102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2103
a61af66fc99e Initial load
duke
parents:
diff changeset
2104 public String getLabelName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2105 return readLengthPrefixedStringAt(7);
a61af66fc99e Initial load
duke
parents:
diff changeset
2106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2107
a61af66fc99e Initial load
duke
parents:
diff changeset
2108 ////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2109 // S_CEXMODEL32 accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2110 ////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2111
a61af66fc99e Initial load
duke
parents:
diff changeset
2112 public int getChangeOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2113 symSeek(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2114 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2116
a61af66fc99e Initial load
duke
parents:
diff changeset
2117 public short getChangeSegment() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2118 symSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2119 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2121
a61af66fc99e Initial load
duke
parents:
diff changeset
2122 public short getChangeModel() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2123 symSeek(6);
a61af66fc99e Initial load
duke
parents:
diff changeset
2124 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2126
a61af66fc99e Initial load
duke
parents:
diff changeset
2127 ////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2128 // S_VFTTABLE32 accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2129 ////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2130
a61af66fc99e Initial load
duke
parents:
diff changeset
2131 public int getVTableRoot() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2132 symSeek(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2133 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2135
a61af66fc99e Initial load
duke
parents:
diff changeset
2136 public int getVTablePath() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2137 symSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2138 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2139 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2140
a61af66fc99e Initial load
duke
parents:
diff changeset
2141 public int getVTableOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2142 symSeek(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2143 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2144 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2145
a61af66fc99e Initial load
duke
parents:
diff changeset
2146 public short getVTableSegment() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2147 symSeek(12);
a61af66fc99e Initial load
duke
parents:
diff changeset
2148 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2150
a61af66fc99e Initial load
duke
parents:
diff changeset
2151 //////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2152 // S_REGREL32 accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2153 //////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2154
a61af66fc99e Initial load
duke
parents:
diff changeset
2155 public int getRegRelOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2156 symSeek(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2157 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2159
a61af66fc99e Initial load
duke
parents:
diff changeset
2160 public int getRegRelType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2161 symSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2162 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2164
a61af66fc99e Initial load
duke
parents:
diff changeset
2165 public short getRegRelRegister() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2166 symSeek(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2167 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2169
a61af66fc99e Initial load
duke
parents:
diff changeset
2170 public String getRegRelName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2171 return readLengthPrefixedStringAt(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
2172 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2173
a61af66fc99e Initial load
duke
parents:
diff changeset
2174 ///////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2175 // S_LTHREAD32 and S_GTHREAD32 accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2176 ///////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2177
a61af66fc99e Initial load
duke
parents:
diff changeset
2178 public int getLThreadType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2179 symSeek(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2180 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2182
a61af66fc99e Initial load
duke
parents:
diff changeset
2183 public int getLThreadOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2184 symSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2185 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2187
a61af66fc99e Initial load
duke
parents:
diff changeset
2188 public short getLThreadSegment() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2189 symSeek(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2190 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2191 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2192
a61af66fc99e Initial load
duke
parents:
diff changeset
2193 public String getLThreadName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2194 return readLengthPrefixedStringAt(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
2195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2196
a61af66fc99e Initial load
duke
parents:
diff changeset
2197 //----------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
2198 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
2199 //
a61af66fc99e Initial load
duke
parents:
diff changeset
2200
a61af66fc99e Initial load
duke
parents:
diff changeset
2201 private void symSeek(int offsetInSym) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2202 seek(pos + HEADER_SIZE + offsetInSym);
a61af66fc99e Initial load
duke
parents:
diff changeset
2203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2204
a61af66fc99e Initial load
duke
parents:
diff changeset
2205 private int numericLeafLengthAt(int offsetInSym) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2206 return DebugVC50Impl.this.numericLeafLengthAt(pos + HEADER_SIZE + offsetInSym);
a61af66fc99e Initial load
duke
parents:
diff changeset
2207 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2208
a61af66fc99e Initial load
duke
parents:
diff changeset
2209 private int readIntNumericLeafAt(int offsetInSym) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2210 return DebugVC50Impl.this.readIntNumericLeafAt(pos + HEADER_SIZE + offsetInSym);
a61af66fc99e Initial load
duke
parents:
diff changeset
2211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2212
a61af66fc99e Initial load
duke
parents:
diff changeset
2213 private long readLongNumericLeafAt(int offsetInSym) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2214 return DebugVC50Impl.this.readLongNumericLeafAt(pos + HEADER_SIZE + offsetInSym);
a61af66fc99e Initial load
duke
parents:
diff changeset
2215 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2216
a61af66fc99e Initial load
duke
parents:
diff changeset
2217 private float readFloatNumericLeafAt(int offsetInSym) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2218 return DebugVC50Impl.this.readFloatNumericLeafAt(pos + HEADER_SIZE + offsetInSym);
a61af66fc99e Initial load
duke
parents:
diff changeset
2219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2220
a61af66fc99e Initial load
duke
parents:
diff changeset
2221 private double readDoubleNumericLeafAt(int offsetInSym) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2222 return DebugVC50Impl.this.readDoubleNumericLeafAt(pos + HEADER_SIZE + offsetInSym);
a61af66fc99e Initial load
duke
parents:
diff changeset
2223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2224
a61af66fc99e Initial load
duke
parents:
diff changeset
2225 private int lengthPrefixedStringLengthAt(int offsetInSym) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2226 return DebugVC50Impl.this.lengthPrefixedStringLengthAt(pos + HEADER_SIZE + offsetInSym);
a61af66fc99e Initial load
duke
parents:
diff changeset
2227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2228
a61af66fc99e Initial load
duke
parents:
diff changeset
2229 private String readLengthPrefixedStringAt(int offsetInSym) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2230 return DebugVC50Impl.this.readLengthPrefixedStringAt(pos + HEADER_SIZE + offsetInSym);
a61af66fc99e Initial load
duke
parents:
diff changeset
2231 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2232 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2233
a61af66fc99e Initial load
duke
parents:
diff changeset
2234 class DebugVC50TypeIteratorImpl implements DebugVC50TypeIterator,
a61af66fc99e Initial load
duke
parents:
diff changeset
2235 DebugVC50TypeLeafIndices, DebugVC50MemberAttributes, DebugVC50TypeEnums {
a61af66fc99e Initial load
duke
parents:
diff changeset
2236 private DebugVC50SSGlobalTypes parent;
a61af66fc99e Initial load
duke
parents:
diff changeset
2237 private int base;
a61af66fc99e Initial load
duke
parents:
diff changeset
2238 private int numTypes;
a61af66fc99e Initial load
duke
parents:
diff changeset
2239 private int typeIndex;
a61af66fc99e Initial load
duke
parents:
diff changeset
2240 private int typeRecordOffset;
a61af66fc99e Initial load
duke
parents:
diff changeset
2241 private int typeStringOffset;
a61af66fc99e Initial load
duke
parents:
diff changeset
2242 private int typeRecordSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
2243 private int typeStringLeaf;
a61af66fc99e Initial load
duke
parents:
diff changeset
2244
a61af66fc99e Initial load
duke
parents:
diff changeset
2245 DebugVC50TypeIteratorImpl(DebugVC50SSGlobalTypes parent, int base, int numTypes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2246 this(parent, base, numTypes, 0, base);
a61af66fc99e Initial load
duke
parents:
diff changeset
2247 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2248
a61af66fc99e Initial load
duke
parents:
diff changeset
2249 private DebugVC50TypeIteratorImpl(DebugVC50SSGlobalTypes parent, int base, int numTypes, int curType, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2250 this.parent = parent;
a61af66fc99e Initial load
duke
parents:
diff changeset
2251 this.base = base;
a61af66fc99e Initial load
duke
parents:
diff changeset
2252 this.numTypes = numTypes;
a61af66fc99e Initial load
duke
parents:
diff changeset
2253 this.typeIndex = curType;
a61af66fc99e Initial load
duke
parents:
diff changeset
2254 if (!done()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2255 typeRecordOffset = offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
2256 loadTypeRecord();
a61af66fc99e Initial load
duke
parents:
diff changeset
2257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2258 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2259
a61af66fc99e Initial load
duke
parents:
diff changeset
2260 public boolean done() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2261 return (typeIndex == numTypes);
a61af66fc99e Initial load
duke
parents:
diff changeset
2262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2263
a61af66fc99e Initial load
duke
parents:
diff changeset
2264 public void next() throws NoSuchElementException {
a61af66fc99e Initial load
duke
parents:
diff changeset
2265 if (done()) throw new NoSuchElementException();
a61af66fc99e Initial load
duke
parents:
diff changeset
2266 ++typeIndex;
a61af66fc99e Initial load
duke
parents:
diff changeset
2267 if (!done()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2268 typeRecordOffset = parent.getTypeOffset(typeIndex);
a61af66fc99e Initial load
duke
parents:
diff changeset
2269 loadTypeRecord();
a61af66fc99e Initial load
duke
parents:
diff changeset
2270 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2271 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2272
a61af66fc99e Initial load
duke
parents:
diff changeset
2273 public short getLength() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2274 return (short) typeRecordSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
2275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2276
a61af66fc99e Initial load
duke
parents:
diff changeset
2277 public int getTypeIndex() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2278 return biasTypeIndex(typeIndex);
a61af66fc99e Initial load
duke
parents:
diff changeset
2279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2280
a61af66fc99e Initial load
duke
parents:
diff changeset
2281 public int getNumTypes() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2282 return numTypes;
a61af66fc99e Initial load
duke
parents:
diff changeset
2283 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2284
a61af66fc99e Initial load
duke
parents:
diff changeset
2285 public boolean typeStringDone() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2286 return (typeStringOffset - typeRecordOffset - 2) >= typeRecordSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
2287 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2288
a61af66fc99e Initial load
duke
parents:
diff changeset
2289 public void typeStringNext() throws NoSuchElementException {
a61af66fc99e Initial load
duke
parents:
diff changeset
2290 if (typeStringDone()) throw new NoSuchElementException();
a61af66fc99e Initial load
duke
parents:
diff changeset
2291 typeStringOffset += typeStringLength();
a61af66fc99e Initial load
duke
parents:
diff changeset
2292 loadTypeString();
a61af66fc99e Initial load
duke
parents:
diff changeset
2293 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2294
a61af66fc99e Initial load
duke
parents:
diff changeset
2295 public int typeStringLeaf() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2296 return typeStringLeaf;
a61af66fc99e Initial load
duke
parents:
diff changeset
2297 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2298
a61af66fc99e Initial load
duke
parents:
diff changeset
2299 public int typeStringOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2300 return typeStringOffset;
a61af66fc99e Initial load
duke
parents:
diff changeset
2301 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2302
a61af66fc99e Initial load
duke
parents:
diff changeset
2303 ///////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2304 // LF_MODIFIER accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2305 ///////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2306
a61af66fc99e Initial load
duke
parents:
diff changeset
2307 public int getModifierIndex() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2308 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2309 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2310 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2311
a61af66fc99e Initial load
duke
parents:
diff changeset
2312 public short getModifierAttribute() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2313 typeSeek(6);
a61af66fc99e Initial load
duke
parents:
diff changeset
2314 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2315 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2316
a61af66fc99e Initial load
duke
parents:
diff changeset
2317 //////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2318 // LF_POINTER accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2319 //////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2320
a61af66fc99e Initial load
duke
parents:
diff changeset
2321 public int getPointerType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2322 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2323 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2324 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2325
a61af66fc99e Initial load
duke
parents:
diff changeset
2326 public int getPointerAttributes() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2327 typeSeek(6);
a61af66fc99e Initial load
duke
parents:
diff changeset
2328 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2329 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2330
a61af66fc99e Initial load
duke
parents:
diff changeset
2331 public int getPointerBasedOnTypeIndex() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2332 typeSeek(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
2333 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2334 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2335
a61af66fc99e Initial load
duke
parents:
diff changeset
2336 public String getPointerBasedOnTypeName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2337 return readLengthPrefixedStringAt(14);
a61af66fc99e Initial load
duke
parents:
diff changeset
2338 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2339
a61af66fc99e Initial load
duke
parents:
diff changeset
2340 public int getPointerToMemberClass() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2341 typeSeek(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
2342 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2343 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2344
a61af66fc99e Initial load
duke
parents:
diff changeset
2345 public short getPointerToMemberFormat() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2346 typeSeek(14);
a61af66fc99e Initial load
duke
parents:
diff changeset
2347 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2348 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2349
a61af66fc99e Initial load
duke
parents:
diff changeset
2350 ////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2351 // LF_ARRAY accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2352 ////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2353
a61af66fc99e Initial load
duke
parents:
diff changeset
2354 public int getArrayElementType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2355 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2356 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2357 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2358
a61af66fc99e Initial load
duke
parents:
diff changeset
2359 public int getArrayIndexType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2360 typeSeek(6);
a61af66fc99e Initial load
duke
parents:
diff changeset
2361 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2362 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2363
a61af66fc99e Initial load
duke
parents:
diff changeset
2364 public int getArrayLength() throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
2365 return readIntNumericLeafAt(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
2366 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2367
a61af66fc99e Initial load
duke
parents:
diff changeset
2368 public String getArrayName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2369 return readLengthPrefixedStringAt(10 + numericLeafLengthAt(10));
a61af66fc99e Initial load
duke
parents:
diff changeset
2370 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2371
a61af66fc99e Initial load
duke
parents:
diff changeset
2372 /////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2373 // LF_CLASS and LF_STRUCTURE accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2374 /////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2375
a61af66fc99e Initial load
duke
parents:
diff changeset
2376 public short getClassCount() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2377 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2378 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2379 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2380
a61af66fc99e Initial load
duke
parents:
diff changeset
2381 public short getClassProperty() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2382 typeSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2383 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2384 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2385
a61af66fc99e Initial load
duke
parents:
diff changeset
2386 public int getClassFieldList() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2387 typeSeek(6);
a61af66fc99e Initial load
duke
parents:
diff changeset
2388 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2389 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2390
a61af66fc99e Initial load
duke
parents:
diff changeset
2391 public DebugVC50TypeIterator getClassFieldListIterator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2392 int index = unbiasTypeIndex(getClassFieldList());
a61af66fc99e Initial load
duke
parents:
diff changeset
2393 int offset = parent.getTypeOffset(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2394 return new DebugVC50TypeIteratorImpl(parent, base, numTypes, index, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2395 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2396
a61af66fc99e Initial load
duke
parents:
diff changeset
2397 public int getClassDerivationList() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2398 typeSeek(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
2399 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2400 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2401
a61af66fc99e Initial load
duke
parents:
diff changeset
2402 public int getClassVShape() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2403 typeSeek(14);
a61af66fc99e Initial load
duke
parents:
diff changeset
2404 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2405 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2406
a61af66fc99e Initial load
duke
parents:
diff changeset
2407 public int getClassSize() throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
2408 return readIntNumericLeafAt(18);
a61af66fc99e Initial load
duke
parents:
diff changeset
2409 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2410
a61af66fc99e Initial load
duke
parents:
diff changeset
2411 public String getClassName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2412 return readLengthPrefixedStringAt(18 + numericLeafLengthAt(18));
a61af66fc99e Initial load
duke
parents:
diff changeset
2413 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2414
a61af66fc99e Initial load
duke
parents:
diff changeset
2415 ////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2416 // LF_UNION accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2417 ////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2418
a61af66fc99e Initial load
duke
parents:
diff changeset
2419 public short getUnionCount() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2420 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2421 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2422 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2423
a61af66fc99e Initial load
duke
parents:
diff changeset
2424 public short getUnionProperty() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2425 typeSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2426 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2427 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2428
a61af66fc99e Initial load
duke
parents:
diff changeset
2429 public int getUnionFieldList() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2430 typeSeek(6);
a61af66fc99e Initial load
duke
parents:
diff changeset
2431 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2432 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2433
a61af66fc99e Initial load
duke
parents:
diff changeset
2434 public DebugVC50TypeIterator getUnionFieldListIterator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2435 int index = unbiasTypeIndex(getUnionFieldList());
a61af66fc99e Initial load
duke
parents:
diff changeset
2436 int offset = parent.getTypeOffset(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2437 return new DebugVC50TypeIteratorImpl(parent, base, numTypes, index, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2438 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2439
a61af66fc99e Initial load
duke
parents:
diff changeset
2440 public int getUnionSize() throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
2441 return readIntNumericLeafAt(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
2442 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2443
a61af66fc99e Initial load
duke
parents:
diff changeset
2444 public String getUnionName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2445 return readLengthPrefixedStringAt(10 + numericLeafLengthAt(10));
a61af66fc99e Initial load
duke
parents:
diff changeset
2446 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2447
a61af66fc99e Initial load
duke
parents:
diff changeset
2448 ///////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2449 // LF_ENUM accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2450 ///////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2451
a61af66fc99e Initial load
duke
parents:
diff changeset
2452 public short getEnumCount() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2453 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2454 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2455 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2456
a61af66fc99e Initial load
duke
parents:
diff changeset
2457 public short getEnumProperty() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2458 typeSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2459 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2460 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2461
a61af66fc99e Initial load
duke
parents:
diff changeset
2462 public int getEnumType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2463 typeSeek(6);
a61af66fc99e Initial load
duke
parents:
diff changeset
2464 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2465 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2466
a61af66fc99e Initial load
duke
parents:
diff changeset
2467 public int getEnumFieldList() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2468 typeSeek(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
2469 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2470 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2471
a61af66fc99e Initial load
duke
parents:
diff changeset
2472 public DebugVC50TypeIterator getEnumFieldListIterator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2473 int index = unbiasTypeIndex(getEnumFieldList());
a61af66fc99e Initial load
duke
parents:
diff changeset
2474 int offset = parent.getTypeOffset(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2475 return new DebugVC50TypeIteratorImpl(parent, base, numTypes, index, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2476 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2477
a61af66fc99e Initial load
duke
parents:
diff changeset
2478 public String getEnumName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2479 return readLengthPrefixedStringAt(14);
a61af66fc99e Initial load
duke
parents:
diff changeset
2480 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2481
a61af66fc99e Initial load
duke
parents:
diff changeset
2482 ////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2483 // LF_PROCEDURE accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2484 ////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2485
a61af66fc99e Initial load
duke
parents:
diff changeset
2486 public int getProcedureReturnType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2487 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2488 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2489 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2490
a61af66fc99e Initial load
duke
parents:
diff changeset
2491 public byte getProcedureCallingConvention() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2492 typeSeek(6);
a61af66fc99e Initial load
duke
parents:
diff changeset
2493 return readByte();
a61af66fc99e Initial load
duke
parents:
diff changeset
2494 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2495
a61af66fc99e Initial load
duke
parents:
diff changeset
2496 public short getProcedureNumberOfParameters() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2497 typeSeek(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2498 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2499 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2500
a61af66fc99e Initial load
duke
parents:
diff changeset
2501 public int getProcedureArgumentList() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2502 typeSeek(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
2503 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2504 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2505
a61af66fc99e Initial load
duke
parents:
diff changeset
2506 public DebugVC50TypeIterator getProcedureArgumentListIterator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2507 int index = unbiasTypeIndex(getProcedureArgumentList());
a61af66fc99e Initial load
duke
parents:
diff changeset
2508 int offset = parent.getTypeOffset(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2509 return new DebugVC50TypeIteratorImpl(parent, base, numTypes, index, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2510 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2511
a61af66fc99e Initial load
duke
parents:
diff changeset
2512 ////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2513 // LF_MFUNCTION accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2514 ////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2515
a61af66fc99e Initial load
duke
parents:
diff changeset
2516 public int getMFunctionReturnType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2517 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2518 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2519 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2520
a61af66fc99e Initial load
duke
parents:
diff changeset
2521 public int getMFunctionContainingClass() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2522 typeSeek(6);
a61af66fc99e Initial load
duke
parents:
diff changeset
2523 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2524 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2525
a61af66fc99e Initial load
duke
parents:
diff changeset
2526 public int getMFunctionThis() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2527 typeSeek(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
2528 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2529 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2530
a61af66fc99e Initial load
duke
parents:
diff changeset
2531 public byte getMFunctionCallingConvention() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2532 typeSeek(14);
a61af66fc99e Initial load
duke
parents:
diff changeset
2533 return readByte();
a61af66fc99e Initial load
duke
parents:
diff changeset
2534 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2535
a61af66fc99e Initial load
duke
parents:
diff changeset
2536 public short getMFunctionNumberOfParameters() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2537 typeSeek(16);
a61af66fc99e Initial load
duke
parents:
diff changeset
2538 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2539 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2540
a61af66fc99e Initial load
duke
parents:
diff changeset
2541 public int getMFunctionArgumentList() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2542 typeSeek(18);
a61af66fc99e Initial load
duke
parents:
diff changeset
2543 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2544 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2545
a61af66fc99e Initial load
duke
parents:
diff changeset
2546 public DebugVC50TypeIterator getMFunctionArgumentListIterator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2547 int index = unbiasTypeIndex(getMFunctionArgumentList());
a61af66fc99e Initial load
duke
parents:
diff changeset
2548 int offset = parent.getTypeOffset(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2549 return new DebugVC50TypeIteratorImpl(parent, base, numTypes, index, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2550 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2551
a61af66fc99e Initial load
duke
parents:
diff changeset
2552 public int getMFunctionThisAdjust() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2553 typeSeek(22);
a61af66fc99e Initial load
duke
parents:
diff changeset
2554 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2555 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2556
a61af66fc99e Initial load
duke
parents:
diff changeset
2557 //////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2558 // LF_VTSHAPE accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2559 //////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2560
a61af66fc99e Initial load
duke
parents:
diff changeset
2561 public short getVTShapeCount() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2562 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2563 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2564 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2565
a61af66fc99e Initial load
duke
parents:
diff changeset
2566 public int getVTShapeDescriptor(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2567 typeSeek(4 + (i / 2));
a61af66fc99e Initial load
duke
parents:
diff changeset
2568 int val = readByte() & 0xFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
2569 if ((i % 2) != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2570 val = val >> 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
2571 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2572 return val;
a61af66fc99e Initial load
duke
parents:
diff changeset
2573 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2574
a61af66fc99e Initial load
duke
parents:
diff changeset
2575 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2576 // LF_BARRAY accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2577 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2578
a61af66fc99e Initial load
duke
parents:
diff changeset
2579 public int getBasicArrayType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2580 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2581 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2582 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2583
a61af66fc99e Initial load
duke
parents:
diff changeset
2584 ////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2585 // LF_LABEL accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2586 ////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2587
a61af66fc99e Initial load
duke
parents:
diff changeset
2588 public short getLabelAddressMode() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2589 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2590 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2591 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2592
a61af66fc99e Initial load
duke
parents:
diff changeset
2593 ///////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2594 // LF_DIMARRAY accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2595 ///////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2596
a61af66fc99e Initial load
duke
parents:
diff changeset
2597 public int getDimArrayType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2598 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2599 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2600 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2601
a61af66fc99e Initial load
duke
parents:
diff changeset
2602 public int getDimArrayDimInfo() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2603 typeSeek(6);
a61af66fc99e Initial load
duke
parents:
diff changeset
2604 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2605 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2606
a61af66fc99e Initial load
duke
parents:
diff changeset
2607 public String getDimArrayName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2608 return readLengthPrefixedStringAt(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
2609 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2610
a61af66fc99e Initial load
duke
parents:
diff changeset
2611 //////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2612 // LF_VFTPATH accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2613 //////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2614
a61af66fc99e Initial load
duke
parents:
diff changeset
2615 public int getVFTPathCount() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2616 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2617 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2618 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2619
a61af66fc99e Initial load
duke
parents:
diff changeset
2620 public int getVFTPathBase(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2621 typeSeek(6 + (4 * i));
a61af66fc99e Initial load
duke
parents:
diff changeset
2622 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2623 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2624
a61af66fc99e Initial load
duke
parents:
diff changeset
2625 ///////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2626 // LF_SKIP accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2627 ///////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2628
a61af66fc99e Initial load
duke
parents:
diff changeset
2629 public int getSkipIndex() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2630 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2631 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2632 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2633
a61af66fc99e Initial load
duke
parents:
diff changeset
2634 //////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2635 // LF_ARGLIST accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2636 //////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2637
a61af66fc99e Initial load
duke
parents:
diff changeset
2638 public int getArgListCount() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2639 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2640 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2641 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2642
a61af66fc99e Initial load
duke
parents:
diff changeset
2643 public int getArgListType(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2644 typeSeek(6 + (4 * i));
a61af66fc99e Initial load
duke
parents:
diff changeset
2645 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2646 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2647
a61af66fc99e Initial load
duke
parents:
diff changeset
2648 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2649 // LF_DEFARG accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2650 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2651
a61af66fc99e Initial load
duke
parents:
diff changeset
2652 public int getDefaultArgType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2653 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2654 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2655 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2656
a61af66fc99e Initial load
duke
parents:
diff changeset
2657 public String getDefaultArgExpression() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2658 return readLengthPrefixedStringAt(6);
a61af66fc99e Initial load
duke
parents:
diff changeset
2659 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2660
a61af66fc99e Initial load
duke
parents:
diff changeset
2661 //////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2662 // LF_DERIVED accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2663 //////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2664
a61af66fc99e Initial load
duke
parents:
diff changeset
2665 public int getDerivedCount() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2666 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2667 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2668 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2669
a61af66fc99e Initial load
duke
parents:
diff changeset
2670 public int getDerivedType(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2671 typeSeek(6);
a61af66fc99e Initial load
duke
parents:
diff changeset
2672 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2673 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2674
a61af66fc99e Initial load
duke
parents:
diff changeset
2675 ///////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2676 // LF_BITFIELD accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2677 ///////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2678
a61af66fc99e Initial load
duke
parents:
diff changeset
2679 public int getBitfieldFieldType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2680 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2681 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2682 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2683
a61af66fc99e Initial load
duke
parents:
diff changeset
2684 public byte getBitfieldLength() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2685 typeSeek(6);
a61af66fc99e Initial load
duke
parents:
diff changeset
2686 return readByte();
a61af66fc99e Initial load
duke
parents:
diff changeset
2687 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2688
a61af66fc99e Initial load
duke
parents:
diff changeset
2689 public byte getBitfieldPosition() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2690 typeSeek(7);
a61af66fc99e Initial load
duke
parents:
diff changeset
2691 return readByte();
a61af66fc99e Initial load
duke
parents:
diff changeset
2692 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2693
a61af66fc99e Initial load
duke
parents:
diff changeset
2694 ////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2695 // LF_MLIST accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2696 ////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2697
a61af66fc99e Initial load
duke
parents:
diff changeset
2698 public short getMListAttribute() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2699 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2700 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2701 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2702
a61af66fc99e Initial load
duke
parents:
diff changeset
2703 public int getMListLength() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2704 return (getLength() - 6 - (isMListIntroducingVirtual() ? 4 : 0)) / 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
2705 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2706
a61af66fc99e Initial load
duke
parents:
diff changeset
2707 public int getMListType(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
2708 typeSeek(6 + 4 * i);
a61af66fc99e Initial load
duke
parents:
diff changeset
2709 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2710 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2711
a61af66fc99e Initial load
duke
parents:
diff changeset
2712 public boolean isMListIntroducingVirtual() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2713 return isIntroducingVirtual(getMListAttribute());
a61af66fc99e Initial load
duke
parents:
diff changeset
2714 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2715
a61af66fc99e Initial load
duke
parents:
diff changeset
2716 public int getMListVtabOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2717 typeSeek(6 + 4 * getMListLength());
a61af66fc99e Initial load
duke
parents:
diff changeset
2718 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2719 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2720
a61af66fc99e Initial load
duke
parents:
diff changeset
2721 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2722 // LF_REFSYM accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2723 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2724
a61af66fc99e Initial load
duke
parents:
diff changeset
2725 public DebugVC50SymbolIterator getRefSym() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2726 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2727 int len = readShort() & 0xFFFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
2728 return new DebugVC50SymbolIteratorImpl(typeStringOffset + 2, len);
a61af66fc99e Initial load
duke
parents:
diff changeset
2729 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2730
a61af66fc99e Initial load
duke
parents:
diff changeset
2731 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2732 // LF_BCLASS accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2733 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2734
a61af66fc99e Initial load
duke
parents:
diff changeset
2735 public short getBClassAttribute() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2736 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2737 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2738 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2739
a61af66fc99e Initial load
duke
parents:
diff changeset
2740 public int getBClassType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2741 typeSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2742 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2743 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2744
a61af66fc99e Initial load
duke
parents:
diff changeset
2745 public int getBClassOffset() throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
2746 return readIntNumericLeafAt(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2747 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2748
a61af66fc99e Initial load
duke
parents:
diff changeset
2749 //////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2750 // LF_VBCLASS accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2751 //////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2752
a61af66fc99e Initial load
duke
parents:
diff changeset
2753 public short getVBClassAttribute() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2754 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2755 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2756 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2757
a61af66fc99e Initial load
duke
parents:
diff changeset
2758 public int getVBClassBaseClassType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2759 typeSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2760 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2761 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2762
a61af66fc99e Initial load
duke
parents:
diff changeset
2763 public int getVBClassVirtualBaseClassType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2764 typeSeek(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2765 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2766 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2767
a61af66fc99e Initial load
duke
parents:
diff changeset
2768 public int getVBClassVBPOff() throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
2769 return readIntNumericLeafAt(12);
a61af66fc99e Initial load
duke
parents:
diff changeset
2770 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2771
a61af66fc99e Initial load
duke
parents:
diff changeset
2772 public int getVBClassVBOff() throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
2773 return readIntNumericLeafAt(12 + numericLeafLengthAt(12));
a61af66fc99e Initial load
duke
parents:
diff changeset
2774 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2775
a61af66fc99e Initial load
duke
parents:
diff changeset
2776 ///////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2777 // LF_IVBCLASS accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2778 ///////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2779
a61af66fc99e Initial load
duke
parents:
diff changeset
2780 public short getIVBClassAttribute() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2781 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2782 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2783 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2784
a61af66fc99e Initial load
duke
parents:
diff changeset
2785 public int getIVBClassBType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2786 typeSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2787 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2788 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2789
a61af66fc99e Initial load
duke
parents:
diff changeset
2790 public int getIVBClassVBPType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2791 typeSeek(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2792 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2793 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2794
a61af66fc99e Initial load
duke
parents:
diff changeset
2795 public int getIVBClassVBPOff() throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
2796 return readIntNumericLeafAt(12);
a61af66fc99e Initial load
duke
parents:
diff changeset
2797 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2798
a61af66fc99e Initial load
duke
parents:
diff changeset
2799 public int getIVBClassVBOff() throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
2800 return readIntNumericLeafAt(12 + numericLeafLengthAt(12));
a61af66fc99e Initial load
duke
parents:
diff changeset
2801 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2802
a61af66fc99e Initial load
duke
parents:
diff changeset
2803 ////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2804 // LF_ENUMERATE accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2805 ////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2806
a61af66fc99e Initial load
duke
parents:
diff changeset
2807 public short getEnumerateAttribute() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2808 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2809 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2810 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2811
a61af66fc99e Initial load
duke
parents:
diff changeset
2812 public long getEnumerateValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2813 return readIntNumericLeafAt(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2814 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2815
a61af66fc99e Initial load
duke
parents:
diff changeset
2816 public String getEnumerateName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2817 return readLengthPrefixedStringAt(4 + numericLeafLengthAt(4));
a61af66fc99e Initial load
duke
parents:
diff changeset
2818 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2819
a61af66fc99e Initial load
duke
parents:
diff changeset
2820 ////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2821 // LF_FRIENDFCN accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2822 ////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2823
a61af66fc99e Initial load
duke
parents:
diff changeset
2824 public int getFriendFcnType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2825 typeSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2826 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2827 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2828
a61af66fc99e Initial load
duke
parents:
diff changeset
2829 public String getFriendFcnName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2830 return readLengthPrefixedStringAt(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2831 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2832
a61af66fc99e Initial load
duke
parents:
diff changeset
2833 ////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2834 // LF_INDEX accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2835 ////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2836
a61af66fc99e Initial load
duke
parents:
diff changeset
2837 public int getIndexValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2838 typeSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2839 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2840 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2841
a61af66fc99e Initial load
duke
parents:
diff changeset
2842 public DebugVC50TypeIterator getIndexIterator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2843 int index = unbiasTypeIndex(getIndexValue());
a61af66fc99e Initial load
duke
parents:
diff changeset
2844 int offset = parent.getTypeOffset(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
2845 return new DebugVC50TypeIteratorImpl(parent, base, numTypes, index, offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
2846 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2847
a61af66fc99e Initial load
duke
parents:
diff changeset
2848 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2849 // LF_MEMBER accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2850 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2851
a61af66fc99e Initial load
duke
parents:
diff changeset
2852 public short getMemberAttribute() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2853 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2854 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2855 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2856
a61af66fc99e Initial load
duke
parents:
diff changeset
2857 public int getMemberType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2858 typeSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2859 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2860 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2861
a61af66fc99e Initial load
duke
parents:
diff changeset
2862 public int getMemberOffset() throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
2863 return readIntNumericLeafAt(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2864 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2865
a61af66fc99e Initial load
duke
parents:
diff changeset
2866 public String getMemberName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2867 return readLengthPrefixedStringAt(8 + numericLeafLengthAt(8));
a61af66fc99e Initial load
duke
parents:
diff changeset
2868 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2869
a61af66fc99e Initial load
duke
parents:
diff changeset
2870 ///////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2871 // LF_STMEMBER accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2872 ///////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2873
a61af66fc99e Initial load
duke
parents:
diff changeset
2874 public short getStaticAttribute() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2875 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2876 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2877 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2878
a61af66fc99e Initial load
duke
parents:
diff changeset
2879 public int getStaticType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2880 typeSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2881 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2882 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2883
a61af66fc99e Initial load
duke
parents:
diff changeset
2884 public String getStaticName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2885 return readLengthPrefixedStringAt(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2886 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2887
a61af66fc99e Initial load
duke
parents:
diff changeset
2888 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2889 // LF_METHOD accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2890 /////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2891
a61af66fc99e Initial load
duke
parents:
diff changeset
2892 public short getMethodCount() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2893 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2894 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2895 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2896
a61af66fc99e Initial load
duke
parents:
diff changeset
2897 public int getMethodList() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2898 typeSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2899 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2900 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2901
a61af66fc99e Initial load
duke
parents:
diff changeset
2902 public String getMethodName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2903 return readLengthPrefixedStringAt(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2904 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2905
a61af66fc99e Initial load
duke
parents:
diff changeset
2906 /////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2907 // LF_NESTEDTYPE accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2908 /////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2909
a61af66fc99e Initial load
duke
parents:
diff changeset
2910 public int getNestedType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2911 typeSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2912 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2913 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2914
a61af66fc99e Initial load
duke
parents:
diff changeset
2915 public String getNestedName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2916 return readLengthPrefixedStringAt(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2917 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2918
a61af66fc99e Initial load
duke
parents:
diff changeset
2919 ///////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2920 // LF_VFUNCTAB accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2921 ///////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2922
a61af66fc99e Initial load
duke
parents:
diff changeset
2923 public int getVFuncTabType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2924 typeSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2925 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2926 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2927
a61af66fc99e Initial load
duke
parents:
diff changeset
2928 ////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2929 // LF_FRIENDCLS accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2930 ////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2931
a61af66fc99e Initial load
duke
parents:
diff changeset
2932 public int getFriendClsType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2933 typeSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2934 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2935 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2936
a61af66fc99e Initial load
duke
parents:
diff changeset
2937 ////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2938 // LF_ONEMETHOD accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2939 ////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2940
a61af66fc99e Initial load
duke
parents:
diff changeset
2941 public short getOneMethodAttribute() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2942 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2943 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2944 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2945
a61af66fc99e Initial load
duke
parents:
diff changeset
2946 public int getOneMethodType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2947 typeSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2948 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2949 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2950
a61af66fc99e Initial load
duke
parents:
diff changeset
2951 public boolean isOneMethodIntroducingVirtual() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2952 return isIntroducingVirtual(getOneMethodAttribute());
a61af66fc99e Initial load
duke
parents:
diff changeset
2953 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2954
a61af66fc99e Initial load
duke
parents:
diff changeset
2955 public int getOneMethodVBaseOff() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2956 typeSeek(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2957 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2958 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2959
a61af66fc99e Initial load
duke
parents:
diff changeset
2960 public String getOneMethodName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2961 int baseLen = 8 + (isOneMethodIntroducingVirtual() ? 4 : 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
2962 return readLengthPrefixedStringAt(baseLen);
a61af66fc99e Initial load
duke
parents:
diff changeset
2963 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2964
a61af66fc99e Initial load
duke
parents:
diff changeset
2965 ///////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2966 // LF_VFUNCOFF accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2967 ///////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2968
a61af66fc99e Initial load
duke
parents:
diff changeset
2969 public int getVFuncOffType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2970 typeSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2971 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2972 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2973
a61af66fc99e Initial load
duke
parents:
diff changeset
2974 public int getVFuncOffOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2975 typeSeek(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2976 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2977 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2978
a61af66fc99e Initial load
duke
parents:
diff changeset
2979 ///////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2980 // LF_NESTEDTYPEEX accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2981 ///////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2982
a61af66fc99e Initial load
duke
parents:
diff changeset
2983 public short getNestedExAttribute() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2984 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
2985 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
2986 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2987
a61af66fc99e Initial load
duke
parents:
diff changeset
2988 public int getNestedExType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2989 typeSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
2990 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
2991 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2992
a61af66fc99e Initial load
duke
parents:
diff changeset
2993 public String getNestedExName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
2994 return readLengthPrefixedStringAt(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
2995 }
a61af66fc99e Initial load
duke
parents:
diff changeset
2996
a61af66fc99e Initial load
duke
parents:
diff changeset
2997 ///////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
2998 // LF_MEMBERMODIFY accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
2999 ///////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
3000
a61af66fc99e Initial load
duke
parents:
diff changeset
3001 public short getMemberModifyAttribute() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3002 typeSeek(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
3003 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
3004 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3005
a61af66fc99e Initial load
duke
parents:
diff changeset
3006 public int getMemberModifyType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3007 typeSeek(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
3008 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3009 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3010
a61af66fc99e Initial load
duke
parents:
diff changeset
3011 public String getMemberModifyName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3012 return readLengthPrefixedStringAt(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
3013 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3014
a61af66fc99e Initial load
duke
parents:
diff changeset
3015 ////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
3016 // Numeric Leaf accessors //
a61af66fc99e Initial load
duke
parents:
diff changeset
3017 ////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
3018
a61af66fc99e Initial load
duke
parents:
diff changeset
3019 public short getNumericTypeAt(int byteOffset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3020 typeSeek(byteOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3021 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
3022 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3023
a61af66fc99e Initial load
duke
parents:
diff changeset
3024 public int getNumericLengthAt(int byteOffset)
a61af66fc99e Initial load
duke
parents:
diff changeset
3025 throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3026 return numericLeafLengthAt(byteOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3027 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3028
a61af66fc99e Initial load
duke
parents:
diff changeset
3029 public int getNumericIntAt(int byteOffset)
a61af66fc99e Initial load
duke
parents:
diff changeset
3030 throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3031 return readIntNumericLeafAt(byteOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3032 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3033
a61af66fc99e Initial load
duke
parents:
diff changeset
3034 public long getNumericLongAt(int byteOffset)
a61af66fc99e Initial load
duke
parents:
diff changeset
3035 throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3036 // FIXME
a61af66fc99e Initial load
duke
parents:
diff changeset
3037 throw new RuntimeException("Unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
3038 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3039
a61af66fc99e Initial load
duke
parents:
diff changeset
3040 public float getNumericFloatAt(int byteOffset)
a61af66fc99e Initial load
duke
parents:
diff changeset
3041 throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3042 // FIXME
a61af66fc99e Initial load
duke
parents:
diff changeset
3043 throw new RuntimeException("Unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
3044 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3045
a61af66fc99e Initial load
duke
parents:
diff changeset
3046 public double getNumericDoubleAt(int byteOffset)
a61af66fc99e Initial load
duke
parents:
diff changeset
3047 throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3048 // FIXME
a61af66fc99e Initial load
duke
parents:
diff changeset
3049 throw new RuntimeException("Unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
3050 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3051
a61af66fc99e Initial load
duke
parents:
diff changeset
3052 public byte[] getNumericDataAt(int byteOffset)
a61af66fc99e Initial load
duke
parents:
diff changeset
3053 throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3054 // FIXME
a61af66fc99e Initial load
duke
parents:
diff changeset
3055 throw new RuntimeException("Unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
3056 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3057
a61af66fc99e Initial load
duke
parents:
diff changeset
3058 //----------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
3059 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
3060 //
a61af66fc99e Initial load
duke
parents:
diff changeset
3061
a61af66fc99e Initial load
duke
parents:
diff changeset
3062 private void loadTypeRecord() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3063 seek(typeRecordOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3064 typeRecordSize = readShort() & 0xFFFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
3065 typeStringOffset = typeRecordOffset + 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
3066 loadTypeString();
a61af66fc99e Initial load
duke
parents:
diff changeset
3067 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3068
a61af66fc99e Initial load
duke
parents:
diff changeset
3069 private void loadTypeString() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3070 seek(typeStringOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3071 int lo = readByte() & 0xFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
3072 // See if it is one of the single-byte leaves
a61af66fc99e Initial load
duke
parents:
diff changeset
3073 if (lo >= LF_PAD0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3074 typeStringLeaf = lo;
a61af66fc99e Initial load
duke
parents:
diff changeset
3075 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3076 int hi = readByte() & 0xFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
3077 typeStringLeaf = (hi << 8) | lo;
a61af66fc99e Initial load
duke
parents:
diff changeset
3078 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3079 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3080
a61af66fc99e Initial load
duke
parents:
diff changeset
3081 private void typeSeek(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3082 seek(typeStringOffset + offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3083 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3084
a61af66fc99e Initial load
duke
parents:
diff changeset
3085 private int typeStringLength() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3086 // LF_PAD
a61af66fc99e Initial load
duke
parents:
diff changeset
3087 if (typeStringLeaf >= 0xF0 && typeStringLeaf <= 0xFF) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3088 return (typeStringLeaf - 0xF0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3089 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3090
a61af66fc99e Initial load
duke
parents:
diff changeset
3091 switch (typeStringLeaf) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3092
a61af66fc99e Initial load
duke
parents:
diff changeset
3093 // Leaf indices for type records that can be referenced
a61af66fc99e Initial load
duke
parents:
diff changeset
3094 // from symbols:
a61af66fc99e Initial load
duke
parents:
diff changeset
3095 case LF_MODIFIER: return 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
3096 case LF_POINTER: {
a61af66fc99e Initial load
duke
parents:
diff changeset
3097 int extraLen = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
3098 int attr = (getPointerAttributes() & POINTER_PTRTYPE_MASK) >> POINTER_PTRTYPE_SHIFT;
a61af66fc99e Initial load
duke
parents:
diff changeset
3099 int mode = (getPointerAttributes() & POINTER_PTRMODE_MASK) >> POINTER_PTRMODE_SHIFT;
a61af66fc99e Initial load
duke
parents:
diff changeset
3100 if (attr == POINTER_PTRTYPE_BASED_ON_TYPE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3101 extraLen = 4 + numericLeafLengthAt(typeStringOffset + 14);
a61af66fc99e Initial load
duke
parents:
diff changeset
3102 } else if (mode == POINTER_PTRMODE_PTR_TO_DATA_MEMBER ||
a61af66fc99e Initial load
duke
parents:
diff changeset
3103 mode == POINTER_PTRMODE_PTR_TO_METHOD) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3104 extraLen = 6;
a61af66fc99e Initial load
duke
parents:
diff changeset
3105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3106 return 10 + extraLen;
a61af66fc99e Initial load
duke
parents:
diff changeset
3107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3108 case LF_ARRAY: {
a61af66fc99e Initial load
duke
parents:
diff changeset
3109 int temp = 10 + numericLeafLengthAt(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
3110 return temp + lengthPrefixedStringLengthAt(temp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3112 case LF_CLASS:
a61af66fc99e Initial load
duke
parents:
diff changeset
3113 case LF_STRUCTURE: {
a61af66fc99e Initial load
duke
parents:
diff changeset
3114 int temp = 18 + numericLeafLengthAt(18);
a61af66fc99e Initial load
duke
parents:
diff changeset
3115 return temp + lengthPrefixedStringLengthAt(temp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3117 case LF_UNION: {
a61af66fc99e Initial load
duke
parents:
diff changeset
3118 int temp = 10 + numericLeafLengthAt(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
3119 return temp + lengthPrefixedStringLengthAt(temp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3121 case LF_ENUM: {
a61af66fc99e Initial load
duke
parents:
diff changeset
3122 return 14 + lengthPrefixedStringLengthAt(14);
a61af66fc99e Initial load
duke
parents:
diff changeset
3123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3124 case LF_PROCEDURE: return 14;
a61af66fc99e Initial load
duke
parents:
diff changeset
3125 case LF_MFUNCTION: return 26;
a61af66fc99e Initial load
duke
parents:
diff changeset
3126 case LF_VTSHAPE: return 4 + ((getVTShapeCount() + 1) / 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
3127 case LF_COBOL0:
a61af66fc99e Initial load
duke
parents:
diff changeset
3128 case LF_COBOL1: throw new COFFException("COBOL symbols unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
3129 case LF_BARRAY: return 6;
a61af66fc99e Initial load
duke
parents:
diff changeset
3130 case LF_LABEL: return 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
3131 case LF_NULL: return 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
3132 case LF_NOTTRAN: return 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
3133 case LF_DIMARRAY: return 10 + lengthPrefixedStringLengthAt(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
3134 case LF_VFTPATH: return 6 + 4 * getVFTPathCount();
a61af66fc99e Initial load
duke
parents:
diff changeset
3135 case LF_PRECOMP: return 14 + lengthPrefixedStringLengthAt(14);
a61af66fc99e Initial load
duke
parents:
diff changeset
3136 case LF_ENDPRECOMP: return 6;
a61af66fc99e Initial load
duke
parents:
diff changeset
3137 case LF_OEM: throw new COFFException("OEM symbols unimplemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
3138 case LF_TYPESERVER: return 10 + lengthPrefixedStringLengthAt(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
3139
a61af66fc99e Initial load
duke
parents:
diff changeset
3140 case LF_SKIP: return 6 + numericLeafLengthAt(6);
a61af66fc99e Initial load
duke
parents:
diff changeset
3141 case LF_ARGLIST: return 6 + 4 * getArgListCount();
a61af66fc99e Initial load
duke
parents:
diff changeset
3142 case LF_DEFARG: return 6 + lengthPrefixedStringLengthAt(6);
a61af66fc99e Initial load
duke
parents:
diff changeset
3143 // case LF_FIELDLIST: throw new COFFException("Should not see LF_FIELDLIST leaf");
a61af66fc99e Initial load
duke
parents:
diff changeset
3144 case LF_FIELDLIST: return 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
3145 case LF_DERIVED: return 6 + 4 * getDerivedCount();
a61af66fc99e Initial load
duke
parents:
diff changeset
3146 case LF_BITFIELD: return 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
3147 case LF_METHODLIST: {
a61af66fc99e Initial load
duke
parents:
diff changeset
3148 return 6 + 4 * getMListLength() + (isMListIntroducingVirtual() ? 4 : 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3150 case LF_DIMCONU:
a61af66fc99e Initial load
duke
parents:
diff changeset
3151 case LF_DIMCONLU:
a61af66fc99e Initial load
duke
parents:
diff changeset
3152 case LF_DIMVARU:
a61af66fc99e Initial load
duke
parents:
diff changeset
3153 case LF_DIMVARLU: throw new COFFException("LF_DIMCONU, LF_DIMCONLU, LF_DIMVARU, and LF_DIMVARLU unsupported");
a61af66fc99e Initial load
duke
parents:
diff changeset
3154 case LF_REFSYM: {
a61af66fc99e Initial load
duke
parents:
diff changeset
3155 seek(typeStringOffset + 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
3156 return 4 + readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
3157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3158
a61af66fc99e Initial load
duke
parents:
diff changeset
3159 case LF_BCLASS: return 8 + numericLeafLengthAt(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
3160 case LF_VBCLASS:
a61af66fc99e Initial load
duke
parents:
diff changeset
3161 case LF_IVBCLASS: {
a61af66fc99e Initial load
duke
parents:
diff changeset
3162 int temp = 12 + numericLeafLengthAt(12);
a61af66fc99e Initial load
duke
parents:
diff changeset
3163 return temp + numericLeafLengthAt(temp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3165 case LF_ENUMERATE: {
a61af66fc99e Initial load
duke
parents:
diff changeset
3166 int temp = 4 + numericLeafLengthAt(4);
a61af66fc99e Initial load
duke
parents:
diff changeset
3167 return temp + lengthPrefixedStringLengthAt(temp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3169 case LF_FRIENDFCN: return 8 + lengthPrefixedStringLengthAt(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
3170 case LF_INDEX: return 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
3171 case LF_MEMBER: {
a61af66fc99e Initial load
duke
parents:
diff changeset
3172 int temp = 8 + numericLeafLengthAt(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
3173 return temp + lengthPrefixedStringLengthAt(temp);
a61af66fc99e Initial load
duke
parents:
diff changeset
3174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3175 case LF_STMEMBER: return 8 + lengthPrefixedStringLengthAt(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
3176 case LF_METHOD: return 8 + lengthPrefixedStringLengthAt(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
3177 case LF_NESTTYPE: return 8 + lengthPrefixedStringLengthAt(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
3178 case LF_VFUNCTAB: return 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
3179 case LF_FRIENDCLS: return 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
3180 case LF_ONEMETHOD: {
a61af66fc99e Initial load
duke
parents:
diff changeset
3181 int baseLen = 8 + (isOneMethodIntroducingVirtual() ? 4 : 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3182 return baseLen + lengthPrefixedStringLengthAt(baseLen);
a61af66fc99e Initial load
duke
parents:
diff changeset
3183 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3184 case LF_VFUNCOFF: return 12;
a61af66fc99e Initial load
duke
parents:
diff changeset
3185 case LF_NESTTYPEEX: return 8 + lengthPrefixedStringLengthAt(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
3186 case LF_MEMBERMODIFY: return 8 + lengthPrefixedStringLengthAt(8);
a61af66fc99e Initial load
duke
parents:
diff changeset
3187
a61af66fc99e Initial load
duke
parents:
diff changeset
3188 // Should not encounter numeric leaves with this routine
a61af66fc99e Initial load
duke
parents:
diff changeset
3189 case LF_CHAR:
a61af66fc99e Initial load
duke
parents:
diff changeset
3190 case LF_SHORT:
a61af66fc99e Initial load
duke
parents:
diff changeset
3191 case LF_USHORT:
a61af66fc99e Initial load
duke
parents:
diff changeset
3192 case LF_LONG:
a61af66fc99e Initial load
duke
parents:
diff changeset
3193 case LF_ULONG:
a61af66fc99e Initial load
duke
parents:
diff changeset
3194 case LF_REAL32:
a61af66fc99e Initial load
duke
parents:
diff changeset
3195 case LF_REAL64:
a61af66fc99e Initial load
duke
parents:
diff changeset
3196 case LF_REAL80:
a61af66fc99e Initial load
duke
parents:
diff changeset
3197 case LF_REAL128:
a61af66fc99e Initial load
duke
parents:
diff changeset
3198 case LF_QUADWORD:
a61af66fc99e Initial load
duke
parents:
diff changeset
3199 case LF_UQUADWORD:
a61af66fc99e Initial load
duke
parents:
diff changeset
3200 case LF_REAL48:
a61af66fc99e Initial load
duke
parents:
diff changeset
3201 case LF_COMPLEX32:
a61af66fc99e Initial load
duke
parents:
diff changeset
3202 case LF_COMPLEX64:
a61af66fc99e Initial load
duke
parents:
diff changeset
3203 case LF_COMPLEX80:
a61af66fc99e Initial load
duke
parents:
diff changeset
3204 case LF_COMPLEX128:
a61af66fc99e Initial load
duke
parents:
diff changeset
3205 case LF_VARSTRING: throw new RuntimeException("Unexpected numeric leaf " + typeStringLeaf +
a61af66fc99e Initial load
duke
parents:
diff changeset
3206 "in type string");
a61af66fc99e Initial load
duke
parents:
diff changeset
3207 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
3208 throw new COFFException("Unrecognized leaf " + typeStringLeaf + " in type string at offset " +
a61af66fc99e Initial load
duke
parents:
diff changeset
3209 typeStringOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3210 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3212
a61af66fc99e Initial load
duke
parents:
diff changeset
3213 private boolean isIntroducingVirtual(int mprop) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3214 int masked = mprop & MEMATTR_MPROP_MASK;
a61af66fc99e Initial load
duke
parents:
diff changeset
3215 return ((masked == MEMATTR_MPROP_INTRODUCING_VIRTUAL) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
3216 (masked == MEMATTR_MPROP_PURE_INTRODUCING_VIRTUAL));
a61af66fc99e Initial load
duke
parents:
diff changeset
3217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3218
a61af66fc99e Initial load
duke
parents:
diff changeset
3219 private int numericLeafLengthAt(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3220 return DebugVC50Impl.this.numericLeafLengthAt(typeStringOffset + offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3222
a61af66fc99e Initial load
duke
parents:
diff changeset
3223 private int readIntNumericLeafAt(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3224 return DebugVC50Impl.this.readIntNumericLeafAt(typeStringOffset + offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3225 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3226
a61af66fc99e Initial load
duke
parents:
diff changeset
3227 private int lengthPrefixedStringLengthAt(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3228 return DebugVC50Impl.this.lengthPrefixedStringLengthAt(typeStringOffset + offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3229 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3230
a61af66fc99e Initial load
duke
parents:
diff changeset
3231 private String readLengthPrefixedStringAt(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3232 return DebugVC50Impl.this.readLengthPrefixedStringAt(typeStringOffset + offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3233 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3235
a61af66fc99e Initial load
duke
parents:
diff changeset
3236 private int numericLeafLengthAt(int absoluteOffset) throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3237 seek(absoluteOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3238 int leaf = readShort() & 0xFFFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
3239 if (leaf < 0x8000) return 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
3240 switch (leaf) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3241 case LF_CHAR: return 3;
a61af66fc99e Initial load
duke
parents:
diff changeset
3242 case LF_SHORT:
a61af66fc99e Initial load
duke
parents:
diff changeset
3243 case LF_USHORT: return 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
3244 case LF_LONG:
a61af66fc99e Initial load
duke
parents:
diff changeset
3245 case LF_ULONG: return 6;
a61af66fc99e Initial load
duke
parents:
diff changeset
3246 case LF_REAL32: return 6;
a61af66fc99e Initial load
duke
parents:
diff changeset
3247 case LF_REAL64: return 10;
a61af66fc99e Initial load
duke
parents:
diff changeset
3248 case LF_REAL80: return 12;
a61af66fc99e Initial load
duke
parents:
diff changeset
3249 case LF_REAL128: return 18;
a61af66fc99e Initial load
duke
parents:
diff changeset
3250 case LF_QUADWORD:
a61af66fc99e Initial load
duke
parents:
diff changeset
3251 case LF_UQUADWORD: return 18;
a61af66fc99e Initial load
duke
parents:
diff changeset
3252 case LF_REAL48: return 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
3253 case LF_COMPLEX32: return 10;
a61af66fc99e Initial load
duke
parents:
diff changeset
3254 case LF_COMPLEX64: return 18;
a61af66fc99e Initial load
duke
parents:
diff changeset
3255 case LF_COMPLEX80: return 26;
a61af66fc99e Initial load
duke
parents:
diff changeset
3256 case LF_COMPLEX128: return 66;
a61af66fc99e Initial load
duke
parents:
diff changeset
3257 // FIXME: figure out format of variable-length strings
a61af66fc99e Initial load
duke
parents:
diff changeset
3258 case LF_VARSTRING: return 4 + readIntNumericLeafAt(absoluteOffset + 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
3259
a61af66fc99e Initial load
duke
parents:
diff changeset
3260 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
3261 throw new DebugVC50WrongNumericTypeException("Illegal numeric leaf index " + leaf +
a61af66fc99e Initial load
duke
parents:
diff changeset
3262 " at offset " + absoluteOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3264 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3265
a61af66fc99e Initial load
duke
parents:
diff changeset
3266 private int readIntNumericLeafAt(int absoluteOffset) throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3267 seek(absoluteOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3268 int leaf = readShort() & 0xFFFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
3269 if (leaf < 0x8000) return leaf;
a61af66fc99e Initial load
duke
parents:
diff changeset
3270 switch (leaf) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3271 case LF_CHAR: return readByte() & 0xFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
3272 case LF_SHORT:
a61af66fc99e Initial load
duke
parents:
diff changeset
3273 case LF_USHORT: return readShort() & 0xFFFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
3274 case LF_LONG:
a61af66fc99e Initial load
duke
parents:
diff changeset
3275 case LF_ULONG: return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3276
a61af66fc99e Initial load
duke
parents:
diff changeset
3277 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
3278 throw new DebugVC50WrongNumericTypeException("Illegal numeric leaf index " + leaf);
a61af66fc99e Initial load
duke
parents:
diff changeset
3279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3280 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3281
a61af66fc99e Initial load
duke
parents:
diff changeset
3282 private long readLongNumericLeafAt(int absoluteOffset) throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3283 seek(absoluteOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3284 int leaf = readShort() & 0xFFFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
3285 if (leaf < 0x8000) return leaf;
a61af66fc99e Initial load
duke
parents:
diff changeset
3286 switch (leaf) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3287 case LF_CHAR: return readByte() & 0xFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
3288 case LF_SHORT:
a61af66fc99e Initial load
duke
parents:
diff changeset
3289 case LF_USHORT: return readShort() & 0xFFFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
3290 case LF_LONG:
a61af66fc99e Initial load
duke
parents:
diff changeset
3291 case LF_ULONG: return readInt() & 0xFFFFFFFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
3292 case LF_QUADWORD:
a61af66fc99e Initial load
duke
parents:
diff changeset
3293 case LF_UQUADWORD: return readLong();
a61af66fc99e Initial load
duke
parents:
diff changeset
3294
a61af66fc99e Initial load
duke
parents:
diff changeset
3295 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
3296 throw new DebugVC50WrongNumericTypeException("Illegal numeric leaf index " + leaf);
a61af66fc99e Initial load
duke
parents:
diff changeset
3297 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3298 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3299
a61af66fc99e Initial load
duke
parents:
diff changeset
3300 private float readFloatNumericLeafAt(int absoluteOffset) throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3301 seek(absoluteOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3302 int leaf = readShort() & 0xFFFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
3303 if (leaf != LF_REAL32) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3304 throw new DebugVC50WrongNumericTypeException("Illegal numeric leaf index " + leaf);
a61af66fc99e Initial load
duke
parents:
diff changeset
3305 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3306 return readFloat();
a61af66fc99e Initial load
duke
parents:
diff changeset
3307 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3308
a61af66fc99e Initial load
duke
parents:
diff changeset
3309 private double readDoubleNumericLeafAt(int absoluteOffset) throws DebugVC50WrongNumericTypeException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3310 seek(absoluteOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3311 int leaf = readShort() & 0xFFFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
3312 if (leaf != LF_REAL64) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3313 throw new DebugVC50WrongNumericTypeException("Illegal numeric leaf index " + leaf);
a61af66fc99e Initial load
duke
parents:
diff changeset
3314 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3315 return readDouble();
a61af66fc99e Initial load
duke
parents:
diff changeset
3316 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3317
a61af66fc99e Initial load
duke
parents:
diff changeset
3318 private int lengthPrefixedStringLengthAt(int absoluteOffset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3319 // NOTE: the format of length-prefixed strings is not well
a61af66fc99e Initial load
duke
parents:
diff changeset
3320 // specified. There is a LF_VARSTRING numeric leaf (the
a61af66fc99e Initial load
duke
parents:
diff changeset
3321 // format of which is also not specified), but it seems that
a61af66fc99e Initial load
duke
parents:
diff changeset
3322 // most length-prefixed strings are comprised of a single
a61af66fc99e Initial load
duke
parents:
diff changeset
3323 // byte length followed by that many bytes of data.
a61af66fc99e Initial load
duke
parents:
diff changeset
3324 seek(absoluteOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3325 int len = readByte() & 0xFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
3326 return 1 + len;
a61af66fc99e Initial load
duke
parents:
diff changeset
3327 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3328
a61af66fc99e Initial load
duke
parents:
diff changeset
3329 private String readLengthPrefixedStringAt(int absoluteOffset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3330 // NOTE: it isn't clear whether LF_VARSTRING numeric leaves
a61af66fc99e Initial load
duke
parents:
diff changeset
3331 // ever show up, or in general what happens when the length
a61af66fc99e Initial load
duke
parents:
diff changeset
3332 // of the string is > 255 (FIXME)
a61af66fc99e Initial load
duke
parents:
diff changeset
3333 seek(absoluteOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3334 int len = readByte() & 0xFF;
a61af66fc99e Initial load
duke
parents:
diff changeset
3335 byte[] res = new byte[len];
a61af66fc99e Initial load
duke
parents:
diff changeset
3336 int numRead = readBytes(res);
a61af66fc99e Initial load
duke
parents:
diff changeset
3337 if (numRead != len) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3338 throw new COFFException("Error reading length prefixed string in symbol at offset " +
a61af66fc99e Initial load
duke
parents:
diff changeset
3339 absoluteOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3340 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3341 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
3342 return new String(res, US_ASCII);
a61af66fc99e Initial load
duke
parents:
diff changeset
3343 } catch (UnsupportedEncodingException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3344 throw new COFFException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
3345 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3346 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3347
a61af66fc99e Initial load
duke
parents:
diff changeset
3348 private int unbiasTypeIndex(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3349 return index - 0x1000;
a61af66fc99e Initial load
duke
parents:
diff changeset
3350 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3351
a61af66fc99e Initial load
duke
parents:
diff changeset
3352 private int biasTypeIndex(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3353 return index + 0x1000;
a61af66fc99e Initial load
duke
parents:
diff changeset
3354 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3355 } // Class DebugVC50Impl
a61af66fc99e Initial load
duke
parents:
diff changeset
3356
a61af66fc99e Initial load
duke
parents:
diff changeset
3357 class SectionHeaderImpl implements SectionHeader {
a61af66fc99e Initial load
duke
parents:
diff changeset
3358 private String name;
a61af66fc99e Initial load
duke
parents:
diff changeset
3359 private int virtualSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
3360 private int virtualAddress;
a61af66fc99e Initial load
duke
parents:
diff changeset
3361 private int sizeOfRawData;
a61af66fc99e Initial load
duke
parents:
diff changeset
3362 private int pointerToRawData;
a61af66fc99e Initial load
duke
parents:
diff changeset
3363 private int pointerToRelocations;
a61af66fc99e Initial load
duke
parents:
diff changeset
3364 private int pointerToLineNumbers;
a61af66fc99e Initial load
duke
parents:
diff changeset
3365 private short numberOfRelocations;
a61af66fc99e Initial load
duke
parents:
diff changeset
3366 private short numberOfLineNumbers;
a61af66fc99e Initial load
duke
parents:
diff changeset
3367 private int characteristics;
a61af66fc99e Initial load
duke
parents:
diff changeset
3368 private MemoizedObject[] relocations;
a61af66fc99e Initial load
duke
parents:
diff changeset
3369 private MemoizedObject[] lineNumbers;
a61af66fc99e Initial load
duke
parents:
diff changeset
3370
a61af66fc99e Initial load
duke
parents:
diff changeset
3371 public SectionHeaderImpl(int offset) throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3372 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3373
a61af66fc99e Initial load
duke
parents:
diff changeset
3374 // FIXME: compute name lazily
a61af66fc99e Initial load
duke
parents:
diff changeset
3375
a61af66fc99e Initial load
duke
parents:
diff changeset
3376 // Read name
a61af66fc99e Initial load
duke
parents:
diff changeset
3377 byte[] tmpName = new byte[8];
a61af66fc99e Initial load
duke
parents:
diff changeset
3378 int numRead = readBytes(tmpName);
a61af66fc99e Initial load
duke
parents:
diff changeset
3379 if (numRead != 8) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3380 throw new COFFException("Error reading name of section header at offset " + offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3381 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3382 if (tmpName[0] == (byte) '/') {
a61af66fc99e Initial load
duke
parents:
diff changeset
3383 // Long name; must find real value in string table
a61af66fc99e Initial load
duke
parents:
diff changeset
3384 int index = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
3385 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
3386 index = Integer.parseInt(new String(tmpName, 1, tmpName.length - 1, US_ASCII));
a61af66fc99e Initial load
duke
parents:
diff changeset
3387 } catch (NumberFormatException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3388 throw new COFFException("Error parsing string table index of name of section header " +
a61af66fc99e Initial load
duke
parents:
diff changeset
3389 "at offset " + offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3390 } catch (UnsupportedEncodingException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3391 throw new COFFException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
3392 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3393 // Look up in string table
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
3394 // FIXME: this index value is assumed to be in the valid range
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3395 name = getStringTable().get(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
3396 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3397 try {
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
3398 int length = 0;
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
3399 // find last non-NULL
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
3400 for (; length < tmpName.length && tmpName[length] != '\0';) {
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
3401 length++;
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
3402 }
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
3403 // don't include NULL chars in returned name String
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
3404 name = new String(tmpName, 0, length, US_ASCII);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3405 } catch (UnsupportedEncodingException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3406 throw new COFFException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
3407 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3408 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3409 virtualSize = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3410 virtualAddress = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3411 sizeOfRawData = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3412 pointerToRawData = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3413 pointerToRelocations = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3414 pointerToLineNumbers = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3415 numberOfRelocations = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
3416 numberOfLineNumbers = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
3417 characteristics = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3418
a61af66fc99e Initial load
duke
parents:
diff changeset
3419 // Set up relocations
a61af66fc99e Initial load
duke
parents:
diff changeset
3420 relocations = new MemoizedObject[numberOfRelocations];
a61af66fc99e Initial load
duke
parents:
diff changeset
3421 for (int i = 0; i < numberOfRelocations; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3422 final int relocOffset = pointerToRelocations + i * RELOCATION_SIZE;
a61af66fc99e Initial load
duke
parents:
diff changeset
3423 relocations[i] = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3424 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3425 return new COFFRelocationImpl(relocOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3426 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3427 };
a61af66fc99e Initial load
duke
parents:
diff changeset
3428 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3429
a61af66fc99e Initial load
duke
parents:
diff changeset
3430 // Set up line numbers
a61af66fc99e Initial load
duke
parents:
diff changeset
3431 lineNumbers = new MemoizedObject[numberOfLineNumbers];
a61af66fc99e Initial load
duke
parents:
diff changeset
3432 for (int i = 0; i < numberOfLineNumbers; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3433 final int lineNoOffset = pointerToLineNumbers + i * LINE_NUMBER_SIZE;
a61af66fc99e Initial load
duke
parents:
diff changeset
3434 lineNumbers[i] = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3435 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3436 return new COFFLineNumberImpl(lineNoOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3437 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3438 };
a61af66fc99e Initial load
duke
parents:
diff changeset
3439 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3440 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3441
a61af66fc99e Initial load
duke
parents:
diff changeset
3442 public String getName() { return name; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3443 public int getSize() { return virtualSize; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3444 public int getVirtualAddress() { return virtualAddress; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3445 public int getSizeOfRawData() { return sizeOfRawData; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3446 public int getPointerToRawData() { return pointerToRawData; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3447 public int getPointerToRelocations() { return pointerToRelocations; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3448 public int getPointerToLineNumbers() { return pointerToLineNumbers; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3449 public short getNumberOfRelocations() { return numberOfRelocations; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3450 public short getNumberOfLineNumbers() { return numberOfLineNumbers; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3451 public int getSectionFlags() { return characteristics; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3452 public boolean hasSectionFlag(int flag ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3453 return ((characteristics & flag) != 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
3454 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3455 public COFFRelocation getCOFFRelocation(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3456 return (COFFRelocation) relocations[index].getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
3457 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3458 public COFFLineNumber getCOFFLineNumber(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3459 return (COFFLineNumber) lineNumbers[index];
a61af66fc99e Initial load
duke
parents:
diff changeset
3460 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3461 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3462
a61af66fc99e Initial load
duke
parents:
diff changeset
3463 class COFFSymbolImpl implements COFFSymbol, COFFSymbolConstants {
a61af66fc99e Initial load
duke
parents:
diff changeset
3464 private int offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
3465 private String name;
a61af66fc99e Initial load
duke
parents:
diff changeset
3466 private int value;
a61af66fc99e Initial load
duke
parents:
diff changeset
3467 private short sectionNumber;
a61af66fc99e Initial load
duke
parents:
diff changeset
3468 private short type;
a61af66fc99e Initial load
duke
parents:
diff changeset
3469 private byte storageClass;
a61af66fc99e Initial load
duke
parents:
diff changeset
3470 private byte numberOfAuxSymbols;
a61af66fc99e Initial load
duke
parents:
diff changeset
3471 private MemoizedObject auxFunctionDefinitionRecord = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3472 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3473 return new AuxFunctionDefinitionRecordImpl(offset + SYMBOL_SIZE);
a61af66fc99e Initial load
duke
parents:
diff changeset
3474 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3475 };
a61af66fc99e Initial load
duke
parents:
diff changeset
3476 private MemoizedObject auxBfEfRecord = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3477 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3478 return new AuxBfEfRecordImpl(offset + SYMBOL_SIZE);
a61af66fc99e Initial load
duke
parents:
diff changeset
3479 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3480 };
a61af66fc99e Initial load
duke
parents:
diff changeset
3481 private MemoizedObject auxWeakExternalRecord = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3482 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3483 return new AuxWeakExternalRecordImpl(offset + SYMBOL_SIZE);
a61af66fc99e Initial load
duke
parents:
diff changeset
3484 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3485 };
a61af66fc99e Initial load
duke
parents:
diff changeset
3486 private MemoizedObject auxFileRecord = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3487 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3488 return new AuxFileRecordImpl(offset + SYMBOL_SIZE);
a61af66fc99e Initial load
duke
parents:
diff changeset
3489 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3490 };
a61af66fc99e Initial load
duke
parents:
diff changeset
3491 private MemoizedObject auxSectionDefinitionsRecord = new MemoizedObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3492 public Object computeValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3493 return new AuxSectionDefinitionsRecordImpl(offset + SYMBOL_SIZE);
a61af66fc99e Initial load
duke
parents:
diff changeset
3494 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3495 };
a61af66fc99e Initial load
duke
parents:
diff changeset
3496
a61af66fc99e Initial load
duke
parents:
diff changeset
3497 public COFFSymbolImpl(int offset) throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3498 this.offset = offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
3499 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3500
a61af66fc99e Initial load
duke
parents:
diff changeset
3501 // Parse name
a61af66fc99e Initial load
duke
parents:
diff changeset
3502 byte[] tmpName = new byte[8];
a61af66fc99e Initial load
duke
parents:
diff changeset
3503 int numRead = readBytes(tmpName);
a61af66fc99e Initial load
duke
parents:
diff changeset
3504 if (numRead != 8) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3505 throw new COFFException("Error reading name of symbol at offset " + offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3506 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3507 if ((tmpName[0] == 0) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
3508 (tmpName[1] == 0) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
3509 (tmpName[2] == 0) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
3510 (tmpName[3] == 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3511 // It's an offset into the string table.
a61af66fc99e Initial load
duke
parents:
diff changeset
3512 // FIXME: not sure about byte ordering...
a61af66fc99e Initial load
duke
parents:
diff changeset
3513 int stringOffset = (tmpName[4] << 24 |
a61af66fc99e Initial load
duke
parents:
diff changeset
3514 tmpName[5] << 16 |
a61af66fc99e Initial load
duke
parents:
diff changeset
3515 tmpName[6] << 8 |
a61af66fc99e Initial load
duke
parents:
diff changeset
3516 tmpName[7]);
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
3517 // FIXME: stringOffset is assumed to be in the valid range
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3518 name = getStringTable().getAtOffset(stringOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3519 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3520
a61af66fc99e Initial load
duke
parents:
diff changeset
3521 value = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3522 sectionNumber = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
3523 type = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
3524 storageClass = readByte();
a61af66fc99e Initial load
duke
parents:
diff changeset
3525 numberOfAuxSymbols = readByte();
a61af66fc99e Initial load
duke
parents:
diff changeset
3526 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3527
a61af66fc99e Initial load
duke
parents:
diff changeset
3528 public int getOffset() { return offset; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3529 public String getName() { return name; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3530 public int getValue() { return value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3531 public short getSectionNumber() { return sectionNumber; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3532 public short getType() { return type; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3533 public byte getStorageClass() { return storageClass; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3534 public byte getNumberOfAuxSymbols() { return numberOfAuxSymbols; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3535 public boolean isFunctionDefinition() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3536 return ((getStorageClass() == IMAGE_SYM_CLASS_EXTERNAL) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
3537 ((getType() >>> 8) == IMAGE_SYM_DTYPE_FUNCTION) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
3538 (getSectionNumber() > 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
3539 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3540 public AuxFunctionDefinitionRecord getAuxFunctionDefinitionRecord() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3541 return (AuxFunctionDefinitionRecord) auxFunctionDefinitionRecord.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
3542 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3543 public boolean isBfOrEfSymbol() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3544 return ((getName().equals(".bf") || getName().equals(".ef")) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
3545 (getStorageClass() == IMAGE_SYM_CLASS_FUNCTION));
a61af66fc99e Initial load
duke
parents:
diff changeset
3546 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3547 public AuxBfEfRecord getAuxBfEfRecord() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3548 return (AuxBfEfRecord) auxBfEfRecord.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
3549 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3550 public boolean isWeakExternal() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3551 return ((getStorageClass() == IMAGE_SYM_CLASS_EXTERNAL) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
3552 (getSectionNumber() == IMAGE_SYM_UNDEFINED) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
3553 (getValue() == 0));
a61af66fc99e Initial load
duke
parents:
diff changeset
3554 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3555 public AuxWeakExternalRecord getAuxWeakExternalRecord() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3556 return (AuxWeakExternalRecord) auxWeakExternalRecord.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
3557 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3558 public boolean isFile() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3559 return ((getName().equals(".file")) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
3560 (getStorageClass() == IMAGE_SYM_CLASS_FILE));
a61af66fc99e Initial load
duke
parents:
diff changeset
3561 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3562 public AuxFileRecord getAuxFileRecord() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3563 return (AuxFileRecord) auxFileRecord.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
3564 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3565 public boolean isSectionDefinition() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3566 // FIXME: not sure how to ensure that symbol name is the
a61af66fc99e Initial load
duke
parents:
diff changeset
3567 // name of a section.
a61af66fc99e Initial load
duke
parents:
diff changeset
3568 return ((getName().charAt(0) == '.') &&
a61af66fc99e Initial load
duke
parents:
diff changeset
3569 (getStorageClass() == IMAGE_SYM_CLASS_STATIC));
a61af66fc99e Initial load
duke
parents:
diff changeset
3570 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3571 public AuxSectionDefinitionsRecord getAuxSectionDefinitionsRecord() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3572 return (AuxSectionDefinitionsRecord) auxSectionDefinitionsRecord.getValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
3573 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3574 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3575
a61af66fc99e Initial load
duke
parents:
diff changeset
3576 class AuxFunctionDefinitionRecordImpl implements AuxFunctionDefinitionRecord {
a61af66fc99e Initial load
duke
parents:
diff changeset
3577 private int tagIndex;
a61af66fc99e Initial load
duke
parents:
diff changeset
3578 private int totalSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
3579 private int pointerToLineNumber;
a61af66fc99e Initial load
duke
parents:
diff changeset
3580 private int pointerToNextFunction;
a61af66fc99e Initial load
duke
parents:
diff changeset
3581
a61af66fc99e Initial load
duke
parents:
diff changeset
3582 AuxFunctionDefinitionRecordImpl(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3583 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3584 tagIndex = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3585 totalSize = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3586 // NOTE zero-basing of this index
a61af66fc99e Initial load
duke
parents:
diff changeset
3587 pointerToLineNumber = readInt() - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
3588 pointerToNextFunction = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3589 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3590
a61af66fc99e Initial load
duke
parents:
diff changeset
3591 public int getTagIndex() { return tagIndex; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3592 public int getTotalSize() { return totalSize; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3593 public int getPointerToLineNumber() { return pointerToLineNumber; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3594 public int getPointerToNextFunction() { return pointerToNextFunction; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3595 public int getType() { return FUNCTION_DEFINITION; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3596 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3597
a61af66fc99e Initial load
duke
parents:
diff changeset
3598 class AuxBfEfRecordImpl implements AuxBfEfRecord {
a61af66fc99e Initial load
duke
parents:
diff changeset
3599 private short lineNumber;
a61af66fc99e Initial load
duke
parents:
diff changeset
3600 private int pointerToNextFunction;
a61af66fc99e Initial load
duke
parents:
diff changeset
3601
a61af66fc99e Initial load
duke
parents:
diff changeset
3602 AuxBfEfRecordImpl(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3603 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3604 readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3605 lineNumber = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
3606 readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3607 readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
3608 pointerToNextFunction = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3609 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3610
a61af66fc99e Initial load
duke
parents:
diff changeset
3611 public short getLineNumber() { return lineNumber; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3612 public int getPointerToNextFunction() { return pointerToNextFunction; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3613 public int getType() { return BF_EF_RECORD; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3614 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3615
a61af66fc99e Initial load
duke
parents:
diff changeset
3616 class AuxWeakExternalRecordImpl implements AuxWeakExternalRecord {
a61af66fc99e Initial load
duke
parents:
diff changeset
3617 private int tagIndex;
a61af66fc99e Initial load
duke
parents:
diff changeset
3618 private int characteristics;
a61af66fc99e Initial load
duke
parents:
diff changeset
3619
a61af66fc99e Initial load
duke
parents:
diff changeset
3620 AuxWeakExternalRecordImpl(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3621 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3622 tagIndex = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3623 characteristics = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3624 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3625
a61af66fc99e Initial load
duke
parents:
diff changeset
3626 public int getTagIndex() { return tagIndex; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3627 public int getCharacteristics() { return characteristics; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3628 public int getType() { return WEAK_EXTERNAL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3629 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3630
a61af66fc99e Initial load
duke
parents:
diff changeset
3631 class AuxFileRecordImpl implements AuxFileRecord {
a61af66fc99e Initial load
duke
parents:
diff changeset
3632 private String name;
a61af66fc99e Initial load
duke
parents:
diff changeset
3633
a61af66fc99e Initial load
duke
parents:
diff changeset
3634 AuxFileRecordImpl(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3635 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3636 byte[] tmpName = new byte[18];
a61af66fc99e Initial load
duke
parents:
diff changeset
3637 int numRead = readBytes(tmpName);
a61af66fc99e Initial load
duke
parents:
diff changeset
3638 if (numRead != 18) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3639 throw new COFFException("Error reading auxiliary file record at offset " + offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3640 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3641 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
3642 name = new String(tmpName, US_ASCII);
a61af66fc99e Initial load
duke
parents:
diff changeset
3643 } catch (UnsupportedEncodingException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3644 throw new COFFException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
3645 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3646 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3647
a61af66fc99e Initial load
duke
parents:
diff changeset
3648 public String getName() { return name; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3649 public int getType() { return FILE; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3650 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3651
a61af66fc99e Initial load
duke
parents:
diff changeset
3652 class AuxSectionDefinitionsRecordImpl implements AuxSectionDefinitionsRecord {
a61af66fc99e Initial load
duke
parents:
diff changeset
3653 private int length;
a61af66fc99e Initial load
duke
parents:
diff changeset
3654 private short numberOfRelocations;
a61af66fc99e Initial load
duke
parents:
diff changeset
3655 private short numberOfLineNumbers;
a61af66fc99e Initial load
duke
parents:
diff changeset
3656 private int checkSum;
a61af66fc99e Initial load
duke
parents:
diff changeset
3657 private short number;
a61af66fc99e Initial load
duke
parents:
diff changeset
3658 private byte selection;
a61af66fc99e Initial load
duke
parents:
diff changeset
3659
a61af66fc99e Initial load
duke
parents:
diff changeset
3660 AuxSectionDefinitionsRecordImpl(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3661 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3662 length = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3663 numberOfRelocations = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
3664 numberOfLineNumbers = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
3665 checkSum = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3666 number = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
3667 selection = readByte();
a61af66fc99e Initial load
duke
parents:
diff changeset
3668 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3669
a61af66fc99e Initial load
duke
parents:
diff changeset
3670 public int getLength() { return length; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3671 public short getNumberOfRelocations() { return numberOfRelocations; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3672 public short getNumberOfLineNumbers() { return numberOfLineNumbers; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3673 public int getCheckSum() { return checkSum; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3674 public short getNumber() { return number; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3675 public byte getSelection() { return selection; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3676 public int getType() { return SECTION_DEFINITION; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3677 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3678
a61af66fc99e Initial load
duke
parents:
diff changeset
3679 class COFFRelocationImpl implements COFFRelocation {
a61af66fc99e Initial load
duke
parents:
diff changeset
3680 private int virtualAddress;
a61af66fc99e Initial load
duke
parents:
diff changeset
3681 private int symbolTableIndex;
a61af66fc99e Initial load
duke
parents:
diff changeset
3682 private short type;
a61af66fc99e Initial load
duke
parents:
diff changeset
3683
a61af66fc99e Initial load
duke
parents:
diff changeset
3684 COFFRelocationImpl(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3685 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3686 virtualAddress = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3687 symbolTableIndex = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3688 type = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
3689 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3690
a61af66fc99e Initial load
duke
parents:
diff changeset
3691 public int getVirtualAddress() { return virtualAddress; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3692 public int getSymbolTableIndex() { return symbolTableIndex; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3693 public short getType() { return type; }
a61af66fc99e Initial load
duke
parents:
diff changeset
3694 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3695
a61af66fc99e Initial load
duke
parents:
diff changeset
3696 class COFFLineNumberImpl implements COFFLineNumber {
a61af66fc99e Initial load
duke
parents:
diff changeset
3697 private int type;
a61af66fc99e Initial load
duke
parents:
diff changeset
3698 private short lineNumber;
a61af66fc99e Initial load
duke
parents:
diff changeset
3699
a61af66fc99e Initial load
duke
parents:
diff changeset
3700 COFFLineNumberImpl(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3701 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3702 type = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3703 lineNumber = readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
3704 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3705
a61af66fc99e Initial load
duke
parents:
diff changeset
3706 public int getType() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3707 return type;
a61af66fc99e Initial load
duke
parents:
diff changeset
3708 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3709
a61af66fc99e Initial load
duke
parents:
diff changeset
3710 public short getLineNumber() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3711 return lineNumber;
a61af66fc99e Initial load
duke
parents:
diff changeset
3712 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3713 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3714
a61af66fc99e Initial load
duke
parents:
diff changeset
3715 class StringTable {
a61af66fc99e Initial load
duke
parents:
diff changeset
3716 class COFFString {
a61af66fc99e Initial load
duke
parents:
diff changeset
3717 String str;
a61af66fc99e Initial load
duke
parents:
diff changeset
3718 int offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
3719
a61af66fc99e Initial load
duke
parents:
diff changeset
3720 COFFString(String str, int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3721 this.str = str; this.offset = offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
3722 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3723 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3724
a61af66fc99e Initial load
duke
parents:
diff changeset
3725 COFFString[] strings;
a61af66fc99e Initial load
duke
parents:
diff changeset
3726
a61af66fc99e Initial load
duke
parents:
diff changeset
3727 StringTable(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3728 if (offset == 0) {
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
3729 // no String Table
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3730 strings = new COFFString[0];
a61af66fc99e Initial load
duke
parents:
diff changeset
3731 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
3732 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3733
a61af66fc99e Initial load
duke
parents:
diff changeset
3734 seek(offset);
2072
d6cd0d55d0b5 6987812: 2/3 SAJDI: "gHotSpotVMTypes was not initialized properly in the remote process"
dcubed
parents: 1552
diff changeset
3735 int length = readInt(); // length includes itself
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3736 byte[] data = new byte[length - 4];
a61af66fc99e Initial load
duke
parents:
diff changeset
3737 int numBytesRead = readBytes(data);
a61af66fc99e Initial load
duke
parents:
diff changeset
3738 if (numBytesRead != data.length) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3739 throw new COFFException("Error reading string table (read " +
a61af66fc99e Initial load
duke
parents:
diff changeset
3740 numBytesRead + " bytes, expected to read " + data.length + ")");
a61af66fc99e Initial load
duke
parents:
diff changeset
3741 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3742 int numStrings = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
3743 int ptr = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
3744 for (ptr = 0; ptr < data.length; ptr++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3745 if (data[ptr] == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3746 numStrings++;
a61af66fc99e Initial load
duke
parents:
diff changeset
3747 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3748 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3749 strings = new COFFString[numStrings];
a61af66fc99e Initial load
duke
parents:
diff changeset
3750 int lastPtr = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
3751 ptr = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
3752 for (int i = 0; i < numStrings; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3753 while (data[ptr] != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3754 ptr++;
a61af66fc99e Initial load
duke
parents:
diff changeset
3755 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3756 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
3757 strings[i] = new COFFString(new String(data, lastPtr, ptr - lastPtr, US_ASCII),
a61af66fc99e Initial load
duke
parents:
diff changeset
3758 offset + ptr + 4);
a61af66fc99e Initial load
duke
parents:
diff changeset
3759 } catch (UnsupportedEncodingException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3760 throw new COFFException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
3761 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3762 ptr++;
a61af66fc99e Initial load
duke
parents:
diff changeset
3763 lastPtr = ptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
3764 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3765 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3766
a61af66fc99e Initial load
duke
parents:
diff changeset
3767 int getNum() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3768 return strings.length;
a61af66fc99e Initial load
duke
parents:
diff changeset
3769 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3770
a61af66fc99e Initial load
duke
parents:
diff changeset
3771 String get(int i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3772 return strings[i].str;
a61af66fc99e Initial load
duke
parents:
diff changeset
3773 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3774
a61af66fc99e Initial load
duke
parents:
diff changeset
3775 /** This version takes an absolute offset in the file */
a61af66fc99e Initial load
duke
parents:
diff changeset
3776 String getAtOffset(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3777 int i = Arrays.binarySearch(strings, new COFFString(null, offset),
a61af66fc99e Initial load
duke
parents:
diff changeset
3778 new Comparator() {
a61af66fc99e Initial load
duke
parents:
diff changeset
3779 public int compare(Object o1, Object o2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3780 COFFString s1 = (COFFString) o1;
a61af66fc99e Initial load
duke
parents:
diff changeset
3781 COFFString s2 = (COFFString) o2;
a61af66fc99e Initial load
duke
parents:
diff changeset
3782 if (s1.offset == s2.offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3783 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
3784 } else if (s1.offset < s2.offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3785 return -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
3786 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
3787 return 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
3788 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3789 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3790 });
a61af66fc99e Initial load
duke
parents:
diff changeset
3791 if (i < 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3792 throw new COFFException("No string found at file offset " + offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3793 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3794 return strings[i].str;
a61af66fc99e Initial load
duke
parents:
diff changeset
3795 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3796 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3797 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3798
a61af66fc99e Initial load
duke
parents:
diff changeset
3799 void initialize() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3800 // Figure out whether this file is an object file or an image
a61af66fc99e Initial load
duke
parents:
diff changeset
3801 // (either executable or DLL).
a61af66fc99e Initial load
duke
parents:
diff changeset
3802 seek(0x3c); // Error here probably indicates file format error
a61af66fc99e Initial load
duke
parents:
diff changeset
3803 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
3804 int peOffset = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3805 seek(peOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3806 if ((readByte() == (byte) 'P') &&
a61af66fc99e Initial load
duke
parents:
diff changeset
3807 (readByte() == (byte) 'E') &&
a61af66fc99e Initial load
duke
parents:
diff changeset
3808 (readByte() == (byte) 0) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
3809 (readByte() == (byte) 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3810 isImage = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
3811 imageHeaderOffset = getFilePointer();
a61af66fc99e Initial load
duke
parents:
diff changeset
3812 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3813 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3814 catch (COFFException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3815 // Expect failures here if not image file.
a61af66fc99e Initial load
duke
parents:
diff changeset
3816 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3817 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3818
a61af66fc99e Initial load
duke
parents:
diff changeset
3819 byte readByteAt(long offset) throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3820 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3821 return readByte();
a61af66fc99e Initial load
duke
parents:
diff changeset
3822 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3823
a61af66fc99e Initial load
duke
parents:
diff changeset
3824 byte readByte() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3825 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
3826 return file.readByte();
a61af66fc99e Initial load
duke
parents:
diff changeset
3827 } catch (IOException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3828 throw new COFFException(e.toString() + " at offset 0x" +
a61af66fc99e Initial load
duke
parents:
diff changeset
3829 Long.toHexString(filePos), e);
a61af66fc99e Initial load
duke
parents:
diff changeset
3830 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3831 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3832
a61af66fc99e Initial load
duke
parents:
diff changeset
3833 int readBytesAt(long offset, byte[] b) throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3834 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3835 return readBytes(b);
a61af66fc99e Initial load
duke
parents:
diff changeset
3836 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3837
a61af66fc99e Initial load
duke
parents:
diff changeset
3838 int readBytes(byte[] b) throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3839 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
3840 return file.read(b);
a61af66fc99e Initial load
duke
parents:
diff changeset
3841 } catch (IOException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3842 throw new COFFException(e.toString() + " at offset 0x" +
a61af66fc99e Initial load
duke
parents:
diff changeset
3843 Long.toHexString(filePos), e);
a61af66fc99e Initial load
duke
parents:
diff changeset
3844 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3845 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3846
a61af66fc99e Initial load
duke
parents:
diff changeset
3847 /** NOTE: reads little-endian short */
a61af66fc99e Initial load
duke
parents:
diff changeset
3848 short readShortAt(long offset) throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3849 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3850 return readShort();
a61af66fc99e Initial load
duke
parents:
diff changeset
3851 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3852
a61af66fc99e Initial load
duke
parents:
diff changeset
3853 /** NOTE: reads little-endian short */
a61af66fc99e Initial load
duke
parents:
diff changeset
3854 short readShort() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3855 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
3856 return byteSwap(file.readShort());
a61af66fc99e Initial load
duke
parents:
diff changeset
3857 } catch (IOException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3858 throw new COFFException(e.toString() + " at offset 0x" +
a61af66fc99e Initial load
duke
parents:
diff changeset
3859 Long.toHexString(filePos), e);
a61af66fc99e Initial load
duke
parents:
diff changeset
3860 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3861 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3862
a61af66fc99e Initial load
duke
parents:
diff changeset
3863 /** NOTE: reads little-endian int */
a61af66fc99e Initial load
duke
parents:
diff changeset
3864 int readIntAt(long offset) throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3865 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3866 return readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3867 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3868
a61af66fc99e Initial load
duke
parents:
diff changeset
3869 /** NOTE: reads little-endian int */
a61af66fc99e Initial load
duke
parents:
diff changeset
3870 int readInt() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3871 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
3872 return byteSwap(file.readInt());
a61af66fc99e Initial load
duke
parents:
diff changeset
3873 } catch (IOException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3874 throw new COFFException(e.toString() + " at offset 0x" +
a61af66fc99e Initial load
duke
parents:
diff changeset
3875 Long.toHexString(filePos), e);
a61af66fc99e Initial load
duke
parents:
diff changeset
3876 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3877 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3878
a61af66fc99e Initial load
duke
parents:
diff changeset
3879 /** NOTE: reads little-endian long */
a61af66fc99e Initial load
duke
parents:
diff changeset
3880 long readLongAt(long offset) throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3881 seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3882 return readLong();
a61af66fc99e Initial load
duke
parents:
diff changeset
3883 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3884
a61af66fc99e Initial load
duke
parents:
diff changeset
3885 /** NOTE: reads little-endian long */
a61af66fc99e Initial load
duke
parents:
diff changeset
3886 long readLong() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3887 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
3888 return byteSwap(file.readLong());
a61af66fc99e Initial load
duke
parents:
diff changeset
3889 } catch (IOException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3890 throw new COFFException(e.toString() + " at offset 0x" +
a61af66fc99e Initial load
duke
parents:
diff changeset
3891 Long.toHexString(filePos), e);
a61af66fc99e Initial load
duke
parents:
diff changeset
3892 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3893 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3894
a61af66fc99e Initial load
duke
parents:
diff changeset
3895 /** NOTE: reads little-endian float */
a61af66fc99e Initial load
duke
parents:
diff changeset
3896 float readFloat() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3897 int i = readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
3898 return Float.intBitsToFloat(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
3899 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3900
a61af66fc99e Initial load
duke
parents:
diff changeset
3901 /** NOTE: reads little-endian double */
a61af66fc99e Initial load
duke
parents:
diff changeset
3902 double readDouble() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3903 long l = readLong();
a61af66fc99e Initial load
duke
parents:
diff changeset
3904 return Double.longBitsToDouble(l);
a61af66fc99e Initial load
duke
parents:
diff changeset
3905 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3906
a61af66fc99e Initial load
duke
parents:
diff changeset
3907 String readCString() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3908 List data = new ArrayList();
a61af66fc99e Initial load
duke
parents:
diff changeset
3909 byte b = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
3910 while ((b = readByte()) != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3911 data.add(new Byte(b));
a61af66fc99e Initial load
duke
parents:
diff changeset
3912 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3913 byte[] bytes = new byte[data.size()];
a61af66fc99e Initial load
duke
parents:
diff changeset
3914 for (int i = 0; i < data.size(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3915 bytes[i] = ((Byte) data.get(i)).byteValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
3916 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3917 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
3918 return new String(bytes, US_ASCII);
a61af66fc99e Initial load
duke
parents:
diff changeset
3919 } catch (UnsupportedEncodingException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3920 throw new COFFException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
3921 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3922 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3923
a61af66fc99e Initial load
duke
parents:
diff changeset
3924 void seek(long offset) throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3925 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
3926 filePos = offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
3927 file.seek(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
3928 } catch (IOException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3929 throw new COFFException(e.toString() + " at offset 0x" +
a61af66fc99e Initial load
duke
parents:
diff changeset
3930 Long.toHexString(offset), e);
a61af66fc99e Initial load
duke
parents:
diff changeset
3931 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3932 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3933
a61af66fc99e Initial load
duke
parents:
diff changeset
3934 long getFilePointer() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3935 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
3936 return file.getFilePointer();
a61af66fc99e Initial load
duke
parents:
diff changeset
3937 } catch (IOException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3938 throw new COFFException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
3939 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3940 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3941
a61af66fc99e Initial load
duke
parents:
diff changeset
3942 short byteSwap(short arg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3943 return (short) ((arg << 8) | ((arg >>> 8) & 0xFF));
a61af66fc99e Initial load
duke
parents:
diff changeset
3944 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3945
a61af66fc99e Initial load
duke
parents:
diff changeset
3946 int byteSwap(int arg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3947 return (((int) byteSwap((short) arg)) << 16) | (((int) (byteSwap((short) (arg >>> 16)))) & 0xFFFF);
a61af66fc99e Initial load
duke
parents:
diff changeset
3948 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3949
a61af66fc99e Initial load
duke
parents:
diff changeset
3950 long byteSwap(long arg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3951 return ((((long) byteSwap((int) arg)) << 32) | (((long) byteSwap((int) (arg >>> 32))) & 0xFFFFFFFF));
a61af66fc99e Initial load
duke
parents:
diff changeset
3952 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3953
a61af66fc99e Initial load
duke
parents:
diff changeset
3954 public void close() throws COFFException {
a61af66fc99e Initial load
duke
parents:
diff changeset
3955 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
3956 file.close();
a61af66fc99e Initial load
duke
parents:
diff changeset
3957 } catch (IOException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
3958 throw new COFFException(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
3959 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3960 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3961 }
a61af66fc99e Initial load
duke
parents:
diff changeset
3962 }