author | gziemski |
Thu, 18 Jun 2015 14:39:38 -0500 | |
changeset 31371 | 311143309e73 |
parent 30764 | fec48bf5a827 |
child 36795 | bfd8c074c8ec |
permissions | -rw-r--r-- |
1 | 1 |
/* |
29081
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
27880
diff
changeset
|
2 |
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4571
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4571
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:
4571
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "classfile/javaClasses.hpp" |
|
27 |
#include "classfile/systemDictionary.hpp" |
|
30764 | 28 |
#include "gc/shared/vmGCOperations.hpp" |
7397 | 29 |
#include "memory/resourceArea.hpp" |
29081
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
27880
diff
changeset
|
30 |
#include "oops/oop.inline.hpp" |
7397 | 31 |
#include "prims/jvmtiExport.hpp" |
32 |
#include "runtime/arguments.hpp" |
|
33 |
#include "runtime/globals.hpp" |
|
34 |
#include "runtime/java.hpp" |
|
35 |
#include "runtime/javaCalls.hpp" |
|
36 |
#include "runtime/os.hpp" |
|
37 |
#include "services/attachListener.hpp" |
|
11209 | 38 |
#include "services/diagnosticCommand.hpp" |
30764 | 39 |
#include "services/heapDumper.hpp" |
28949
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
27880
diff
changeset
|
40 |
#include "services/writeableFlags.hpp" |
1 | 41 |
|
42 |
volatile bool AttachListener::_initialized; |
|
43 |
||
44 |
// Implementation of "properties" command. |
|
45 |
// |
|
46 |
// Invokes sun.misc.VMSupport.serializePropertiesToByteArray to serialize |
|
47 |
// the system properties into a byte array. |
|
48 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
49 |
static Klass* load_and_initialize_klass(Symbol* sh, TRAPS) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
50 |
Klass* k = SystemDictionary::resolve_or_fail(sh, true, CHECK_NULL); |
1 | 51 |
instanceKlassHandle ik (THREAD, k); |
52 |
if (ik->should_be_initialized()) { |
|
53 |
ik->initialize(CHECK_NULL); |
|
54 |
} |
|
55 |
return ik(); |
|
56 |
} |
|
57 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
58 |
static jint get_properties(AttachOperation* op, outputStream* out, Symbol* serializePropertiesMethod) { |
1 | 59 |
Thread* THREAD = Thread::current(); |
60 |
HandleMark hm; |
|
61 |
||
62 |
// load sun.misc.VMSupport |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
63 |
Symbol* klass = vmSymbols::sun_misc_VMSupport(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
64 |
Klass* k = load_and_initialize_klass(klass, THREAD); |
1 | 65 |
if (HAS_PENDING_EXCEPTION) { |
66 |
java_lang_Throwable::print(PENDING_EXCEPTION, out); |
|
67 |
CLEAR_PENDING_EXCEPTION; |
|
68 |
return JNI_ERR; |
|
69 |
} |
|
70 |
instanceKlassHandle ik(THREAD, k); |
|
71 |
||
72 |
// invoke the serializePropertiesToByteArray method |
|
73 |
JavaValue result(T_OBJECT); |
|
74 |
JavaCallArguments args; |
|
75 |
||
76 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
77 |
Symbol* signature = vmSymbols::serializePropertiesToByteArray_signature(); |
1 | 78 |
JavaCalls::call_static(&result, |
79 |
ik, |
|
80 |
serializePropertiesMethod, |
|
81 |
signature, |
|
82 |
&args, |
|
83 |
THREAD); |
|
84 |
if (HAS_PENDING_EXCEPTION) { |
|
85 |
java_lang_Throwable::print(PENDING_EXCEPTION, out); |
|
86 |
CLEAR_PENDING_EXCEPTION; |
|
87 |
return JNI_ERR; |
|
88 |
} |
|
89 |
||
90 |
// The result should be a [B |
|
91 |
oop res = (oop)result.get_jobject(); |
|
92 |
assert(res->is_typeArray(), "just checking"); |
|
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13728
diff
changeset
|
93 |
assert(TypeArrayKlass::cast(res->klass())->element_type() == T_BYTE, "just checking"); |
1 | 94 |
|
95 |
// copy the bytes to the output stream |
|
96 |
typeArrayOop ba = typeArrayOop(res); |
|
97 |
jbyte* addr = typeArrayOop(res)->byte_at_addr(0); |
|
98 |
out->print_raw((const char*)addr, ba->length()); |
|
99 |
||
100 |
return JNI_OK; |
|
101 |
} |
|
102 |
||
103 |
// Implementation of "properties" command. |
|
11441 | 104 |
// See also: PrintSystemPropertiesDCmd class |
1 | 105 |
static jint get_system_properties(AttachOperation* op, outputStream* out) { |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
106 |
return get_properties(op, out, vmSymbols::serializePropertiesToByteArray_name()); |
1 | 107 |
} |
108 |
||
109 |
// Implementation of "agent_properties" command. |
|
110 |
static jint get_agent_properties(AttachOperation* op, outputStream* out) { |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
111 |
return get_properties(op, out, vmSymbols::serializeAgentPropertiesToByteArray_name()); |
1 | 112 |
} |
113 |
||
114 |
// Implementation of "datadump" command. |
|
115 |
// |
|
116 |
// Raises a SIGBREAK signal so that VM dump threads, does deadlock detection, |
|
117 |
// etc. In theory this command should only post a DataDumpRequest to any |
|
118 |
// JVMTI environment that has enabled this event. However it's useful to |
|
119 |
// trigger the SIGBREAK handler. |
|
120 |
||
121 |
static jint data_dump(AttachOperation* op, outputStream* out) { |
|
122 |
if (!ReduceSignalUsage) { |
|
123 |
AttachListener::pd_data_dump(); |
|
124 |
} else { |
|
125 |
if (JvmtiExport::should_post_data_dump()) { |
|
126 |
JvmtiExport::post_data_dump(); |
|
127 |
} |
|
128 |
} |
|
129 |
return JNI_OK; |
|
130 |
} |
|
131 |
||
132 |
// Implementation of "threaddump" command - essentially a remote ctrl-break |
|
11441 | 133 |
// See also: ThreadDumpDCmd class |
1 | 134 |
// |
135 |
static jint thread_dump(AttachOperation* op, outputStream* out) { |
|
136 |
bool print_concurrent_locks = false; |
|
137 |
if (op->arg(0) != NULL && strcmp(op->arg(0), "-l") == 0) { |
|
138 |
print_concurrent_locks = true; |
|
139 |
} |
|
140 |
||
141 |
// thread stacks |
|
142 |
VM_PrintThreads op1(out, print_concurrent_locks); |
|
143 |
VMThread::execute(&op1); |
|
144 |
||
145 |
// JNI global handles |
|
146 |
VM_PrintJNI op2(out); |
|
147 |
VMThread::execute(&op2); |
|
148 |
||
149 |
// Deadlock detection |
|
150 |
VM_FindDeadlocks op3(out); |
|
151 |
VMThread::execute(&op3); |
|
152 |
||
153 |
return JNI_OK; |
|
154 |
} |
|
155 |
||
11209 | 156 |
// A jcmd attach operation request was received, which will now |
157 |
// dispatch to the diagnostic commands used for serviceability functions. |
|
158 |
static jint jcmd(AttachOperation* op, outputStream* out) { |
|
159 |
Thread* THREAD = Thread::current(); |
|
160 |
// All the supplied jcmd arguments are stored as a single |
|
161 |
// string (op->arg(0)). This is parsed by the Dcmd framework. |
|
17296
68557efd8583
8004095: Add support for JMX interface to Diagnostic Framework and Commands
fparain
parents:
15432
diff
changeset
|
162 |
DCmd::parse_and_execute(DCmd_Source_AttachAPI, out, op->arg(0), ' ', THREAD); |
11209 | 163 |
if (HAS_PENDING_EXCEPTION) { |
164 |
java_lang_Throwable::print(PENDING_EXCEPTION, out); |
|
11441 | 165 |
out->cr(); |
11209 | 166 |
CLEAR_PENDING_EXCEPTION; |
24833
c55a7c2888f6
8044398: Attach code should propagate errors in Diagnostic Commands as errors
sla
parents:
24424
diff
changeset
|
167 |
return JNI_ERR; |
11209 | 168 |
} |
169 |
return JNI_OK; |
|
170 |
} |
|
171 |
||
1 | 172 |
// Implementation of "dumpheap" command. |
11441 | 173 |
// See also: HeapDumpDCmd class |
1 | 174 |
// |
175 |
// Input arguments :- |
|
176 |
// arg0: Name of the dump file |
|
177 |
// arg1: "-live" or "-all" |
|
178 |
jint dump_heap(AttachOperation* op, outputStream* out) { |
|
179 |
const char* path = op->arg(0); |
|
180 |
if (path == NULL || path[0] == '\0') { |
|
181 |
out->print_cr("No dump file specified"); |
|
182 |
} else { |
|
183 |
bool live_objects_only = true; // default is true to retain the behavior before this change is made |
|
184 |
const char* arg1 = op->arg(1); |
|
185 |
if (arg1 != NULL && (strlen(arg1) > 0)) { |
|
186 |
if (strcmp(arg1, "-all") != 0 && strcmp(arg1, "-live") != 0) { |
|
187 |
out->print_cr("Invalid argument to dumpheap operation: %s", arg1); |
|
188 |
return JNI_ERR; |
|
189 |
} |
|
190 |
live_objects_only = strcmp(arg1, "-live") == 0; |
|
191 |
} |
|
192 |
||
193 |
// Request a full GC before heap dump if live_objects_only = true |
|
194 |
// This helps reduces the amount of unreachable objects in the dump |
|
195 |
// and makes it easier to browse. |
|
196 |
HeapDumper dumper(live_objects_only /* request GC */); |
|
197 |
int res = dumper.dump(op->arg(0)); |
|
198 |
if (res == 0) { |
|
199 |
out->print_cr("Heap dump file created"); |
|
200 |
} else { |
|
201 |
// heap dump failed |
|
202 |
ResourceMark rm; |
|
203 |
char* error = dumper.error_as_C_string(); |
|
204 |
if (error == NULL) { |
|
205 |
out->print_cr("Dump failed - reason unknown"); |
|
206 |
} else { |
|
207 |
out->print_cr("%s", error); |
|
208 |
} |
|
209 |
} |
|
210 |
} |
|
211 |
return JNI_OK; |
|
212 |
} |
|
213 |
||
214 |
// Implementation of "inspectheap" command |
|
11441 | 215 |
// See also: ClassHistogramDCmd class |
1 | 216 |
// |
217 |
// Input arguments :- |
|
218 |
// arg0: "-live" or "-all" |
|
219 |
static jint heap_inspection(AttachOperation* op, outputStream* out) { |
|
220 |
bool live_objects_only = true; // default is true to retain the behavior before this change is made |
|
221 |
const char* arg0 = op->arg(0); |
|
222 |
if (arg0 != NULL && (strlen(arg0) > 0)) { |
|
223 |
if (strcmp(arg0, "-all") != 0 && strcmp(arg0, "-live") != 0) { |
|
224 |
out->print_cr("Invalid argument to inspectheap operation: %s", arg0); |
|
225 |
return JNI_ERR; |
|
226 |
} |
|
227 |
live_objects_only = strcmp(arg0, "-live") == 0; |
|
228 |
} |
|
18025 | 229 |
VM_GC_HeapInspection heapop(out, live_objects_only /* request full gc */); |
1 | 230 |
VMThread::execute(&heapop); |
231 |
return JNI_OK; |
|
232 |
} |
|
233 |
||
234 |
// Implementation of "setflag" command |
|
235 |
static jint set_flag(AttachOperation* op, outputStream* out) { |
|
236 |
||
237 |
const char* name = NULL; |
|
238 |
if ((name = op->arg(0)) == NULL) { |
|
239 |
out->print_cr("flag name is missing"); |
|
240 |
return JNI_ERR; |
|
241 |
} |
|
242 |
||
28949
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
27880
diff
changeset
|
243 |
FormatBuffer<80> err_msg("%s", ""); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
27880
diff
changeset
|
244 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
27880
diff
changeset
|
245 |
int ret = WriteableFlags::set_flag(op->arg(0), op->arg(1), Flag::ATTACH_ON_DEMAND, err_msg); |
31371
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
30764
diff
changeset
|
246 |
if (ret != Flag::SUCCESS) { |
311143309e73
8122937: [JEP 245] Validate JVM Command-Line Flag Arguments.
gziemski
parents:
30764
diff
changeset
|
247 |
if (ret == Flag::NON_WRITABLE) { |
28949
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
27880
diff
changeset
|
248 |
// if the flag is not manageable try to change it through |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
27880
diff
changeset
|
249 |
// the platform dependent implementation |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
27880
diff
changeset
|
250 |
return AttachListener::pd_set_flag(op, out); |
1 | 251 |
} else { |
28949
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
27880
diff
changeset
|
252 |
out->print_cr("%s", err_msg.buffer()); |
1 | 253 |
} |
28949
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
27880
diff
changeset
|
254 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
27880
diff
changeset
|
255 |
return JNI_ERR; |
1 | 256 |
} |
28949
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
27880
diff
changeset
|
257 |
return JNI_OK; |
1 | 258 |
} |
259 |
||
260 |
// Implementation of "printflag" command |
|
11441 | 261 |
// See also: PrintVMFlagsDCmd class |
1 | 262 |
static jint print_flag(AttachOperation* op, outputStream* out) { |
263 |
const char* name = NULL; |
|
264 |
if ((name = op->arg(0)) == NULL) { |
|
265 |
out->print_cr("flag name is missing"); |
|
266 |
return JNI_ERR; |
|
267 |
} |
|
268 |
Flag* f = Flag::find_flag((char*)name, strlen(name)); |
|
269 |
if (f) { |
|
270 |
f->print_as_flag(out); |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
22758
diff
changeset
|
271 |
out->cr(); |
1 | 272 |
} else { |
273 |
out->print_cr("no such flag '%s'", name); |
|
274 |
} |
|
275 |
return JNI_OK; |
|
276 |
} |
|
277 |
||
278 |
// Table to map operation names to functions. |
|
279 |
||
280 |
// names must be of length <= AttachOperation::name_length_max |
|
281 |
static AttachOperationFunctionInfo funcs[] = { |
|
282 |
{ "agentProperties", get_agent_properties }, |
|
283 |
{ "datadump", data_dump }, |
|
284 |
{ "dumpheap", dump_heap }, |
|
285 |
{ "load", JvmtiExport::load_agent_library }, |
|
286 |
{ "properties", get_system_properties }, |
|
287 |
{ "threaddump", thread_dump }, |
|
288 |
{ "inspectheap", heap_inspection }, |
|
289 |
{ "setflag", set_flag }, |
|
290 |
{ "printflag", print_flag }, |
|
11209 | 291 |
{ "jcmd", jcmd }, |
1 | 292 |
{ NULL, NULL } |
293 |
}; |
|
294 |
||
295 |
||
296 |
||
297 |
// The Attach Listener threads services a queue. It dequeues an operation |
|
298 |
// from the queue, examines the operation name (command), and dispatches |
|
299 |
// to the corresponding function to perform the operation. |
|
300 |
||
301 |
static void attach_listener_thread_entry(JavaThread* thread, TRAPS) { |
|
302 |
os::set_priority(thread, NearMaxPriority); |
|
303 |
||
14120
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13952
diff
changeset
|
304 |
thread->record_stack_base_and_size(); |
7d298141c258
7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents:
13952
diff
changeset
|
305 |
|
1 | 306 |
if (AttachListener::pd_init() != 0) { |
307 |
return; |
|
308 |
} |
|
309 |
AttachListener::set_initialized(); |
|
310 |
||
311 |
for (;;) { |
|
312 |
AttachOperation* op = AttachListener::dequeue(); |
|
313 |
if (op == NULL) { |
|
314 |
return; // dequeue failed or shutdown |
|
315 |
} |
|
316 |
||
317 |
ResourceMark rm; |
|
318 |
bufferedStream st; |
|
319 |
jint res = JNI_OK; |
|
320 |
||
321 |
// handle special detachall operation |
|
322 |
if (strcmp(op->name(), AttachOperation::detachall_operation_name()) == 0) { |
|
323 |
AttachListener::detachall(); |
|
324 |
} else { |
|
325 |
// find the function to dispatch too |
|
326 |
AttachOperationFunctionInfo* info = NULL; |
|
327 |
for (int i=0; funcs[i].name != NULL; i++) { |
|
328 |
const char* name = funcs[i].name; |
|
329 |
assert(strlen(name) <= AttachOperation::name_length_max, "operation <= name_length_max"); |
|
330 |
if (strcmp(op->name(), name) == 0) { |
|
331 |
info = &(funcs[i]); |
|
332 |
break; |
|
333 |
} |
|
334 |
} |
|
335 |
||
336 |
// check for platform dependent attach operation |
|
337 |
if (info == NULL) { |
|
338 |
info = AttachListener::pd_find_operation(op->name()); |
|
339 |
} |
|
340 |
||
341 |
if (info != NULL) { |
|
342 |
// dispatch to the function that implements this operation |
|
343 |
res = (info->func)(op, &st); |
|
344 |
} else { |
|
345 |
st.print("Operation %s not recognized!", op->name()); |
|
346 |
res = JNI_ERR; |
|
347 |
} |
|
348 |
} |
|
349 |
||
350 |
// operation complete - send result and output to client |
|
351 |
op->complete(res, &st); |
|
352 |
} |
|
353 |
} |
|
354 |
||
22197
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
355 |
bool AttachListener::has_init_error(TRAPS) { |
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
356 |
if (HAS_PENDING_EXCEPTION) { |
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
357 |
tty->print_cr("Exception in VM (AttachListener::init) : "); |
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
358 |
java_lang_Throwable::print(PENDING_EXCEPTION, tty); |
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
359 |
tty->cr(); |
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
360 |
|
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
361 |
CLEAR_PENDING_EXCEPTION; |
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
362 |
|
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
363 |
return true; |
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
364 |
} else { |
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
365 |
return false; |
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
366 |
} |
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
367 |
} |
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
368 |
|
1 | 369 |
// Starts the Attach Listener thread |
370 |
void AttachListener::init() { |
|
371 |
EXCEPTION_MARK; |
|
22197
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
372 |
Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, THREAD); |
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
373 |
if (has_init_error(THREAD)) { |
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
374 |
return; |
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
375 |
} |
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
376 |
|
1 | 377 |
instanceKlassHandle klass (THREAD, k); |
22197
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
378 |
instanceHandle thread_oop = klass->allocate_instance_handle(THREAD); |
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
379 |
if (has_init_error(THREAD)) { |
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
380 |
return; |
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
381 |
} |
1 | 382 |
|
383 |
const char thread_name[] = "Attach Listener"; |
|
22197
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
384 |
Handle string = java_lang_String::create_from_str(thread_name, THREAD); |
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
385 |
if (has_init_error(THREAD)) { |
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
386 |
return; |
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
387 |
} |
1 | 388 |
|
389 |
// Initialize thread_oop to put it into the system threadGroup |
|
390 |
Handle thread_group (THREAD, Universe::system_thread_group()); |
|
391 |
JavaValue result(T_VOID); |
|
392 |
JavaCalls::call_special(&result, thread_oop, |
|
393 |
klass, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
394 |
vmSymbols::object_initializer_name(), |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
395 |
vmSymbols::threadgroup_string_void_signature(), |
1 | 396 |
thread_group, |
397 |
string, |
|
20067
e0337f5f9f5a
6989981: jstack causes "fatal error: ExceptionMark destructor expects no pending exceptions"
sla
parents:
18025
diff
changeset
|
398 |
THREAD); |
e0337f5f9f5a
6989981: jstack causes "fatal error: ExceptionMark destructor expects no pending exceptions"
sla
parents:
18025
diff
changeset
|
399 |
|
22197
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
400 |
if (has_init_error(THREAD)) { |
20067
e0337f5f9f5a
6989981: jstack causes "fatal error: ExceptionMark destructor expects no pending exceptions"
sla
parents:
18025
diff
changeset
|
401 |
return; |
e0337f5f9f5a
6989981: jstack causes "fatal error: ExceptionMark destructor expects no pending exceptions"
sla
parents:
18025
diff
changeset
|
402 |
} |
1 | 403 |
|
4571 | 404 |
KlassHandle group(THREAD, SystemDictionary::ThreadGroup_klass()); |
1 | 405 |
JavaCalls::call_special(&result, |
406 |
thread_group, |
|
407 |
group, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
408 |
vmSymbols::add_method_name(), |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
409 |
vmSymbols::thread_void_signature(), |
1 | 410 |
thread_oop, // ARG 1 |
20067
e0337f5f9f5a
6989981: jstack causes "fatal error: ExceptionMark destructor expects no pending exceptions"
sla
parents:
18025
diff
changeset
|
411 |
THREAD); |
22197
41ea552a447d
6730115: Fastdebug VM crashes with "ExceptionMark destructor expects no pending exceptions" error
zgu
parents:
20291
diff
changeset
|
412 |
if (has_init_error(THREAD)) { |
20067
e0337f5f9f5a
6989981: jstack causes "fatal error: ExceptionMark destructor expects no pending exceptions"
sla
parents:
18025
diff
changeset
|
413 |
return; |
e0337f5f9f5a
6989981: jstack causes "fatal error: ExceptionMark destructor expects no pending exceptions"
sla
parents:
18025
diff
changeset
|
414 |
} |
1 | 415 |
|
416 |
{ MutexLocker mu(Threads_lock); |
|
417 |
JavaThread* listener_thread = new JavaThread(&attach_listener_thread_entry); |
|
418 |
||
419 |
// Check that thread and osthread were created |
|
420 |
if (listener_thread == NULL || listener_thread->osthread() == NULL) { |
|
421 |
vm_exit_during_initialization("java.lang.OutOfMemoryError", |
|
22758
c6b6abb73544
7182040: volano29 limited by os resource on Linux - need better diagnostic message
iklam
parents:
22555
diff
changeset
|
422 |
os::native_thread_creation_failed_msg()); |
1 | 423 |
} |
424 |
||
425 |
java_lang_Thread::set_thread(thread_oop(), listener_thread); |
|
426 |
java_lang_Thread::set_daemon(thread_oop()); |
|
427 |
||
428 |
listener_thread->set_threadObj(thread_oop()); |
|
429 |
Threads::add(listener_thread); |
|
430 |
Thread::start(listener_thread); |
|
431 |
} |
|
432 |
} |
|
433 |
||
434 |
// Performs clean-up tasks on platforms where we can detect that the last |
|
435 |
// client has detached |
|
436 |
void AttachListener::detachall() { |
|
437 |
// call the platform dependent clean-up |
|
438 |
pd_detachall(); |
|
439 |
} |