annotate src/share/vm/compiler/disassembler.cpp @ 20804:7848fc12602b

Merge with jdk8u40-b25
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Tue, 07 Apr 2015 14:58:49 +0200
parents 52b4284cb496 094cbdffa87d
children 1621af5cb444
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
1 /*
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 14223
diff changeset
2 * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
4 *
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
7 * published by the Free Software Foundation.
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
8 *
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
13 * accompanied this code).
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
14 *
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1155
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1155
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: 1155
diff changeset
21 * questions.
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
22 *
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
23 */
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
26 #include "classfile/javaClasses.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
27 #include "code/codeCache.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
28 #include "compiler/disassembler.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
29 #include "gc_interface/collectedHeap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
30 #include "memory/cardTableModRefBS.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
31 #include "runtime/fprofiler.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
32 #include "runtime/handles.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
33 #include "runtime/stubCodeGenerator.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
34 #include "runtime/stubRoutines.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
35 #ifdef TARGET_ARCH_x86
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
36 # include "depChecker_x86.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
37 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
38 #ifdef TARGET_ARCH_sparc
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
39 # include "depChecker_sparc.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
40 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
41 #ifdef TARGET_ARCH_zero
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
42 # include "depChecker_zero.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
43 #endif
2192
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2014
diff changeset
44 #ifdef TARGET_ARCH_arm
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2014
diff changeset
45 # include "depChecker_arm.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2014
diff changeset
46 #endif
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2014
diff changeset
47 #ifdef TARGET_ARCH_ppc
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2014
diff changeset
48 # include "depChecker_ppc.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2014
diff changeset
49 #endif
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
50 #ifdef SHARK
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
51 #include "shark/sharkEntry.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
52 #endif
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
53
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 14223
diff changeset
54 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 14223
diff changeset
55
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
56 void* Disassembler::_library = NULL;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
57 bool Disassembler::_tried_to_load_library = false;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
58
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
59 // This routine is in the shared library:
6933
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
60 Disassembler::decode_func_virtual Disassembler::_decode_instructions_virtual = NULL;
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
61 Disassembler::decode_func Disassembler::_decode_instructions = NULL;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
62
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
63 static const char hsdis_library_name[] = "hsdis-"HOTSPOT_LIB_ARCH;
6933
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
64 static const char decode_instructions_virtual_name[] = "decode_instructions_virtual";
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
65 static const char decode_instructions_name[] = "decode_instructions";
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
66 static bool use_new_version = true;
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
67 #define COMMENT_COLUMN 40 LP64_ONLY(+8) /*could be an option*/
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
68 #define BYTES_COMMENT ";..." /* funky byte display comment */
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
69
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
70 bool Disassembler::load_library() {
6933
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
71 if (_decode_instructions_virtual != NULL || _decode_instructions != NULL) {
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
72 // Already succeeded.
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
73 return true;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
74 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
75 if (_tried_to_load_library) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
76 // Do not try twice.
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
77 // To force retry in debugger: assign _tried_to_load_library=0
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
78 return false;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
79 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
80 // Try to load it.
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
81 char ebuf[1024];
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
82 char buf[JVM_MAXPATHLEN];
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
83 os::jvm_path(buf, sizeof(buf));
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
84 int jvm_offset = -1;
3794
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
85 int lib_offset = -1;
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
86 {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
87 // Match "jvm[^/]*" in jvm_path.
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
88 const char* base = buf;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
89 const char* p = strrchr(buf, '/');
3794
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
90 if (p != NULL) lib_offset = p - base + 1;
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
91 p = strstr(p ? p : base, "jvm");
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
92 if (p != NULL) jvm_offset = p - base;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
93 }
3794
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
94 // Find the disassembler shared library.
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
95 // Search for several paths derived from libjvm, in this order:
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
96 // 1. <home>/jre/lib/<arch>/<vm>/libhsdis-<arch>.so (for compatibility)
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
97 // 2. <home>/jre/lib/<arch>/<vm>/hsdis-<arch>.so
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
98 // 3. <home>/jre/lib/<arch>/hsdis-<arch>.so
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
99 // 4. hsdis-<arch>.so (using LD_LIBRARY_PATH)
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
100 if (jvm_offset >= 0) {
3794
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
101 // 1. <home>/jre/lib/<arch>/<vm>/libhsdis-<arch>.so
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
102 strcpy(&buf[jvm_offset], hsdis_library_name);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
103 strcat(&buf[jvm_offset], os::dll_file_extension());
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
104 _library = os::dll_load(buf, ebuf, sizeof ebuf);
3794
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
105 if (_library == NULL) {
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
106 // 2. <home>/jre/lib/<arch>/<vm>/hsdis-<arch>.so
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
107 strcpy(&buf[lib_offset], hsdis_library_name);
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
108 strcat(&buf[lib_offset], os::dll_file_extension());
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
109 _library = os::dll_load(buf, ebuf, sizeof ebuf);
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
110 }
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
111 if (_library == NULL) {
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
112 // 3. <home>/jre/lib/<arch>/hsdis-<arch>.so
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
113 buf[lib_offset - 1] = '\0';
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
114 const char* p = strrchr(buf, '/');
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
115 if (p != NULL) {
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
116 lib_offset = p - buf + 1;
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
117 strcpy(&buf[lib_offset], hsdis_library_name);
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
118 strcat(&buf[lib_offset], os::dll_file_extension());
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
119 _library = os::dll_load(buf, ebuf, sizeof ebuf);
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
120 }
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
121 }
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
122 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
123 if (_library == NULL) {
3794
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
124 // 4. hsdis-<arch>.so (using LD_LIBRARY_PATH)
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
125 strcpy(&buf[0], hsdis_library_name);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
126 strcat(&buf[0], os::dll_file_extension());
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
127 _library = os::dll_load(buf, ebuf, sizeof ebuf);
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
128 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
129 if (_library != NULL) {
6933
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
130 _decode_instructions_virtual = CAST_TO_FN_PTR(Disassembler::decode_func_virtual,
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
131 os::dll_lookup(_library, decode_instructions_virtual_name));
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
132 }
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
133 if (_decode_instructions_virtual == NULL) {
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
134 // could not spot in new version, try old version
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
135 _decode_instructions = CAST_TO_FN_PTR(Disassembler::decode_func,
1980
828eafbd85cc 6348631: remove the use of the HPI library from Hotspot
ikrylov
parents: 1972
diff changeset
136 os::dll_lookup(_library, decode_instructions_name));
6933
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
137 use_new_version = false;
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
138 } else {
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
139 use_new_version = true;
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
140 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
141 _tried_to_load_library = true;
6933
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
142 if (_decode_instructions_virtual == NULL && _decode_instructions == NULL) {
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
143 tty->print_cr("Could not load %s; %s; %s", buf,
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
144 ((_library != NULL)
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
145 ? "entry point is missing"
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
146 : (WizardMode || PrintMiscellaneous)
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
147 ? (const char*)ebuf
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
148 : "library not loadable"),
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
149 "PrintAssembly is disabled");
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
150 return false;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
151 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
152
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
153 // Success.
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
154 tty->print_cr("Loaded disassembler from %s", buf);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
155 return true;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
156 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
157
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
158
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
159 class decode_env {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
160 private:
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
161 nmethod* _nm;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
162 CodeBlob* _code;
8767
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 6983
diff changeset
163 CodeStrings _strings;
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
164 outputStream* _output;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
165 address _start, _end;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
166
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
167 char _option_buf[512];
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
168 char _print_raw;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
169 bool _print_pc;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
170 bool _print_bytes;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
171 address _cur_insn;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
172 int _total_ticks;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
173 int _bytes_per_line; // arch-specific formatting option
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
174
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
175 static bool match(const char* event, const char* tag) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
176 size_t taglen = strlen(tag);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
177 if (strncmp(event, tag, taglen) != 0)
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
178 return false;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
179 char delim = event[taglen];
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
180 return delim == '\0' || delim == ' ' || delim == '/' || delim == '=';
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
181 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
182
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
183 void collect_options(const char* p) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
184 if (p == NULL || p[0] == '\0') return;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
185 size_t opt_so_far = strlen(_option_buf);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
186 if (opt_so_far + 1 + strlen(p) + 1 > sizeof(_option_buf)) return;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
187 char* fillp = &_option_buf[opt_so_far];
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
188 if (opt_so_far > 0) *fillp++ = ',';
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
189 strcat(fillp, p);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
190 // replace white space by commas:
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
191 char* q = fillp;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
192 while ((q = strpbrk(q, " \t\n")) != NULL)
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
193 *q++ = ',';
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
194 // Note that multiple PrintAssemblyOptions flags accumulate with \n,
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
195 // which we want to be changed to a comma...
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
196 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
197
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
198 void print_insn_labels();
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
199 void print_insn_bytes(address pc0, address pc);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
200 void print_address(address value);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
201
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
202 public:
8767
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 6983
diff changeset
203 decode_env(CodeBlob* code, outputStream* output, CodeStrings c = CodeStrings());
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
204
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
205 address decode_instructions(address start, address end);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
206
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
207 void start_insn(address pc) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
208 _cur_insn = pc;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
209 output()->bol();
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
210 print_insn_labels();
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
211 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
212
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
213 void end_insn(address pc) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
214 address pc0 = cur_insn();
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
215 outputStream* st = output();
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
216 if (_print_bytes && pc > pc0)
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
217 print_insn_bytes(pc0, pc);
1155
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 100
diff changeset
218 if (_nm != NULL) {
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
219 _nm->print_code_comment_on(st, COMMENT_COLUMN, pc0, pc);
1155
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 100
diff changeset
220 // this calls reloc_string_for which calls oop::print_value_on
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 100
diff changeset
221 }
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
222
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
223 // Output pc bucket ticks if we have any
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
224 if (total_ticks() != 0) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
225 address bucket_pc = FlatProfiler::bucket_start_for(pc);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
226 if (bucket_pc != NULL && bucket_pc > pc0 && bucket_pc <= pc) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
227 int bucket_count = FlatProfiler::bucket_count_for(pc0);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
228 if (bucket_count != 0) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
229 st->bol();
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
230 st->print_cr("%3.1f%% [%d]", bucket_count*100.0/total_ticks(), bucket_count);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
231 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
232 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
233 }
6782
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 3794
diff changeset
234 // follow each complete insn by a nice newline
5a98bf7d847b 6879063: SA should use hsdis for disassembly
minqi
parents: 3794
diff changeset
235 st->cr();
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
236 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
237
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
238 address handle_event(const char* event, address arg);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
239
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
240 outputStream* output() { return _output; }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
241 address cur_insn() { return _cur_insn; }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
242 int total_ticks() { return _total_ticks; }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
243 void set_total_ticks(int n) { _total_ticks = n; }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
244 const char* options() { return _option_buf; }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
245 };
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
246
8767
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 6983
diff changeset
247 decode_env::decode_env(CodeBlob* code, outputStream* output, CodeStrings c) {
20435
094cbdffa87d 8054292: code comments leak in fastdebug builds
drchase
parents: 17937
diff changeset
248 memset(this, 0, sizeof(*this)); // Beware, this zeroes bits of fields.
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
249 _output = output ? output : tty;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
250 _code = code;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
251 if (code != NULL && code->is_nmethod())
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
252 _nm = (nmethod*) code;
20435
094cbdffa87d 8054292: code comments leak in fastdebug builds
drchase
parents: 17937
diff changeset
253 _strings.copy(c);
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
254
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
255 // by default, output pc but not bytes:
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
256 _print_pc = true;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
257 _print_bytes = false;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
258 _bytes_per_line = Disassembler::pd_instruction_alignment();
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
259
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
260 // parse the global option string:
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
261 collect_options(Disassembler::pd_cpu_opts());
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
262 collect_options(PrintAssemblyOptions);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
263
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
264 if (strstr(options(), "hsdis-")) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
265 if (strstr(options(), "hsdis-print-raw"))
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
266 _print_raw = (strstr(options(), "xml") ? 2 : 1);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
267 if (strstr(options(), "hsdis-print-pc"))
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
268 _print_pc = !_print_pc;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
269 if (strstr(options(), "hsdis-print-bytes"))
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
270 _print_bytes = !_print_bytes;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
271 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
272 if (strstr(options(), "help")) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
273 tty->print_cr("PrintAssemblyOptions help:");
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
274 tty->print_cr(" hsdis-print-raw test plugin by requesting raw output");
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
275 tty->print_cr(" hsdis-print-raw-xml test plugin by requesting raw xml");
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
276 tty->print_cr(" hsdis-print-pc turn off PC printing (on by default)");
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
277 tty->print_cr(" hsdis-print-bytes turn on instruction byte output");
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
278 tty->print_cr("combined options: %s", options());
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
279 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
280 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
281
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
282 address decode_env::handle_event(const char* event, address arg) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
283 if (match(event, "insn")) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
284 start_insn(arg);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
285 } else if (match(event, "/insn")) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
286 end_insn(arg);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
287 } else if (match(event, "addr")) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
288 if (arg != NULL) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
289 print_address(arg);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
290 return arg;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
291 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
292 } else if (match(event, "mach")) {
3794
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
293 static char buffer[32] = { 0, };
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
294 if (strcmp(buffer, (const char*)arg) != 0 ||
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
295 strlen((const char*)arg) > sizeof(buffer) - 1) {
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
296 // Only print this when the mach changes
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
297 strncpy(buffer, (const char*)arg, sizeof(buffer) - 1);
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
298 output()->print_cr("[Disassembling for mach='%s']", arg);
3e23978ea0c3 7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents: 3363
diff changeset
299 }
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
300 } else if (match(event, "format bytes-per-line")) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
301 _bytes_per_line = (int) (intptr_t) arg;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
302 } else {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
303 // ignore unrecognized markup
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
304 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
305 return NULL;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
306 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
307
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
308 // called by the disassembler to print out jump targets and data addresses
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
309 void decode_env::print_address(address adr) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
310 outputStream* st = _output;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
311
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
312 if (adr == NULL) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
313 st->print("NULL");
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
314 return;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
315 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
316
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
317 int small_num = (int)(intptr_t)adr;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
318 if ((intptr_t)adr == (intptr_t)small_num
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
319 && -1 <= small_num && small_num <= 9) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
320 st->print("%d", small_num);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
321 return;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
322 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
323
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
324 if (Universe::is_fully_initialized()) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
325 if (StubRoutines::contains(adr)) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
326 StubCodeDesc* desc = StubCodeDesc::desc_for(adr);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
327 if (desc == NULL)
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
328 desc = StubCodeDesc::desc_for(adr + frame::pc_return_offset);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
329 if (desc != NULL) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
330 st->print("Stub::%s", desc->name());
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
331 if (desc->begin() != adr)
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
332 st->print("%+d 0x%p",adr - desc->begin(), adr);
3363
167b70ff3abc 6939861: JVM should handle more conversion operations
never
parents: 2426
diff changeset
333 else if (WizardMode) st->print(" " PTR_FORMAT, adr);
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
334 return;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
335 }
3363
167b70ff3abc 6939861: JVM should handle more conversion operations
never
parents: 2426
diff changeset
336 st->print("Stub::<unknown> " PTR_FORMAT, adr);
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
337 return;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
338 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
339
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
340 BarrierSet* bs = Universe::heap()->barrier_set();
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
341 if (bs->kind() == BarrierSet::CardTableModRef &&
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
342 adr == (address)((CardTableModRefBS*)(bs))->byte_map_base) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
343 st->print("word_map_base");
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
344 if (WizardMode) st->print(" " INTPTR_FORMAT, (intptr_t)adr);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
345 return;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
346 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
347
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
348 oop obj;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
349 if (_nm != NULL
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
350 && (obj = _nm->embeddedOop_at(cur_insn())) != NULL
1155
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 100
diff changeset
351 && (address) obj == adr
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 100
diff changeset
352 && Universe::heap()->is_in(obj)
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 100
diff changeset
353 && Universe::heap()->is_in(obj->klass())) {
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 100
diff changeset
354 julong c = st->count();
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
355 obj->print_value_on(st);
1155
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 100
diff changeset
356 if (st->count() == c) {
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 100
diff changeset
357 // No output. (Can happen in product builds.)
6983
070d523b96a7 8001471: Klass::cast() does nothing
hseigel
parents: 6933
diff changeset
358 st->print("(a %s)", obj->klass()->external_name());
1155
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 100
diff changeset
359 }
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
360 return;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
361 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
362 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
363
3363
167b70ff3abc 6939861: JVM should handle more conversion operations
never
parents: 2426
diff changeset
364 // Fall through to a simple (hexadecimal) numeral.
167b70ff3abc 6939861: JVM should handle more conversion operations
never
parents: 2426
diff changeset
365 st->print(PTR_FORMAT, adr);
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
366 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
367
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
368 void decode_env::print_insn_labels() {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
369 address p = cur_insn();
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
370 outputStream* st = output();
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
371 CodeBlob* cb = _code;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
372 if (cb != NULL) {
1155
4e6abf09f540 6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents: 100
diff changeset
373 cb->print_block_comment(st, p);
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
374 }
8767
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 6983
diff changeset
375 _strings.print_block_comment(st, (intptr_t)(p - _start));
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
376 if (_print_pc) {
3363
167b70ff3abc 6939861: JVM should handle more conversion operations
never
parents: 2426
diff changeset
377 st->print(" " PTR_FORMAT ": ", p);
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
378 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
379 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
380
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
381 void decode_env::print_insn_bytes(address pc, address pc_limit) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
382 outputStream* st = output();
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
383 size_t incr = 1;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
384 size_t perline = _bytes_per_line;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
385 if ((size_t) Disassembler::pd_instruction_alignment() >= sizeof(int)
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
386 && !((uintptr_t)pc % sizeof(int))
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
387 && !((uintptr_t)pc_limit % sizeof(int))) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
388 incr = sizeof(int);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
389 if (perline % incr) perline += incr - (perline % incr);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
390 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
391 while (pc < pc_limit) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
392 // tab to the desired column:
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
393 st->move_to(COMMENT_COLUMN);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
394 address pc0 = pc;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
395 address pc1 = pc + perline;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
396 if (pc1 > pc_limit) pc1 = pc_limit;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
397 for (; pc < pc1; pc += incr) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
398 if (pc == pc0)
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
399 st->print(BYTES_COMMENT);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
400 else if ((uint)(pc - pc0) % sizeof(int) == 0)
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
401 st->print(" "); // put out a space on word boundaries
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
402 if (incr == sizeof(int))
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
403 st->print("%08lx", *(int*)pc);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
404 else st->print("%02x", (*pc)&0xFF);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
405 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
406 st->cr();
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
407 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
408 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
409
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
410
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
411 static void* event_to_env(void* env_pv, const char* event, void* arg) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
412 decode_env* env = (decode_env*) env_pv;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
413 return env->handle_event(event, (address) arg);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
414 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
415
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 14223
diff changeset
416 ATTRIBUTE_PRINTF(2, 3)
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
417 static int printf_to_env(void* env_pv, const char* format, ...) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
418 decode_env* env = (decode_env*) env_pv;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
419 outputStream* st = env->output();
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
420 size_t flen = strlen(format);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
421 const char* raw = NULL;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
422 if (flen == 0) return 0;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
423 if (flen == 1 && format[0] == '\n') { st->bol(); return 1; }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
424 if (flen < 2 ||
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
425 strchr(format, '%') == NULL) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
426 raw = format;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
427 } else if (format[0] == '%' && format[1] == '%' &&
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
428 strchr(format+2, '%') == NULL) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
429 // happens a lot on machines with names like %foo
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
430 flen--;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
431 raw = format+1;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
432 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
433 if (raw != NULL) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
434 st->print_raw(raw, (int) flen);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
435 return (int) flen;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
436 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
437 va_list ap;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
438 va_start(ap, format);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
439 julong cnt0 = st->count();
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
440 st->vprint(format, ap);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
441 julong cnt1 = st->count();
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
442 va_end(ap);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
443 return (int)(cnt1 - cnt0);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
444 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
445
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
446 address decode_env::decode_instructions(address start, address end) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
447 _start = start; _end = end;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
448
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
449 assert(((((intptr_t)start | (intptr_t)end) % Disassembler::pd_instruction_alignment()) == 0), "misaligned insn addr");
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
450
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
451 const int show_bytes = false; // for disassembler debugging
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
452
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
453 //_version = Disassembler::pd_cpu_version();
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
454
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
455 if (!Disassembler::can_decode()) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
456 return NULL;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
457 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
458
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
459 // decode a series of instructions and return the end of the last instruction
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
460
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
461 if (_print_raw) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
462 // Print whatever the library wants to print, w/o fancy callbacks.
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
463 // This is mainly for debugging the library itself.
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
464 FILE* out = stdout;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
465 FILE* xmlout = (_print_raw > 1 ? out : NULL);
6933
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
466 return use_new_version ?
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
467 (address)
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
468 (*Disassembler::_decode_instructions_virtual)((uintptr_t)start, (uintptr_t)end,
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
469 start, end - start,
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
470 NULL, (void*) xmlout,
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
471 NULL, (void*) out,
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
472 options(), 0/*nice new line*/)
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
473 :
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
474 (address)
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
475 (*Disassembler::_decode_instructions)(start, end,
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
476 NULL, (void*) xmlout,
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
477 NULL, (void*) out,
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
478 options());
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
479 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
480
6933
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
481 return use_new_version ?
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
482 (address)
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
483 (*Disassembler::_decode_instructions_virtual)((uintptr_t)start, (uintptr_t)end,
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
484 start, end - start,
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
485 &event_to_env, (void*) this,
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
486 &printf_to_env, (void*) this,
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
487 options(), 0/*nice new line*/)
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
488 :
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
489 (address)
3d701c802d01 8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents: 6806
diff changeset
490 (*Disassembler::_decode_instructions)(start, end,
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
491 &event_to_env, (void*) this,
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
492 &printf_to_env, (void*) this,
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
493 options());
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
494 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
495
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
496
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
497 void Disassembler::decode(CodeBlob* cb, outputStream* st) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
498 if (!load_library()) return;
16719
b1911c1e44c8 Dump disassembly in crash log
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15099
diff changeset
499 if (cb->is_nmethod()) {
b1911c1e44c8 Dump disassembly in crash log
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15099
diff changeset
500 decode((nmethod*)cb, st);
b1911c1e44c8 Dump disassembly in crash log
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15099
diff changeset
501 return;
b1911c1e44c8 Dump disassembly in crash log
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15099
diff changeset
502 }
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
503 decode_env env(cb, st);
14752
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
504 env.output()->print_cr("----------------------------------------------------------------------");
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
505 env.output()->print_cr("%s at [" PTR_FORMAT ", " PTR_FORMAT "] %d bytes", cb->name(), cb->code_begin(), cb->code_end(), ((jlong)(cb->code_end() - cb->code_begin())) * sizeof(unsigned char*));
1748
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1692
diff changeset
506 env.decode_instructions(cb->code_begin(), cb->code_end());
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
507 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
508
8767
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 6983
diff changeset
509 void Disassembler::decode(address start, address end, outputStream* st, CodeStrings c) {
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
510 if (!load_library()) return;
6796
b31471cdc53e 7200163: add CodeComments functionality to assember stubs
kvn
parents: 3794
diff changeset
511 decode_env env(CodeCache::find_blob_unsafe(start), st, c);
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
512 env.decode_instructions(start, end);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
513 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
514
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
515 void Disassembler::decode(nmethod* nm, outputStream* st) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
516 if (!load_library()) return;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
517 decode_env env(nm, st);
14752
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
518 env.output()->print_cr("----------------------------------------------------------------------");
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
519
1692
d2ede61b7a12 6976186: integrate Shark HotSpot changes
twisti
parents: 1681
diff changeset
520 #ifdef SHARK
1748
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1692
diff changeset
521 SharkEntry* entry = (SharkEntry *) nm->code_begin();
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1692
diff changeset
522 unsigned char* p = entry->code_start();
1692
d2ede61b7a12 6976186: integrate Shark HotSpot changes
twisti
parents: 1681
diff changeset
523 unsigned char* end = entry->code_limit();
d2ede61b7a12 6976186: integrate Shark HotSpot changes
twisti
parents: 1681
diff changeset
524 #else
1748
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1692
diff changeset
525 unsigned char* p = nm->code_begin();
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1692
diff changeset
526 unsigned char* end = nm->code_end();
1692
d2ede61b7a12 6976186: integrate Shark HotSpot changes
twisti
parents: 1681
diff changeset
527 #endif // SHARK
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
528
14752
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
529 nm->method()->method_holder()->name()->print_symbol_on(env.output());
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
530 env.output()->print(".");
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
531 nm->method()->name()->print_symbol_on(env.output());
15099
0fab2ac29847 correct size in printed in message
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 14909
diff changeset
532 env.output()->print_cr(" [" PTR_FORMAT ", " PTR_FORMAT "] %d bytes", p, end, ((jlong)(end - p)));
14752
311bf6c7488b revert some changes to match upstream files
twisti
parents: 14518
diff changeset
533
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
534 // If there has been profiling, print the buckets.
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
535 if (FlatProfiler::bucket_start_for(p) != NULL) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
536 unsigned char* p1 = p;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
537 int total_bucket_count = 0;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
538 while (p1 < end) {
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
539 unsigned char* p0 = p1;
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
540 p1 += pd_instruction_alignment();
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
541 address bucket_pc = FlatProfiler::bucket_start_for(p1);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
542 if (bucket_pc != NULL && bucket_pc > p0 && bucket_pc <= p1)
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
543 total_bucket_count += FlatProfiler::bucket_count_for(p0);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
544 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
545 env.set_total_ticks(total_bucket_count);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
546 }
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
547
2008
2f644f85485d 6961690: load oops from constant table on SPARC
twisti
parents: 1972
diff changeset
548 // Print constant table.
2f644f85485d 6961690: load oops from constant table on SPARC
twisti
parents: 1972
diff changeset
549 if (nm->consts_size() > 0) {
2f644f85485d 6961690: load oops from constant table on SPARC
twisti
parents: 1972
diff changeset
550 nm->print_nmethod_labels(env.output(), nm->consts_begin());
2f644f85485d 6961690: load oops from constant table on SPARC
twisti
parents: 1972
diff changeset
551 int offset = 0;
2f644f85485d 6961690: load oops from constant table on SPARC
twisti
parents: 1972
diff changeset
552 for (address p = nm->consts_begin(); p < nm->consts_end(); p += 4, offset += 4) {
2f644f85485d 6961690: load oops from constant table on SPARC
twisti
parents: 1972
diff changeset
553 if ((offset % 8) == 0) {
3363
167b70ff3abc 6939861: JVM should handle more conversion operations
never
parents: 2426
diff changeset
554 env.output()->print_cr(" " PTR_FORMAT " (offset: %4d): " PTR32_FORMAT " " PTR64_FORMAT, p, offset, *((int32_t*) p), *((int64_t*) p));
2008
2f644f85485d 6961690: load oops from constant table on SPARC
twisti
parents: 1972
diff changeset
555 } else {
3363
167b70ff3abc 6939861: JVM should handle more conversion operations
never
parents: 2426
diff changeset
556 env.output()->print_cr(" " PTR_FORMAT " (offset: %4d): " PTR32_FORMAT, p, offset, *((int32_t*) p));
2008
2f644f85485d 6961690: load oops from constant table on SPARC
twisti
parents: 1972
diff changeset
557 }
2f644f85485d 6961690: load oops from constant table on SPARC
twisti
parents: 1972
diff changeset
558 }
2f644f85485d 6961690: load oops from constant table on SPARC
twisti
parents: 1972
diff changeset
559 }
2f644f85485d 6961690: load oops from constant table on SPARC
twisti
parents: 1972
diff changeset
560
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
561 env.decode_instructions(p, end);
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff changeset
562 }