comparison src/share/vm/services/attachListener.cpp @ 4133:3b688d6ff3d0

7104647: Adding a diagnostic command framework Reviewed-by: phh, dcubed
author fparain
date Wed, 14 Dec 2011 04:30:57 -0800
parents 1d1603768966
children 4f25538b54c9
comparison
equal deleted inserted replaced
4131:e9b91fd07263 4133:3b688d6ff3d0
32 #include "runtime/globals.hpp" 32 #include "runtime/globals.hpp"
33 #include "runtime/java.hpp" 33 #include "runtime/java.hpp"
34 #include "runtime/javaCalls.hpp" 34 #include "runtime/javaCalls.hpp"
35 #include "runtime/os.hpp" 35 #include "runtime/os.hpp"
36 #include "services/attachListener.hpp" 36 #include "services/attachListener.hpp"
37 #include "services/diagnosticCommand.hpp"
37 #include "services/heapDumper.hpp" 38 #include "services/heapDumper.hpp"
38 39
39 volatile bool AttachListener::_initialized; 40 volatile bool AttachListener::_initialized;
40 41
41 // Implementation of "properties" command. 42 // Implementation of "properties" command.
143 144
144 // Deadlock detection 145 // Deadlock detection
145 VM_FindDeadlocks op3(out); 146 VM_FindDeadlocks op3(out);
146 VMThread::execute(&op3); 147 VMThread::execute(&op3);
147 148
149 return JNI_OK;
150 }
151
152 // A jcmd attach operation request was received, which will now
153 // dispatch to the diagnostic commands used for serviceability functions.
154 static jint jcmd(AttachOperation* op, outputStream* out) {
155 Thread* THREAD = Thread::current();
156 // All the supplied jcmd arguments are stored as a single
157 // string (op->arg(0)). This is parsed by the Dcmd framework.
158 DCmd::parse_and_execute(out, op->arg(0), ' ', THREAD);
159 if (HAS_PENDING_EXCEPTION) {
160 java_lang_Throwable::print(PENDING_EXCEPTION, out);
161 CLEAR_PENDING_EXCEPTION;
162 // The exception has been printed on the output stream
163 // If the JVM returns JNI_ERR, the attachAPI throws a generic I/O
164 // exception and the content of the output stream is not processed.
165 // By returning JNI_OK, the exception will be displayed on the client side
166 }
148 return JNI_OK; 167 return JNI_OK;
149 } 168 }
150 169
151 #ifndef SERVICES_KERNEL // Heap dumping not supported 170 #ifndef SERVICES_KERNEL // Heap dumping not supported
152 // Implementation of "dumpheap" command. 171 // Implementation of "dumpheap" command.
364 { "properties", get_system_properties }, 383 { "properties", get_system_properties },
365 { "threaddump", thread_dump }, 384 { "threaddump", thread_dump },
366 { "inspectheap", heap_inspection }, 385 { "inspectheap", heap_inspection },
367 { "setflag", set_flag }, 386 { "setflag", set_flag },
368 { "printflag", print_flag }, 387 { "printflag", print_flag },
388 { "jcmd", jcmd },
369 { NULL, NULL } 389 { NULL, NULL }
370 }; 390 };
371 391
372 392
373 393