aoqi@0: /* aoqi@0: * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #include "precompiled.hpp" aoqi@0: #include "classfile/javaClasses.hpp" aoqi@0: #include "classfile/systemDictionary.hpp" aoqi@0: #include "gc_implementation/shared/vmGCOperations.hpp" aoqi@0: #include "memory/resourceArea.hpp" aoqi@0: #include "prims/jvmtiExport.hpp" aoqi@0: #include "runtime/arguments.hpp" aoqi@0: #include "runtime/globals.hpp" aoqi@0: #include "runtime/java.hpp" aoqi@0: #include "runtime/javaCalls.hpp" aoqi@0: #include "runtime/os.hpp" aoqi@0: #include "services/attachListener.hpp" aoqi@0: #include "services/diagnosticCommand.hpp" aoqi@0: #include "services/heapDumper.hpp" aoqi@0: aoqi@0: volatile bool AttachListener::_initialized; aoqi@0: aoqi@0: // Implementation of "properties" command. aoqi@0: // aoqi@0: // Invokes sun.misc.VMSupport.serializePropertiesToByteArray to serialize aoqi@0: // the system properties into a byte array. aoqi@0: aoqi@0: static Klass* load_and_initialize_klass(Symbol* sh, TRAPS) { aoqi@0: Klass* k = SystemDictionary::resolve_or_fail(sh, true, CHECK_NULL); aoqi@0: instanceKlassHandle ik (THREAD, k); aoqi@0: if (ik->should_be_initialized()) { aoqi@0: ik->initialize(CHECK_NULL); aoqi@0: } aoqi@0: return ik(); aoqi@0: } aoqi@0: aoqi@0: static jint get_properties(AttachOperation* op, outputStream* out, Symbol* serializePropertiesMethod) { aoqi@0: Thread* THREAD = Thread::current(); aoqi@0: HandleMark hm; aoqi@0: aoqi@0: // load sun.misc.VMSupport aoqi@0: Symbol* klass = vmSymbols::sun_misc_VMSupport(); aoqi@0: Klass* k = load_and_initialize_klass(klass, THREAD); aoqi@0: if (HAS_PENDING_EXCEPTION) { aoqi@0: java_lang_Throwable::print(PENDING_EXCEPTION, out); aoqi@0: CLEAR_PENDING_EXCEPTION; aoqi@0: return JNI_ERR; aoqi@0: } aoqi@0: instanceKlassHandle ik(THREAD, k); aoqi@0: aoqi@0: // invoke the serializePropertiesToByteArray method aoqi@0: JavaValue result(T_OBJECT); aoqi@0: JavaCallArguments args; aoqi@0: aoqi@0: aoqi@0: Symbol* signature = vmSymbols::serializePropertiesToByteArray_signature(); aoqi@0: JavaCalls::call_static(&result, aoqi@0: ik, aoqi@0: serializePropertiesMethod, aoqi@0: signature, aoqi@0: &args, aoqi@0: THREAD); aoqi@0: if (HAS_PENDING_EXCEPTION) { aoqi@0: java_lang_Throwable::print(PENDING_EXCEPTION, out); aoqi@0: CLEAR_PENDING_EXCEPTION; aoqi@0: return JNI_ERR; aoqi@0: } aoqi@0: aoqi@0: // The result should be a [B aoqi@0: oop res = (oop)result.get_jobject(); aoqi@0: assert(res->is_typeArray(), "just checking"); aoqi@0: assert(TypeArrayKlass::cast(res->klass())->element_type() == T_BYTE, "just checking"); aoqi@0: aoqi@0: // copy the bytes to the output stream aoqi@0: typeArrayOop ba = typeArrayOop(res); aoqi@0: jbyte* addr = typeArrayOop(res)->byte_at_addr(0); aoqi@0: out->print_raw((const char*)addr, ba->length()); aoqi@0: aoqi@0: return JNI_OK; aoqi@0: } aoqi@0: aoqi@0: // Implementation of "properties" command. aoqi@0: // See also: PrintSystemPropertiesDCmd class aoqi@0: static jint get_system_properties(AttachOperation* op, outputStream* out) { aoqi@0: return get_properties(op, out, vmSymbols::serializePropertiesToByteArray_name()); aoqi@0: } aoqi@0: aoqi@0: // Implementation of "agent_properties" command. aoqi@0: static jint get_agent_properties(AttachOperation* op, outputStream* out) { aoqi@0: return get_properties(op, out, vmSymbols::serializeAgentPropertiesToByteArray_name()); aoqi@0: } aoqi@0: aoqi@0: // Implementation of "datadump" command. aoqi@0: // aoqi@0: // Raises a SIGBREAK signal so that VM dump threads, does deadlock detection, aoqi@0: // etc. In theory this command should only post a DataDumpRequest to any aoqi@0: // JVMTI environment that has enabled this event. However it's useful to aoqi@0: // trigger the SIGBREAK handler. aoqi@0: aoqi@0: static jint data_dump(AttachOperation* op, outputStream* out) { aoqi@0: if (!ReduceSignalUsage) { aoqi@0: AttachListener::pd_data_dump(); aoqi@0: } else { aoqi@0: if (JvmtiExport::should_post_data_dump()) { aoqi@0: JvmtiExport::post_data_dump(); aoqi@0: } aoqi@0: } aoqi@0: return JNI_OK; aoqi@0: } aoqi@0: aoqi@0: // Implementation of "threaddump" command - essentially a remote ctrl-break aoqi@0: // See also: ThreadDumpDCmd class aoqi@0: // aoqi@0: static jint thread_dump(AttachOperation* op, outputStream* out) { aoqi@0: bool print_concurrent_locks = false; aoqi@0: if (op->arg(0) != NULL && strcmp(op->arg(0), "-l") == 0) { aoqi@0: print_concurrent_locks = true; aoqi@0: } aoqi@0: aoqi@0: // thread stacks aoqi@0: VM_PrintThreads op1(out, print_concurrent_locks); aoqi@0: VMThread::execute(&op1); aoqi@0: aoqi@0: // JNI global handles aoqi@0: VM_PrintJNI op2(out); aoqi@0: VMThread::execute(&op2); aoqi@0: aoqi@0: // Deadlock detection aoqi@0: VM_FindDeadlocks op3(out); aoqi@0: VMThread::execute(&op3); aoqi@0: aoqi@0: return JNI_OK; aoqi@0: } aoqi@0: aoqi@0: // A jcmd attach operation request was received, which will now aoqi@0: // dispatch to the diagnostic commands used for serviceability functions. aoqi@0: static jint jcmd(AttachOperation* op, outputStream* out) { aoqi@0: Thread* THREAD = Thread::current(); aoqi@0: // All the supplied jcmd arguments are stored as a single aoqi@0: // string (op->arg(0)). This is parsed by the Dcmd framework. aoqi@0: DCmd::parse_and_execute(DCmd_Source_AttachAPI, out, op->arg(0), ' ', THREAD); aoqi@0: if (HAS_PENDING_EXCEPTION) { aoqi@0: java_lang_Throwable::print(PENDING_EXCEPTION, out); aoqi@0: out->cr(); aoqi@0: CLEAR_PENDING_EXCEPTION; aoqi@0: // The exception has been printed on the output stream aoqi@0: // If the JVM returns JNI_ERR, the attachAPI throws a generic I/O aoqi@0: // exception and the content of the output stream is not processed. aoqi@0: // By returning JNI_OK, the exception will be displayed on the client side aoqi@0: } aoqi@0: return JNI_OK; aoqi@0: } aoqi@0: aoqi@0: // Implementation of "dumpheap" command. aoqi@0: // See also: HeapDumpDCmd class aoqi@0: // aoqi@0: // Input arguments :- aoqi@0: // arg0: Name of the dump file aoqi@0: // arg1: "-live" or "-all" aoqi@0: jint dump_heap(AttachOperation* op, outputStream* out) { aoqi@0: const char* path = op->arg(0); aoqi@0: if (path == NULL || path[0] == '\0') { aoqi@0: out->print_cr("No dump file specified"); aoqi@0: } else { aoqi@0: bool live_objects_only = true; // default is true to retain the behavior before this change is made aoqi@0: const char* arg1 = op->arg(1); aoqi@0: if (arg1 != NULL && (strlen(arg1) > 0)) { aoqi@0: if (strcmp(arg1, "-all") != 0 && strcmp(arg1, "-live") != 0) { aoqi@0: out->print_cr("Invalid argument to dumpheap operation: %s", arg1); aoqi@0: return JNI_ERR; aoqi@0: } aoqi@0: live_objects_only = strcmp(arg1, "-live") == 0; aoqi@0: } aoqi@0: aoqi@0: // Request a full GC before heap dump if live_objects_only = true aoqi@0: // This helps reduces the amount of unreachable objects in the dump aoqi@0: // and makes it easier to browse. aoqi@0: HeapDumper dumper(live_objects_only /* request GC */); aoqi@0: int res = dumper.dump(op->arg(0)); aoqi@0: if (res == 0) { aoqi@0: out->print_cr("Heap dump file created"); aoqi@0: } else { aoqi@0: // heap dump failed aoqi@0: ResourceMark rm; aoqi@0: char* error = dumper.error_as_C_string(); aoqi@0: if (error == NULL) { aoqi@0: out->print_cr("Dump failed - reason unknown"); aoqi@0: } else { aoqi@0: out->print_cr("%s", error); aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: return JNI_OK; aoqi@0: } aoqi@0: aoqi@0: // Implementation of "inspectheap" command aoqi@0: // See also: ClassHistogramDCmd class aoqi@0: // aoqi@0: // Input arguments :- aoqi@0: // arg0: "-live" or "-all" aoqi@0: static jint heap_inspection(AttachOperation* op, outputStream* out) { aoqi@0: bool live_objects_only = true; // default is true to retain the behavior before this change is made aoqi@0: const char* arg0 = op->arg(0); aoqi@0: if (arg0 != NULL && (strlen(arg0) > 0)) { aoqi@0: if (strcmp(arg0, "-all") != 0 && strcmp(arg0, "-live") != 0) { aoqi@0: out->print_cr("Invalid argument to inspectheap operation: %s", arg0); aoqi@0: return JNI_ERR; aoqi@0: } aoqi@0: live_objects_only = strcmp(arg0, "-live") == 0; aoqi@0: } aoqi@0: VM_GC_HeapInspection heapop(out, live_objects_only /* request full gc */); aoqi@0: VMThread::execute(&heapop); aoqi@0: return JNI_OK; aoqi@0: } aoqi@0: aoqi@0: // set a boolean global flag using value from AttachOperation aoqi@0: static jint set_bool_flag(const char* name, AttachOperation* op, outputStream* out) { aoqi@0: bool value = true; aoqi@0: const char* arg1; aoqi@0: if ((arg1 = op->arg(1)) != NULL) { aoqi@0: int tmp; aoqi@0: int n = sscanf(arg1, "%d", &tmp); aoqi@0: if (n != 1) { aoqi@0: out->print_cr("flag value must be a boolean (1 or 0)"); aoqi@0: return JNI_ERR; aoqi@0: } aoqi@0: value = (tmp != 0); aoqi@0: } aoqi@0: bool res = CommandLineFlags::boolAtPut((char*)name, &value, Flag::ATTACH_ON_DEMAND); aoqi@0: if (! res) { aoqi@0: out->print_cr("setting flag %s failed", name); aoqi@0: } aoqi@0: return res? JNI_OK : JNI_ERR; aoqi@0: } aoqi@0: aoqi@0: // set a intx global flag using value from AttachOperation aoqi@0: static jint set_intx_flag(const char* name, AttachOperation* op, outputStream* out) { aoqi@0: intx value; aoqi@0: const char* arg1; aoqi@0: if ((arg1 = op->arg(1)) != NULL) { aoqi@0: int n = sscanf(arg1, INTX_FORMAT, &value); aoqi@0: if (n != 1) { aoqi@0: out->print_cr("flag value must be an integer"); aoqi@0: return JNI_ERR; aoqi@0: } aoqi@0: } aoqi@0: bool res = CommandLineFlags::intxAtPut((char*)name, &value, Flag::ATTACH_ON_DEMAND); aoqi@0: if (! res) { aoqi@0: out->print_cr("setting flag %s failed", name); aoqi@0: } aoqi@0: aoqi@0: return res? JNI_OK : JNI_ERR; aoqi@0: } aoqi@0: aoqi@0: // set a uintx global flag using value from AttachOperation aoqi@0: static jint set_uintx_flag(const char* name, AttachOperation* op, outputStream* out) { aoqi@0: uintx value; aoqi@0: const char* arg1; aoqi@0: if ((arg1 = op->arg(1)) != NULL) { aoqi@0: int n = sscanf(arg1, UINTX_FORMAT, &value); aoqi@0: if (n != 1) { aoqi@0: out->print_cr("flag value must be an unsigned integer"); aoqi@0: return JNI_ERR; aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: if (strncmp(name, "MaxHeapFreeRatio", 17) == 0) { aoqi@0: FormatBuffer<80> err_msg("%s", ""); aoqi@0: if (!Arguments::verify_MaxHeapFreeRatio(err_msg, value)) { aoqi@0: out->print_cr("%s", err_msg.buffer()); aoqi@0: return JNI_ERR; aoqi@0: } aoqi@0: } else if (strncmp(name, "MinHeapFreeRatio", 17) == 0) { aoqi@0: FormatBuffer<80> err_msg("%s", ""); aoqi@0: if (!Arguments::verify_MinHeapFreeRatio(err_msg, value)) { aoqi@0: out->print_cr("%s", err_msg.buffer()); aoqi@0: return JNI_ERR; aoqi@0: } aoqi@0: } aoqi@0: bool res = CommandLineFlags::uintxAtPut((char*)name, &value, Flag::ATTACH_ON_DEMAND); aoqi@0: if (! res) { aoqi@0: out->print_cr("setting flag %s failed", name); aoqi@0: } aoqi@0: aoqi@0: return res? JNI_OK : JNI_ERR; aoqi@0: } aoqi@0: aoqi@0: // set a uint64_t global flag using value from AttachOperation aoqi@0: static jint set_uint64_t_flag(const char* name, AttachOperation* op, outputStream* out) { aoqi@0: uint64_t value; aoqi@0: const char* arg1; aoqi@0: if ((arg1 = op->arg(1)) != NULL) { aoqi@0: int n = sscanf(arg1, UINT64_FORMAT, &value); aoqi@0: if (n != 1) { aoqi@0: out->print_cr("flag value must be an unsigned 64-bit integer"); aoqi@0: return JNI_ERR; aoqi@0: } aoqi@0: } aoqi@0: bool res = CommandLineFlags::uint64_tAtPut((char*)name, &value, Flag::ATTACH_ON_DEMAND); aoqi@0: if (! res) { aoqi@0: out->print_cr("setting flag %s failed", name); aoqi@0: } aoqi@0: aoqi@0: return res? JNI_OK : JNI_ERR; aoqi@0: } aoqi@0: aoqi@0: // set a string global flag using value from AttachOperation aoqi@0: static jint set_ccstr_flag(const char* name, AttachOperation* op, outputStream* out) { aoqi@0: const char* value; aoqi@0: if ((value = op->arg(1)) == NULL) { aoqi@0: out->print_cr("flag value must be a string"); aoqi@0: return JNI_ERR; aoqi@0: } aoqi@0: bool res = CommandLineFlags::ccstrAtPut((char*)name, &value, Flag::ATTACH_ON_DEMAND); aoqi@0: if (res) { aoqi@0: FREE_C_HEAP_ARRAY(char, value, mtInternal); aoqi@0: } else { aoqi@0: out->print_cr("setting flag %s failed", name); aoqi@0: } aoqi@0: aoqi@0: return res? JNI_OK : JNI_ERR; aoqi@0: } aoqi@0: aoqi@0: // Implementation of "setflag" command aoqi@0: static jint set_flag(AttachOperation* op, outputStream* out) { aoqi@0: aoqi@0: const char* name = NULL; aoqi@0: if ((name = op->arg(0)) == NULL) { aoqi@0: out->print_cr("flag name is missing"); aoqi@0: return JNI_ERR; aoqi@0: } aoqi@0: aoqi@0: Flag* f = Flag::find_flag((char*)name, strlen(name)); aoqi@0: if (f && f->is_external() && f->is_writeable()) { aoqi@0: if (f->is_bool()) { aoqi@0: return set_bool_flag(name, op, out); aoqi@0: } else if (f->is_intx()) { aoqi@0: return set_intx_flag(name, op, out); aoqi@0: } else if (f->is_uintx()) { aoqi@0: return set_uintx_flag(name, op, out); aoqi@0: } else if (f->is_uint64_t()) { aoqi@0: return set_uint64_t_flag(name, op, out); aoqi@0: } else if (f->is_ccstr()) { aoqi@0: return set_ccstr_flag(name, op, out); aoqi@0: } else { aoqi@0: ShouldNotReachHere(); aoqi@0: return JNI_ERR; aoqi@0: } aoqi@0: } else { aoqi@0: return AttachListener::pd_set_flag(op, out); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: // Implementation of "printflag" command aoqi@0: // See also: PrintVMFlagsDCmd class aoqi@0: static jint print_flag(AttachOperation* op, outputStream* out) { aoqi@0: const char* name = NULL; aoqi@0: if ((name = op->arg(0)) == NULL) { aoqi@0: out->print_cr("flag name is missing"); aoqi@0: return JNI_ERR; aoqi@0: } aoqi@0: Flag* f = Flag::find_flag((char*)name, strlen(name)); aoqi@0: if (f) { aoqi@0: f->print_as_flag(out); aoqi@0: out->cr(); aoqi@0: } else { aoqi@0: out->print_cr("no such flag '%s'", name); aoqi@0: } aoqi@0: return JNI_OK; aoqi@0: } aoqi@0: aoqi@0: // Table to map operation names to functions. aoqi@0: aoqi@0: // names must be of length <= AttachOperation::name_length_max aoqi@0: static AttachOperationFunctionInfo funcs[] = { aoqi@0: { "agentProperties", get_agent_properties }, aoqi@0: { "datadump", data_dump }, aoqi@0: { "dumpheap", dump_heap }, aoqi@0: { "load", JvmtiExport::load_agent_library }, aoqi@0: { "properties", get_system_properties }, aoqi@0: { "threaddump", thread_dump }, aoqi@0: { "inspectheap", heap_inspection }, aoqi@0: { "setflag", set_flag }, aoqi@0: { "printflag", print_flag }, aoqi@0: { "jcmd", jcmd }, aoqi@0: { NULL, NULL } aoqi@0: }; aoqi@0: aoqi@0: aoqi@0: aoqi@0: // The Attach Listener threads services a queue. It dequeues an operation aoqi@0: // from the queue, examines the operation name (command), and dispatches aoqi@0: // to the corresponding function to perform the operation. aoqi@0: aoqi@0: static void attach_listener_thread_entry(JavaThread* thread, TRAPS) { aoqi@0: os::set_priority(thread, NearMaxPriority); aoqi@0: aoqi@0: thread->record_stack_base_and_size(); aoqi@0: aoqi@0: if (AttachListener::pd_init() != 0) { aoqi@0: return; aoqi@0: } aoqi@0: AttachListener::set_initialized(); aoqi@0: aoqi@0: for (;;) { aoqi@0: AttachOperation* op = AttachListener::dequeue(); aoqi@0: if (op == NULL) { aoqi@0: return; // dequeue failed or shutdown aoqi@0: } aoqi@0: aoqi@0: ResourceMark rm; aoqi@0: bufferedStream st; aoqi@0: jint res = JNI_OK; aoqi@0: aoqi@0: // handle special detachall operation aoqi@0: if (strcmp(op->name(), AttachOperation::detachall_operation_name()) == 0) { aoqi@0: AttachListener::detachall(); aoqi@0: } else { aoqi@0: // find the function to dispatch too aoqi@0: AttachOperationFunctionInfo* info = NULL; aoqi@0: for (int i=0; funcs[i].name != NULL; i++) { aoqi@0: const char* name = funcs[i].name; aoqi@0: assert(strlen(name) <= AttachOperation::name_length_max, "operation <= name_length_max"); aoqi@0: if (strcmp(op->name(), name) == 0) { aoqi@0: info = &(funcs[i]); aoqi@0: break; aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: // check for platform dependent attach operation aoqi@0: if (info == NULL) { aoqi@0: info = AttachListener::pd_find_operation(op->name()); aoqi@0: } aoqi@0: aoqi@0: if (info != NULL) { aoqi@0: // dispatch to the function that implements this operation aoqi@0: res = (info->func)(op, &st); aoqi@0: } else { aoqi@0: st.print("Operation %s not recognized!", op->name()); aoqi@0: res = JNI_ERR; aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: // operation complete - send result and output to client aoqi@0: op->complete(res, &st); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: // Starts the Attach Listener thread aoqi@0: void AttachListener::init() { aoqi@0: EXCEPTION_MARK; aoqi@0: Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK); aoqi@0: instanceKlassHandle klass (THREAD, k); aoqi@0: instanceHandle thread_oop = klass->allocate_instance_handle(CHECK); aoqi@0: aoqi@0: const char thread_name[] = "Attach Listener"; aoqi@0: Handle string = java_lang_String::create_from_str(thread_name, CHECK); aoqi@0: aoqi@0: // Initialize thread_oop to put it into the system threadGroup aoqi@0: Handle thread_group (THREAD, Universe::system_thread_group()); aoqi@0: JavaValue result(T_VOID); aoqi@0: JavaCalls::call_special(&result, thread_oop, aoqi@0: klass, aoqi@0: vmSymbols::object_initializer_name(), aoqi@0: vmSymbols::threadgroup_string_void_signature(), aoqi@0: thread_group, aoqi@0: string, aoqi@0: THREAD); aoqi@0: aoqi@0: if (HAS_PENDING_EXCEPTION) { aoqi@0: tty->print_cr("Exception in VM (AttachListener::init) : "); aoqi@0: java_lang_Throwable::print(PENDING_EXCEPTION, tty); aoqi@0: tty->cr(); aoqi@0: aoqi@0: CLEAR_PENDING_EXCEPTION; aoqi@0: aoqi@0: return; aoqi@0: } aoqi@0: aoqi@0: KlassHandle group(THREAD, SystemDictionary::ThreadGroup_klass()); aoqi@0: JavaCalls::call_special(&result, aoqi@0: thread_group, aoqi@0: group, aoqi@0: vmSymbols::add_method_name(), aoqi@0: vmSymbols::thread_void_signature(), aoqi@0: thread_oop, // ARG 1 aoqi@0: THREAD); aoqi@0: aoqi@0: if (HAS_PENDING_EXCEPTION) { aoqi@0: tty->print_cr("Exception in VM (AttachListener::init) : "); aoqi@0: java_lang_Throwable::print(PENDING_EXCEPTION, tty); aoqi@0: tty->cr(); aoqi@0: aoqi@0: CLEAR_PENDING_EXCEPTION; aoqi@0: aoqi@0: return; aoqi@0: } aoqi@0: aoqi@0: { MutexLocker mu(Threads_lock); aoqi@0: JavaThread* listener_thread = new JavaThread(&attach_listener_thread_entry); aoqi@0: aoqi@0: // Check that thread and osthread were created aoqi@0: if (listener_thread == NULL || listener_thread->osthread() == NULL) { aoqi@0: vm_exit_during_initialization("java.lang.OutOfMemoryError", aoqi@0: "unable to create new native thread"); aoqi@0: } aoqi@0: aoqi@0: java_lang_Thread::set_thread(thread_oop(), listener_thread); aoqi@0: java_lang_Thread::set_daemon(thread_oop()); aoqi@0: aoqi@0: listener_thread->set_threadObj(thread_oop()); aoqi@0: Threads::add(listener_thread); aoqi@0: Thread::start(listener_thread); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: // Performs clean-up tasks on platforms where we can detect that the last aoqi@0: // client has detached aoqi@0: void AttachListener::detachall() { aoqi@0: // call the platform dependent clean-up aoqi@0: pd_detachall(); aoqi@0: }