author | zmajo |
Thu, 29 Jan 2015 19:16:47 +0100 | |
changeset 28914 | bee40a1e5cff |
parent 26432 | 9b974e2eae27 |
child 29083 | 5e7bce2712ac |
permissions | -rw-r--r-- |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
1 |
/* |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
22234
diff
changeset
|
2 |
* Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. |
347
df859fcca515
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. |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
4 |
* |
df859fcca515
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 |
df859fcca515
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 |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
8 |
* |
df859fcca515
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 |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
df859fcca515
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 |
df859fcca515
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 |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
13 |
* accompanied this code). |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
14 |
* |
df859fcca515
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 |
df859fcca515
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, |
df859fcca515
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. |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
18 |
* |
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4584
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4584
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4584
diff
changeset
|
21 |
* questions. |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
22 |
* |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
23 |
*/ |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
24 |
|
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "classfile/javaClasses.hpp" |
|
27 |
#include "code/codeCache.hpp" |
|
28 |
#include "compiler/disassembler.hpp" |
|
29 |
#include "gc_interface/collectedHeap.hpp" |
|
30 |
#include "memory/cardTableModRefBS.hpp" |
|
31 |
#include "runtime/fprofiler.hpp" |
|
32 |
#include "runtime/handles.inline.hpp" |
|
25468
5331df506290
8048241: Introduce umbrella header os.inline.hpp and clean up includes
goetz
parents:
24460
diff
changeset
|
33 |
#include "runtime/os.hpp" |
7397 | 34 |
#include "runtime/stubCodeGenerator.hpp" |
35 |
#include "runtime/stubRoutines.hpp" |
|
36 |
#ifdef TARGET_ARCH_x86 |
|
37 |
# include "depChecker_x86.hpp" |
|
38 |
#endif |
|
39 |
#ifdef TARGET_ARCH_sparc |
|
40 |
# include "depChecker_sparc.hpp" |
|
41 |
#endif |
|
42 |
#ifdef TARGET_ARCH_zero |
|
43 |
# include "depChecker_zero.hpp" |
|
44 |
#endif |
|
8107
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7439
diff
changeset
|
45 |
#ifdef TARGET_ARCH_arm |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7439
diff
changeset
|
46 |
# include "depChecker_arm.hpp" |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7439
diff
changeset
|
47 |
#endif |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7439
diff
changeset
|
48 |
#ifdef TARGET_ARCH_ppc |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7439
diff
changeset
|
49 |
# include "depChecker_ppc.hpp" |
78e5bd944384
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
7439
diff
changeset
|
50 |
#endif |
7397 | 51 |
#ifdef SHARK |
52 |
#include "shark/sharkEntry.hpp" |
|
53 |
#endif |
|
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
54 |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
22234
diff
changeset
|
55 |
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
22234
diff
changeset
|
56 |
|
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
57 |
void* Disassembler::_library = NULL; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
58 |
bool Disassembler::_tried_to_load_library = false; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
59 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
60 |
// This routine is in the shared library: |
14384
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
61 |
Disassembler::decode_func_virtual Disassembler::_decode_instructions_virtual = NULL; |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
62 |
Disassembler::decode_func Disassembler::_decode_instructions = NULL; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
63 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
64 |
static const char hsdis_library_name[] = "hsdis-"HOTSPOT_LIB_ARCH; |
14384
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
65 |
static const char decode_instructions_virtual_name[] = "decode_instructions_virtual"; |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
66 |
static const char decode_instructions_name[] = "decode_instructions"; |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
67 |
static bool use_new_version = true; |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
68 |
#define COMMENT_COLUMN 40 LP64_ONLY(+8) /*could be an option*/ |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
69 |
#define BYTES_COMMENT ";..." /* funky byte display comment */ |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
70 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
71 |
bool Disassembler::load_library() { |
14384
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
72 |
if (_decode_instructions_virtual != NULL || _decode_instructions != NULL) { |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
73 |
// Already succeeded. |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
74 |
return true; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
75 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
76 |
if (_tried_to_load_library) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
77 |
// Do not try twice. |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
78 |
// To force retry in debugger: assign _tried_to_load_library=0 |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
79 |
return false; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
80 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
81 |
// Try to load it. |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
82 |
char ebuf[1024]; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
83 |
char buf[JVM_MAXPATHLEN]; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
84 |
os::jvm_path(buf, sizeof(buf)); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
85 |
int jvm_offset = -1; |
10017
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
86 |
int lib_offset = -1; |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
87 |
{ |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
88 |
// Match "jvm[^/]*" in jvm_path. |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
89 |
const char* base = buf; |
24460
ec55671cfdc2
8043264: hsdis library not picked up correctly on expected paths
sspitsyn
parents:
24424
diff
changeset
|
90 |
const char* p = strrchr(buf, *os::file_separator()); |
10017
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
91 |
if (p != NULL) lib_offset = p - base + 1; |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
92 |
p = strstr(p ? p : base, "jvm"); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
93 |
if (p != NULL) jvm_offset = p - base; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
94 |
} |
10017
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
95 |
// Find the disassembler shared library. |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
96 |
// Search for several paths derived from libjvm, in this order: |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
97 |
// 1. <home>/jre/lib/<arch>/<vm>/libhsdis-<arch>.so (for compatibility) |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
98 |
// 2. <home>/jre/lib/<arch>/<vm>/hsdis-<arch>.so |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
99 |
// 3. <home>/jre/lib/<arch>/hsdis-<arch>.so |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
100 |
// 4. hsdis-<arch>.so (using LD_LIBRARY_PATH) |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
101 |
if (jvm_offset >= 0) { |
10017
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
102 |
// 1. <home>/jre/lib/<arch>/<vm>/libhsdis-<arch>.so |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
103 |
strcpy(&buf[jvm_offset], hsdis_library_name); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
104 |
strcat(&buf[jvm_offset], os::dll_file_extension()); |
7405
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
105 |
_library = os::dll_load(buf, ebuf, sizeof ebuf); |
10017
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
106 |
if (_library == NULL) { |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
107 |
// 2. <home>/jre/lib/<arch>/<vm>/hsdis-<arch>.so |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
108 |
strcpy(&buf[lib_offset], hsdis_library_name); |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
109 |
strcat(&buf[lib_offset], os::dll_file_extension()); |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
110 |
_library = os::dll_load(buf, ebuf, sizeof ebuf); |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
111 |
} |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
112 |
if (_library == NULL) { |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
113 |
// 3. <home>/jre/lib/<arch>/hsdis-<arch>.so |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
114 |
buf[lib_offset - 1] = '\0'; |
24460
ec55671cfdc2
8043264: hsdis library not picked up correctly on expected paths
sspitsyn
parents:
24424
diff
changeset
|
115 |
const char* p = strrchr(buf, *os::file_separator()); |
10017
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
116 |
if (p != NULL) { |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
117 |
lib_offset = p - buf + 1; |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
118 |
strcpy(&buf[lib_offset], hsdis_library_name); |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
119 |
strcat(&buf[lib_offset], os::dll_file_extension()); |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
120 |
_library = os::dll_load(buf, ebuf, sizeof ebuf); |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
121 |
} |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
122 |
} |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
123 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
124 |
if (_library == NULL) { |
10017
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
125 |
// 4. hsdis-<arch>.so (using LD_LIBRARY_PATH) |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
126 |
strcpy(&buf[0], hsdis_library_name); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
127 |
strcat(&buf[0], os::dll_file_extension()); |
7405
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
128 |
_library = os::dll_load(buf, ebuf, sizeof ebuf); |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
129 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
130 |
if (_library != NULL) { |
14384
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
131 |
_decode_instructions_virtual = CAST_TO_FN_PTR(Disassembler::decode_func_virtual, |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
132 |
os::dll_lookup(_library, decode_instructions_virtual_name)); |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
133 |
} |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
134 |
if (_decode_instructions_virtual == NULL) { |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
135 |
// could not spot in new version, try old version |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
136 |
_decode_instructions = CAST_TO_FN_PTR(Disassembler::decode_func, |
7405
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
137 |
os::dll_lookup(_library, decode_instructions_name)); |
14384
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
138 |
use_new_version = false; |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
139 |
} else { |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
140 |
use_new_version = true; |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
141 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
142 |
_tried_to_load_library = true; |
14384
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
143 |
if (_decode_instructions_virtual == NULL && _decode_instructions == NULL) { |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
144 |
tty->print_cr("Could not load %s; %s; %s", buf, |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
145 |
((_library != NULL) |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
146 |
? "entry point is missing" |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
147 |
: (WizardMode || PrintMiscellaneous) |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
148 |
? (const char*)ebuf |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
149 |
: "library not loadable"), |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
150 |
"PrintAssembly is disabled"); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
151 |
return false; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
152 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
153 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
154 |
// Success. |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
155 |
tty->print_cr("Loaded disassembler from %s", buf); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
156 |
return true; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
157 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
158 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
159 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
160 |
class decode_env { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
161 |
private: |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
162 |
nmethod* _nm; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
163 |
CodeBlob* _code; |
16368
713209c45a82
8008555: Debugging code in compiled method sometimes leaks memory
roland
parents:
14488
diff
changeset
|
164 |
CodeStrings _strings; |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
165 |
outputStream* _output; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
166 |
address _start, _end; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
167 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
168 |
char _option_buf[512]; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
169 |
char _print_raw; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
170 |
bool _print_pc; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
171 |
bool _print_bytes; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
172 |
address _cur_insn; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
173 |
int _total_ticks; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
174 |
int _bytes_per_line; // arch-specific formatting option |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
175 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
176 |
static bool match(const char* event, const char* tag) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
177 |
size_t taglen = strlen(tag); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
178 |
if (strncmp(event, tag, taglen) != 0) |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
179 |
return false; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
180 |
char delim = event[taglen]; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
181 |
return delim == '\0' || delim == ' ' || delim == '/' || delim == '='; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
182 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
183 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
184 |
void collect_options(const char* p) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
185 |
if (p == NULL || p[0] == '\0') return; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
186 |
size_t opt_so_far = strlen(_option_buf); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
187 |
if (opt_so_far + 1 + strlen(p) + 1 > sizeof(_option_buf)) return; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
188 |
char* fillp = &_option_buf[opt_so_far]; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
189 |
if (opt_so_far > 0) *fillp++ = ','; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
190 |
strcat(fillp, p); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
191 |
// replace white space by commas: |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
192 |
char* q = fillp; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
193 |
while ((q = strpbrk(q, " \t\n")) != NULL) |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
194 |
*q++ = ','; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
195 |
// Note that multiple PrintAssemblyOptions flags accumulate with \n, |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
196 |
// which we want to be changed to a comma... |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
197 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
198 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
199 |
void print_insn_labels(); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
200 |
void print_insn_bytes(address pc0, address pc); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
201 |
void print_address(address value); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
202 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
203 |
public: |
16368
713209c45a82
8008555: Debugging code in compiled method sometimes leaks memory
roland
parents:
14488
diff
changeset
|
204 |
decode_env(CodeBlob* code, outputStream* output, CodeStrings c = CodeStrings()); |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
205 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
206 |
address decode_instructions(address start, address end); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
207 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
208 |
void start_insn(address pc) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
209 |
_cur_insn = pc; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
210 |
output()->bol(); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
211 |
print_insn_labels(); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
212 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
213 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
214 |
void end_insn(address pc) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
215 |
address pc0 = cur_insn(); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
216 |
outputStream* st = output(); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
217 |
if (_print_bytes && pc > pc0) |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
218 |
print_insn_bytes(pc0, pc); |
4584
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
347
diff
changeset
|
219 |
if (_nm != NULL) { |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
220 |
_nm->print_code_comment_on(st, COMMENT_COLUMN, pc0, pc); |
4584
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
347
diff
changeset
|
221 |
// this calls reloc_string_for which calls oop::print_value_on |
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
347
diff
changeset
|
222 |
} |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
223 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
224 |
// Output pc bucket ticks if we have any |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
225 |
if (total_ticks() != 0) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
226 |
address bucket_pc = FlatProfiler::bucket_start_for(pc); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
227 |
if (bucket_pc != NULL && bucket_pc > pc0 && bucket_pc <= pc) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
228 |
int bucket_count = FlatProfiler::bucket_count_for(pc0); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
229 |
if (bucket_count != 0) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
230 |
st->bol(); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
231 |
st->print_cr("%3.1f%% [%d]", bucket_count*100.0/total_ticks(), bucket_count); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
232 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
233 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
234 |
} |
13873 | 235 |
// follow each complete insn by a nice newline |
236 |
st->cr(); |
|
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
237 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
238 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
239 |
address handle_event(const char* event, address arg); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
240 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
241 |
outputStream* output() { return _output; } |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
242 |
address cur_insn() { return _cur_insn; } |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
243 |
int total_ticks() { return _total_ticks; } |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
244 |
void set_total_ticks(int n) { _total_ticks = n; } |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
245 |
const char* options() { return _option_buf; } |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
246 |
}; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
247 |
|
16368
713209c45a82
8008555: Debugging code in compiled method sometimes leaks memory
roland
parents:
14488
diff
changeset
|
248 |
decode_env::decode_env(CodeBlob* code, outputStream* output, CodeStrings c) { |
26432 | 249 |
memset(this, 0, sizeof(*this)); // Beware, this zeroes bits of fields. |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
250 |
_output = output ? output : tty; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
251 |
_code = code; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
252 |
if (code != NULL && code->is_nmethod()) |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
253 |
_nm = (nmethod*) code; |
26432 | 254 |
_strings.copy(c); |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
255 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
256 |
// by default, output pc but not bytes: |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
257 |
_print_pc = true; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
258 |
_print_bytes = false; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
259 |
_bytes_per_line = Disassembler::pd_instruction_alignment(); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
260 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
261 |
// parse the global option string: |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
262 |
collect_options(Disassembler::pd_cpu_opts()); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
263 |
collect_options(PrintAssemblyOptions); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
264 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
265 |
if (strstr(options(), "hsdis-")) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
266 |
if (strstr(options(), "hsdis-print-raw")) |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
267 |
_print_raw = (strstr(options(), "xml") ? 2 : 1); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
268 |
if (strstr(options(), "hsdis-print-pc")) |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
269 |
_print_pc = !_print_pc; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
270 |
if (strstr(options(), "hsdis-print-bytes")) |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
271 |
_print_bytes = !_print_bytes; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
272 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
273 |
if (strstr(options(), "help")) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
274 |
tty->print_cr("PrintAssemblyOptions help:"); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
275 |
tty->print_cr(" hsdis-print-raw test plugin by requesting raw output"); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
276 |
tty->print_cr(" hsdis-print-raw-xml test plugin by requesting raw xml"); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
277 |
tty->print_cr(" hsdis-print-pc turn off PC printing (on by default)"); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
278 |
tty->print_cr(" hsdis-print-bytes turn on instruction byte output"); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
279 |
tty->print_cr("combined options: %s", options()); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
280 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
281 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
282 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
283 |
address decode_env::handle_event(const char* event, address arg) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
284 |
if (match(event, "insn")) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
285 |
start_insn(arg); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
286 |
} else if (match(event, "/insn")) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
287 |
end_insn(arg); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
288 |
} else if (match(event, "addr")) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
289 |
if (arg != NULL) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
290 |
print_address(arg); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
291 |
return arg; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
292 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
293 |
} else if (match(event, "mach")) { |
10017
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
294 |
static char buffer[32] = { 0, }; |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
295 |
if (strcmp(buffer, (const char*)arg) != 0 || |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
296 |
strlen((const char*)arg) > sizeof(buffer) - 1) { |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
297 |
// Only print this when the mach changes |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
298 |
strncpy(buffer, (const char*)arg, sizeof(buffer) - 1); |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
299 |
output()->print_cr("[Disassembling for mach='%s']", arg); |
34ddce3361b7
7062856: Disassembler needs to be smarter about finding hsdis after 1.7 launcher changes
never
parents:
9630
diff
changeset
|
300 |
} |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
301 |
} else if (match(event, "format bytes-per-line")) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
302 |
_bytes_per_line = (int) (intptr_t) arg; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
303 |
} else { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
304 |
// ignore unrecognized markup |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
305 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
306 |
return NULL; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
307 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
308 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
309 |
// called by the disassembler to print out jump targets and data addresses |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
310 |
void decode_env::print_address(address adr) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
311 |
outputStream* st = _output; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
312 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
313 |
if (adr == NULL) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
314 |
st->print("NULL"); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
315 |
return; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
316 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
317 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
318 |
int small_num = (int)(intptr_t)adr; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
319 |
if ((intptr_t)adr == (intptr_t)small_num |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
320 |
&& -1 <= small_num && small_num <= 9) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
321 |
st->print("%d", small_num); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
322 |
return; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
323 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
324 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
325 |
if (Universe::is_fully_initialized()) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
326 |
if (StubRoutines::contains(adr)) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
327 |
StubCodeDesc* desc = StubCodeDesc::desc_for(adr); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
328 |
if (desc == NULL) |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
329 |
desc = StubCodeDesc::desc_for(adr + frame::pc_return_offset); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
330 |
if (desc != NULL) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
331 |
st->print("Stub::%s", desc->name()); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
332 |
if (desc->begin() != adr) |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
333 |
st->print("%+d 0x%p",adr - desc->begin(), adr); |
9630
d6419e4395e3
6939861: JVM should handle more conversion operations
never
parents:
8921
diff
changeset
|
334 |
else if (WizardMode) st->print(" " PTR_FORMAT, adr); |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
335 |
return; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
336 |
} |
9630
d6419e4395e3
6939861: JVM should handle more conversion operations
never
parents:
8921
diff
changeset
|
337 |
st->print("Stub::<unknown> " PTR_FORMAT, adr); |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
338 |
return; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
339 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
340 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
341 |
BarrierSet* bs = Universe::heap()->barrier_set(); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
342 |
if (bs->kind() == BarrierSet::CardTableModRef && |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
343 |
adr == (address)((CardTableModRefBS*)(bs))->byte_map_base) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
344 |
st->print("word_map_base"); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
345 |
if (WizardMode) st->print(" " INTPTR_FORMAT, (intptr_t)adr); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
346 |
return; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
347 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
348 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
349 |
|
9630
d6419e4395e3
6939861: JVM should handle more conversion operations
never
parents:
8921
diff
changeset
|
350 |
// Fall through to a simple (hexadecimal) numeral. |
d6419e4395e3
6939861: JVM should handle more conversion operations
never
parents:
8921
diff
changeset
|
351 |
st->print(PTR_FORMAT, adr); |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
352 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
353 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
354 |
void decode_env::print_insn_labels() { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
355 |
address p = cur_insn(); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
356 |
outputStream* st = output(); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
357 |
CodeBlob* cb = _code; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
358 |
if (cb != NULL) { |
4584
e2a449e8cc6f
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
347
diff
changeset
|
359 |
cb->print_block_comment(st, p); |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
360 |
} |
16368
713209c45a82
8008555: Debugging code in compiled method sometimes leaks memory
roland
parents:
14488
diff
changeset
|
361 |
_strings.print_block_comment(st, (intptr_t)(p - _start)); |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
362 |
if (_print_pc) { |
9630
d6419e4395e3
6939861: JVM should handle more conversion operations
never
parents:
8921
diff
changeset
|
363 |
st->print(" " PTR_FORMAT ": ", p); |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
364 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
365 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
366 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
367 |
void decode_env::print_insn_bytes(address pc, address pc_limit) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
368 |
outputStream* st = output(); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
369 |
size_t incr = 1; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
370 |
size_t perline = _bytes_per_line; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
371 |
if ((size_t) Disassembler::pd_instruction_alignment() >= sizeof(int) |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
372 |
&& !((uintptr_t)pc % sizeof(int)) |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
373 |
&& !((uintptr_t)pc_limit % sizeof(int))) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
374 |
incr = sizeof(int); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
375 |
if (perline % incr) perline += incr - (perline % incr); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
376 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
377 |
while (pc < pc_limit) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
378 |
// tab to the desired column: |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
379 |
st->move_to(COMMENT_COLUMN); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
380 |
address pc0 = pc; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
381 |
address pc1 = pc + perline; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
382 |
if (pc1 > pc_limit) pc1 = pc_limit; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
383 |
for (; pc < pc1; pc += incr) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
384 |
if (pc == pc0) |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
385 |
st->print(BYTES_COMMENT); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
386 |
else if ((uint)(pc - pc0) % sizeof(int) == 0) |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
387 |
st->print(" "); // put out a space on word boundaries |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
388 |
if (incr == sizeof(int)) |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
389 |
st->print("%08lx", *(int*)pc); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
390 |
else st->print("%02x", (*pc)&0xFF); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
391 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
392 |
st->cr(); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
393 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
394 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
395 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
396 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
397 |
static void* event_to_env(void* env_pv, const char* event, void* arg) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
398 |
decode_env* env = (decode_env*) env_pv; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
399 |
return env->handle_event(event, (address) arg); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
400 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
401 |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
22234
diff
changeset
|
402 |
ATTRIBUTE_PRINTF(2, 3) |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
403 |
static int printf_to_env(void* env_pv, const char* format, ...) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
404 |
decode_env* env = (decode_env*) env_pv; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
405 |
outputStream* st = env->output(); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
406 |
size_t flen = strlen(format); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
407 |
const char* raw = NULL; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
408 |
if (flen == 0) return 0; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
409 |
if (flen == 1 && format[0] == '\n') { st->bol(); return 1; } |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
410 |
if (flen < 2 || |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
411 |
strchr(format, '%') == NULL) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
412 |
raw = format; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
413 |
} else if (format[0] == '%' && format[1] == '%' && |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
414 |
strchr(format+2, '%') == NULL) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
415 |
// happens a lot on machines with names like %foo |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
416 |
flen--; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
417 |
raw = format+1; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
418 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
419 |
if (raw != NULL) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
420 |
st->print_raw(raw, (int) flen); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
421 |
return (int) flen; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
422 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
423 |
va_list ap; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
424 |
va_start(ap, format); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
425 |
julong cnt0 = st->count(); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
426 |
st->vprint(format, ap); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
427 |
julong cnt1 = st->count(); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
428 |
va_end(ap); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
429 |
return (int)(cnt1 - cnt0); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
430 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
431 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
432 |
address decode_env::decode_instructions(address start, address end) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
433 |
_start = start; _end = end; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
434 |
|
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
435 |
assert(((((intptr_t)start | (intptr_t)end) % Disassembler::pd_instruction_alignment()) == 0), "misaligned insn addr"); |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
436 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
437 |
const int show_bytes = false; // for disassembler debugging |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
438 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
439 |
//_version = Disassembler::pd_cpu_version(); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
440 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
441 |
if (!Disassembler::can_decode()) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
442 |
return NULL; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
443 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
444 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
445 |
// decode a series of instructions and return the end of the last instruction |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
446 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
447 |
if (_print_raw) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
448 |
// Print whatever the library wants to print, w/o fancy callbacks. |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
449 |
// This is mainly for debugging the library itself. |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
450 |
FILE* out = stdout; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
451 |
FILE* xmlout = (_print_raw > 1 ? out : NULL); |
14384
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
452 |
return use_new_version ? |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
453 |
(address) |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
454 |
(*Disassembler::_decode_instructions_virtual)((uintptr_t)start, (uintptr_t)end, |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
455 |
start, end - start, |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
456 |
NULL, (void*) xmlout, |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
457 |
NULL, (void*) out, |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
458 |
options(), 0/*nice new line*/) |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
459 |
: |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
460 |
(address) |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
461 |
(*Disassembler::_decode_instructions)(start, end, |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
462 |
NULL, (void*) xmlout, |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
463 |
NULL, (void*) out, |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
464 |
options()); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
465 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
466 |
|
14384
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
467 |
return use_new_version ? |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
468 |
(address) |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
469 |
(*Disassembler::_decode_instructions_virtual)((uintptr_t)start, (uintptr_t)end, |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
470 |
start, end - start, |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
471 |
&event_to_env, (void*) this, |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
472 |
&printf_to_env, (void*) this, |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
473 |
options(), 0/*nice new line*/) |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
474 |
: |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
475 |
(address) |
801df8025142
8000489: older builds of hsdis don't work anymore after 6879063
minqi
parents:
13897
diff
changeset
|
476 |
(*Disassembler::_decode_instructions)(start, end, |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
477 |
&event_to_env, (void*) this, |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
478 |
&printf_to_env, (void*) this, |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
479 |
options()); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
480 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
481 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
482 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
483 |
void Disassembler::decode(CodeBlob* cb, outputStream* st) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
484 |
if (!load_library()) return; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
485 |
decode_env env(cb, st); |
9630
d6419e4395e3
6939861: JVM should handle more conversion operations
never
parents:
8921
diff
changeset
|
486 |
env.output()->print_cr("Decoding CodeBlob " PTR_FORMAT, cb); |
6418 | 487 |
env.decode_instructions(cb->code_begin(), cb->code_end()); |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
488 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
489 |
|
16368
713209c45a82
8008555: Debugging code in compiled method sometimes leaks memory
roland
parents:
14488
diff
changeset
|
490 |
void Disassembler::decode(address start, address end, outputStream* st, CodeStrings c) { |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
491 |
if (!load_library()) return; |
13887
89b873bcc55b
7200163: add CodeComments functionality to assember stubs
kvn
parents:
10017
diff
changeset
|
492 |
decode_env env(CodeCache::find_blob_unsafe(start), st, c); |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
493 |
env.decode_instructions(start, end); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
494 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
495 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
496 |
void Disassembler::decode(nmethod* nm, outputStream* st) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
497 |
if (!load_library()) return; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
498 |
decode_env env(nm, st); |
9630
d6419e4395e3
6939861: JVM should handle more conversion operations
never
parents:
8921
diff
changeset
|
499 |
env.output()->print_cr("Decoding compiled method " PTR_FORMAT ":", nm); |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
500 |
env.output()->print_cr("Code:"); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
501 |
|
6187 | 502 |
#ifdef SHARK |
6418 | 503 |
SharkEntry* entry = (SharkEntry *) nm->code_begin(); |
504 |
unsigned char* p = entry->code_start(); |
|
6187 | 505 |
unsigned char* end = entry->code_limit(); |
506 |
#else |
|
6418 | 507 |
unsigned char* p = nm->code_begin(); |
508 |
unsigned char* end = nm->code_end(); |
|
6187 | 509 |
#endif // SHARK |
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
510 |
|
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
511 |
// If there has been profiling, print the buckets. |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
512 |
if (FlatProfiler::bucket_start_for(p) != NULL) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
513 |
unsigned char* p1 = p; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
514 |
int total_bucket_count = 0; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
515 |
while (p1 < end) { |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
516 |
unsigned char* p0 = p1; |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
517 |
p1 += pd_instruction_alignment(); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
518 |
address bucket_pc = FlatProfiler::bucket_start_for(p1); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
519 |
if (bucket_pc != NULL && bucket_pc > p0 && bucket_pc <= p1) |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
520 |
total_bucket_count += FlatProfiler::bucket_count_for(p0); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
521 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
522 |
env.set_total_ticks(total_bucket_count); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
523 |
} |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
524 |
|
7433 | 525 |
// Print constant table. |
526 |
if (nm->consts_size() > 0) { |
|
527 |
nm->print_nmethod_labels(env.output(), nm->consts_begin()); |
|
528 |
int offset = 0; |
|
529 |
for (address p = nm->consts_begin(); p < nm->consts_end(); p += 4, offset += 4) { |
|
530 |
if ((offset % 8) == 0) { |
|
9630
d6419e4395e3
6939861: JVM should handle more conversion operations
never
parents:
8921
diff
changeset
|
531 |
env.output()->print_cr(" " PTR_FORMAT " (offset: %4d): " PTR32_FORMAT " " PTR64_FORMAT, p, offset, *((int32_t*) p), *((int64_t*) p)); |
7433 | 532 |
} else { |
9630
d6419e4395e3
6939861: JVM should handle more conversion operations
never
parents:
8921
diff
changeset
|
533 |
env.output()->print_cr(" " PTR_FORMAT " (offset: %4d): " PTR32_FORMAT, p, offset, *((int32_t*) p)); |
7433 | 534 |
} |
535 |
} |
|
536 |
} |
|
537 |
||
347
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
538 |
env.decode_instructions(p, end); |
df859fcca515
6667042: PrintAssembly option does not work without special plugin
jrose
parents:
diff
changeset
|
539 |
} |