Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/TestDebugInfo.java @ 6842:b9a9ed0f8eeb
7197424: update copyright year to match last edit in jdk8 hotspot repository
Summary: Update copyright year to 2012 for relevant files
Reviewed-by: dholmes, coleenp
author | mikael |
---|---|
date | Tue, 09 Oct 2012 10:09:34 -0700 |
parents | c18cbe5936b8 |
children |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
2 * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.debugger.win32.coff; | |
26 | |
27 public class TestDebugInfo implements DebugVC50SubsectionTypes, DebugVC50SymbolTypes, DebugVC50TypeLeafIndices { | |
28 public static void main(String[] args) { | |
29 if (args.length != 1) { | |
30 System.err.println("usage: java TestParser [file name]"); | |
31 System.err.println("File name may be an .exe, .dll or .obj"); | |
32 System.exit(1); | |
33 } | |
34 | |
35 try { | |
36 COFFFile file = COFFFileParser.getParser().parse(args[0]); | |
37 if (file.isImage()) { | |
38 System.out.println("PE Image detected."); | |
39 } else { | |
40 System.out.println("PE Image NOT detected, assuming object file."); | |
41 } | |
42 | |
43 DebugVC50 vc50 = getDebugVC50(file); | |
44 if (vc50 == null) { | |
45 System.out.println("No debug information found."); | |
46 System.exit(1); | |
47 } else { | |
48 System.out.println("Debug information found!"); | |
49 } | |
50 | |
51 DebugVC50SubsectionDirectory dir = vc50.getSubsectionDirectory(); | |
52 for (int i = 0; i < dir.getNumEntries(); i++) { | |
53 DebugVC50Subsection sec = dir.getSubsection(i); | |
54 switch (sec.getSubsectionType()) { | |
55 case SST_MODULE: System.out.println(" SST_MODULE"); break; | |
56 case SST_TYPES: System.out.println(" SST_TYPES"); break; | |
57 case SST_PUBLIC: System.out.println(" SST_PUBLIC"); break; | |
58 case SST_PUBLIC_SYM: System.out.println(" SST_PUBLIC_SYM"); break; | |
59 case SST_SYMBOLS: System.out.println(" SST_SYMBOLS"); break; | |
60 case SST_ALIGN_SYM: System.out.println(" SST_ALIGN_SYM"); printSymbolTable(((DebugVC50SSAlignSym) sec).getSymbolIterator()); break; | |
61 case SST_SRC_LN_SEG: System.out.println(" SST_SRC_LN_SEG"); break; | |
62 case SST_SRC_MODULE: System.out.println(" SST_SRC_MODULE"); break; | |
63 case SST_LIBRARIES: System.out.println(" SST_LIBRARIES"); break; | |
64 case SST_GLOBAL_SYM: System.out.println(" SST_GLOBAL_SYM"); printSymbolTable(sec); break; | |
65 case SST_GLOBAL_PUB: System.out.println(" SST_GLOBAL_PUB"); printSymbolTable(sec); break; | |
66 case SST_GLOBAL_TYPES: System.out.println(" SST_GLOBAL_TYPES"); printTypeTable(sec); break; | |
67 case SST_MPC: System.out.println(" SST_MPC"); break; | |
68 case SST_SEG_MAP: System.out.println(" SST_SEG_MAP"); break; | |
69 case SST_SEG_NAME: System.out.println(" SST_SEG_NAME"); break; | |
70 case SST_PRE_COMP: System.out.println(" SST_PRE_COMP"); break; | |
71 case SST_UNUSED: System.out.println(" SST_UNUSED"); break; | |
72 case SST_OFFSET_MAP_16: System.out.println(" SST_OFFSET_MAP_16"); break; | |
73 case SST_OFFSET_MAP_32: System.out.println(" SST_OFFSET_MAP_32"); break; | |
74 case SST_FILE_INDEX: System.out.println(" SST_FILE_INDEX"); break; | |
75 case SST_STATIC_SYM: System.out.println(" SST_STATIC_SYM"); printSymbolTable(sec); break; | |
76 default: System.out.println(" (Unknown subsection type " + sec.getSubsectionType() + ")"); break; | |
77 } | |
78 } | |
79 | |
80 } catch (Exception e) { | |
81 e.printStackTrace(); | |
82 } | |
83 } | |
84 | |
85 private static DebugVC50 getDebugVC50(COFFFile file) { | |
86 COFFHeader header = file.getHeader(); | |
87 OptionalHeader opt = header.getOptionalHeader(); | |
88 if (opt == null) { | |
89 System.out.println("Optional header not found."); | |
90 return null; | |
91 } | |
92 OptionalHeaderDataDirectories dd = opt.getDataDirectories(); | |
93 if (dd == null) { | |
94 System.out.println("Optional header data directories not found."); | |
95 return null; | |
96 } | |
97 DebugDirectory debug = dd.getDebugDirectory(); | |
98 if (debug == null) { | |
99 System.out.println("Debug directory not found."); | |
100 return null; | |
101 } | |
102 for (int i = 0; i < debug.getNumEntries(); i++) { | |
103 DebugDirectoryEntry entry = debug.getEntry(i); | |
104 if (entry.getType() == DebugTypes.IMAGE_DEBUG_TYPE_CODEVIEW) { | |
105 System.out.println("Debug Directory Entry " + i + " has debug type IMAGE_DEBUG_TYPE_CODEVIEW"); | |
106 return entry.getDebugVC50(); | |
107 } | |
108 } | |
109 | |
110 return null; | |
111 } | |
112 | |
113 private static void printSymbolTable(DebugVC50Subsection sec) { | |
114 DebugVC50SSSymbolBase sym = (DebugVC50SSSymbolBase) sec; | |
115 DebugVC50SymbolIterator iter = sym.getSymbolIterator(); | |
116 printSymbolTable(iter); | |
117 } | |
118 | |
119 private static void printSymbolTable(DebugVC50SymbolIterator iter) { | |
120 while (!iter.done()) { | |
121 int type = iter.getType() & 0xFFFF; | |
122 switch (type) { | |
123 case S_COMPILE: System.out.println(" S_COMPILE"); break; | |
124 case S_SSEARCH: System.out.println(" S_SSEARCH"); break; | |
125 case S_END: System.out.println(" S_END"); break; | |
126 case S_SKIP: System.out.println(" S_SKIP"); break; | |
127 case S_CVRESERVE: System.out.println(" S_CVRESERVE"); break; | |
128 case S_OBJNAME: System.out.println(" S_OBJNAME"); break; | |
129 case S_ENDARG: System.out.println(" S_ENDARG"); break; | |
130 case S_COBOLUDT: System.out.println(" S_COBOLUDT"); break; | |
131 case S_MANYREG: System.out.println(" S_MANYREG"); break; | |
132 case S_RETURN: System.out.println(" S_RETURN"); break; | |
133 case S_ENTRYTHIS: System.out.println(" S_ENTRYTHIS"); break; | |
134 case S_REGISTER: System.out.println(" S_REGISTER"); break; | |
135 case S_CONSTANT: System.out.println(" S_CONSTANT"); break; | |
136 case S_UDT: System.out.println(" S_UDT"); break; | |
137 case S_COBOLUDT2: System.out.println(" S_COBOLUDT2"); break; | |
138 case S_MANYREG2: System.out.println(" S_MANYREG2"); break; | |
139 case S_BPREL32: System.out.println(" S_BPREL32"); break; | |
140 case S_LDATA32: System.out.println(" S_LDATA32"); break; | |
141 case S_GDATA32: System.out.println(" S_GDATA32"); break; | |
142 case S_PUB32: System.out.println(" S_PUB32"); break; | |
143 case S_LPROC32: System.out.println(" S_LPROC32"); break; | |
144 case S_GPROC32: System.out.println(" S_GPROC32"); break; | |
145 case S_THUNK32: System.out.println(" S_THUNK32"); break; | |
146 case S_BLOCK32: System.out.println(" S_BLOCK32"); break; | |
147 case S_WITH32: System.out.println(" S_WITH32"); break; | |
148 case S_LABEL32: System.out.println(" S_LABEL32"); break; | |
149 case S_CEXMODEL32: System.out.println(" S_CEXMODEL32"); break; | |
150 case S_VFTTABLE32: System.out.println(" S_VFTTABLE32"); break; | |
151 case S_REGREL32: System.out.println(" S_REGREL32"); break; | |
152 case S_LTHREAD32: System.out.println(" S_LTHREAD32"); break; | |
153 case S_GTHREAD32: System.out.println(" S_GTHREAD32"); break; | |
154 case S_LPROCMIPS: System.out.println(" S_LPROCMIPS"); break; | |
155 case S_GPROCMIPS: System.out.println(" S_GPROCMIPS"); break; | |
156 case S_PROCREF: System.out.println(" S_PROCREF"); break; | |
157 case S_DATAREF: System.out.println(" S_DATAREF"); break; | |
158 case S_ALIGN: System.out.println(" S_ALIGN"); break; | |
159 default: System.out.println(" (Unknown symbol type " + type + ")"); break; | |
160 } | |
161 | |
162 iter.next(); | |
163 } | |
164 } | |
165 | |
166 private static void printTypeTable(DebugVC50Subsection sec) { | |
167 DebugVC50SSGlobalTypes types = (DebugVC50SSGlobalTypes) sec; | |
168 | |
169 DebugVC50TypeIterator iter = types.getTypeIterator(); | |
170 while (!iter.done()) { | |
171 System.out.print(" Type string: "); | |
172 while (!iter.typeStringDone()) { | |
173 int leaf = iter.typeStringLeaf() & 0xFFFF; | |
174 switch (leaf) { | |
175 case LF_MODIFIER: System.out.print("LF_MODIFIER "); break; | |
176 case LF_POINTER: System.out.print("LF_POINTER "); break; | |
177 case LF_ARRAY: System.out.print("LF_ARRAY "); break; | |
178 case LF_CLASS: System.out.print("LF_CLASS "); break; | |
179 case LF_STRUCTURE: System.out.print("LF_STRUCTURE "); break; | |
180 case LF_UNION: System.out.print("LF_UNION "); break; | |
181 case LF_ENUM: System.out.print("LF_ENUM "); break; | |
182 case LF_PROCEDURE: System.out.print("LF_PROCEDURE "); break; | |
183 case LF_MFUNCTION: System.out.print("LF_MFUNCTION "); break; | |
184 case LF_VTSHAPE: System.out.print("LF_VTSHAPE "); break; | |
185 case LF_COBOL0: System.out.print("LF_COBOL0 "); break; | |
186 case LF_COBOL1: System.out.print("LF_COBOL1 "); break; | |
187 case LF_BARRAY: System.out.print("LF_BARRAY "); break; | |
188 case LF_LABEL: System.out.print("LF_LABEL "); break; | |
189 case LF_NULL: System.out.print("LF_NULL "); break; | |
190 case LF_NOTTRAN: System.out.print("LF_NOTTRAN "); break; | |
191 case LF_DIMARRAY: System.out.print("LF_DIMARRAY "); break; | |
192 case LF_VFTPATH: System.out.print("LF_VFTPATH "); break; | |
193 case LF_PRECOMP: System.out.print("LF_PRECOMP "); break; | |
194 case LF_ENDPRECOMP: System.out.print("LF_ENDPRECOMP "); break; | |
195 case LF_OEM: System.out.print("LF_OEM "); break; | |
196 case LF_TYPESERVER: System.out.print("LF_TYPESERVER "); break; | |
197 case LF_SKIP: System.out.print("LF_SKIP "); break; | |
198 case LF_ARGLIST: System.out.print("LF_ARGLIST "); break; | |
199 case LF_DEFARG: System.out.print("LF_DEFARG "); break; | |
200 case LF_FIELDLIST: System.out.print("LF_FIELDLIST "); break; | |
201 case LF_DERIVED: System.out.print("LF_DERIVED "); break; | |
202 case LF_BITFIELD: System.out.print("LF_BITFIELD "); break; | |
203 case LF_METHODLIST: System.out.print("LF_METHODLIST "); break; | |
204 case LF_DIMCONU: System.out.print("LF_DIMCONU "); break; | |
205 case LF_DIMCONLU: System.out.print("LF_DIMCONLU "); break; | |
206 case LF_DIMVARU: System.out.print("LF_DIMVARU "); break; | |
207 case LF_DIMVARLU: System.out.print("LF_DIMVARLU "); break; | |
208 case LF_REFSYM: System.out.print("LF_REFSYM "); break; | |
209 case LF_BCLASS: System.out.print("LF_BCLASS "); break; | |
210 case LF_VBCLASS: System.out.print("LF_VBCLASS "); break; | |
211 case LF_IVBCLASS: System.out.print("LF_IVBCLASS "); break; | |
212 case LF_ENUMERATE: System.out.print("LF_ENUMERATE "); break; | |
213 case LF_FRIENDFCN: System.out.print("LF_FRIENDFCN "); break; | |
214 case LF_INDEX: System.out.print("LF_INDEX "); break; | |
215 case LF_MEMBER: System.out.print("LF_MEMBER "); System.out.print(iter.getMemberName() + " "); break; | |
216 case LF_STMEMBER: System.out.print("LF_STMEMBER "); break; | |
217 case LF_METHOD: System.out.print("LF_METHOD "); System.out.print(iter.getMethodName() + " "); break; | |
218 case LF_NESTTYPE: System.out.print("LF_NESTTYPE "); break; | |
219 case LF_VFUNCTAB: System.out.print("LF_VFUNCTAB "); break; | |
220 case LF_FRIENDCLS: System.out.print("LF_FRIENDCLS "); break; | |
221 case LF_ONEMETHOD: System.out.print("LF_ONEMETHOD "); System.out.print(iter.getOneMethodName() + " "); break; | |
222 case LF_VFUNCOFF: System.out.print("LF_VFUNCOFF "); break; | |
223 case LF_NESTTYPEEX: System.out.print("LF_NESTTYPEEX "); break; | |
224 case LF_MEMBERMODIFY: System.out.print("LF_MEMBERMODIFY "); break; | |
225 case LF_CHAR: System.out.print("LF_CHAR "); break; | |
226 case LF_SHORT: System.out.print("LF_SHORT "); break; | |
227 case LF_USHORT: System.out.print("LF_USHORT "); break; | |
228 case LF_LONG: System.out.print("LF_LONG "); break; | |
229 case LF_ULONG: System.out.print("LF_ULONG "); break; | |
230 case LF_REAL32: System.out.print("LF_REAL32 "); break; | |
231 case LF_REAL64: System.out.print("LF_REAL64 "); break; | |
232 case LF_REAL80: System.out.print("LF_REAL80 "); break; | |
233 case LF_REAL128: System.out.print("LF_REAL128 "); break; | |
234 case LF_QUADWORD: System.out.print("LF_QUADWORD "); break; | |
235 case LF_UQUADWORD: System.out.print("LF_UQUADWORD "); break; | |
236 case LF_REAL48: System.out.print("LF_REAL48 "); break; | |
237 case LF_COMPLEX32: System.out.print("LF_COMPLEX32 "); break; | |
238 case LF_COMPLEX64: System.out.print("LF_COMPLEX64 "); break; | |
239 case LF_COMPLEX80: System.out.print("LF_COMPLEX80 "); break; | |
240 case LF_COMPLEX128: System.out.print("LF_COMPLEX128 "); break; | |
241 case LF_VARSTRING: System.out.print("LF_VARSTRING "); break; | |
242 case LF_PAD0: System.out.print("LF_PAD0 "); break; | |
243 case LF_PAD1: System.out.print("LF_PAD1 "); break; | |
244 case LF_PAD2: System.out.print("LF_PAD2 "); break; | |
245 case LF_PAD3: System.out.print("LF_PAD3 "); break; | |
246 case LF_PAD4: System.out.print("LF_PAD4 "); break; | |
247 case LF_PAD5: System.out.print("LF_PAD5 "); break; | |
248 case LF_PAD6: System.out.print("LF_PAD6 "); break; | |
249 case LF_PAD7: System.out.print("LF_PAD7 "); break; | |
250 case LF_PAD8: System.out.print("LF_PAD8 "); break; | |
251 case LF_PAD9: System.out.print("LF_PAD9 "); break; | |
252 case LF_PAD10: System.out.print("LF_PAD10 "); break; | |
253 case LF_PAD11: System.out.print("LF_PAD11 "); break; | |
254 case LF_PAD12: System.out.print("LF_PAD12 "); break; | |
255 case LF_PAD13: System.out.print("LF_PAD13 "); break; | |
256 case LF_PAD14: System.out.print("LF_PAD14 "); break; | |
257 case LF_PAD15: System.out.print("LF_PAD15 "); break; | |
258 default: System.out.print("(Unknown leaf " + leaf + ")"); | |
259 } | |
260 | |
261 iter.typeStringNext(); | |
262 } | |
263 | |
264 System.out.println(""); | |
265 iter.next(); | |
266 } | |
267 } | |
268 } |