annotate agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/COFFFileParser.java @ 0:a61af66fc99e jdk7-b24

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