/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "classfile/javaClasses.hpp"
#include "classfile/systemDictionary.hpp"
#include "gc_implementation/shared/vmGCOperations.hpp"
#include "memory/resourceArea.hpp"
#include "prims/jvmtiExport.hpp"
#include "runtime/arguments.hpp"
#include "runtime/globals.hpp"
#include "runtime/javaCalls.hpp"
#include "services/attachListener.hpp"
#include "services/diagnosticCommand.hpp"
#include "services/heapDumper.hpp"
// Implementation of "properties" command.
//
// Invokes sun.misc.VMSupport.serializePropertiesToByteArray to serialize
// the system properties into a byte array.
if (ik->should_be_initialized()) {
}
return ik();
}
static jint get_properties(AttachOperation* op, outputStream* out, Symbol* serializePropertiesMethod) {
// load sun.misc.VMSupport
if (HAS_PENDING_EXCEPTION) {
return JNI_ERR;
}
// invoke the serializePropertiesToByteArray method
ik,
&args,
THREAD);
if (HAS_PENDING_EXCEPTION) {
return JNI_ERR;
}
// The result should be a [B
// copy the bytes to the output stream
return JNI_OK;
}
// Implementation of "properties" command.
// See also: PrintSystemPropertiesDCmd class
}
// Implementation of "agent_properties" command.
}
// Implementation of "datadump" command.
//
// Raises a SIGBREAK signal so that VM dump threads, does deadlock detection,
// etc. In theory this command should only post a DataDumpRequest to any
// JVMTI environment that has enabled this event. However it's useful to
// trigger the SIGBREAK handler.
if (!ReduceSignalUsage) {
} else {
if (JvmtiExport::should_post_data_dump()) {
}
}
return JNI_OK;
}
// Implementation of "threaddump" command - essentially a remote ctrl-break
// See also: ThreadDumpDCmd class
//
bool print_concurrent_locks = false;
print_concurrent_locks = true;
}
// thread stacks
// JNI global handles
// Deadlock detection
return JNI_OK;
}
// A jcmd attach operation request was received, which will now
// dispatch to the diagnostic commands used for serviceability functions.
// All the supplied jcmd arguments are stored as a single
// string (op->arg(0)). This is parsed by the Dcmd framework.
if (HAS_PENDING_EXCEPTION) {
// The exception has been printed on the output stream
// If the JVM returns JNI_ERR, the attachAPI throws a generic I/O
// exception and the content of the output stream is not processed.
// By returning JNI_OK, the exception will be displayed on the client side
}
return JNI_OK;
}
// Implementation of "dumpheap" command.
// See also: HeapDumpDCmd class
//
// Input arguments :-
// arg0: Name of the dump file
// arg1: "-live" or "-all"
} else {
return JNI_ERR;
}
}
// Request a full GC before heap dump if live_objects_only = true
// This helps reduces the amount of unreachable objects in the dump
// and makes it easier to browse.
if (res == 0) {
} else {
// heap dump failed
} else {
}
}
}
return JNI_OK;
}
// Implementation of "inspectheap" command
// See also: ClassHistogramDCmd class
//
// Input arguments :-
// arg0: "-live" or "-all"
return JNI_ERR;
}
}
VM_GC_HeapInspection heapop(out, live_objects_only /* request full gc */, true /* need_prologue */);
return JNI_OK;
}
// set a boolean global flag using value from AttachOperation
bool value = true;
const char* arg1;
int tmp;
if (n != 1) {
return JNI_ERR;
}
}
if (! res) {
}
}
// set a intx global flag using value from AttachOperation
const char* arg1;
if (n != 1) {
return JNI_ERR;
}
}
if (! res) {
}
}
// set a uintx global flag using value from AttachOperation
const char* arg1;
if (n != 1) {
return JNI_ERR;
}
}
if (! res) {
}
}
// set a uint64_t global flag using value from AttachOperation
const char* arg1;
if (n != 1) {
return JNI_ERR;
}
}
if (! res) {
}
}
// set a string global flag using value from AttachOperation
const char* value;
return JNI_ERR;
}
if (res) {
} else {
}
}
// Implementation of "setflag" command
return JNI_ERR;
}
if (f && f->is_external() && f->is_writeable()) {
if (f->is_bool()) {
} else if (f->is_intx()) {
} else if (f->is_uintx()) {
} else if (f->is_uint64_t()) {
} else if (f->is_ccstr()) {
} else {
return JNI_ERR;
}
} else {
}
}
// Implementation of "printflag" command
// See also: PrintVMFlagsDCmd class
return JNI_ERR;
}
if (f) {
f->print_as_flag(out);
} else {
}
return JNI_OK;
}
// Table to map operation names to functions.
// names must be of length <= AttachOperation::name_length_max
{ "agentProperties", get_agent_properties },
{ "datadump", data_dump },
{ "dumpheap", dump_heap },
{ "properties", get_system_properties },
{ "threaddump", thread_dump },
{ "inspectheap", heap_inspection },
{ "setflag", set_flag },
{ "printflag", print_flag },
{ "jcmd", jcmd },
};
// The Attach Listener threads services a queue. It dequeues an operation
// from the queue, examines the operation name (command), and dispatches
// to the corresponding function to perform the operation.
if (AttachListener::pd_init() != 0) {
return;
}
for (;;) {
return; // dequeue failed or shutdown
}
// handle special detachall operation
} else {
// find the function to dispatch too
break;
}
}
// check for platform dependent attach operation
}
// dispatch to the function that implements this operation
} else {
}
}
// operation complete - send result and output to client
}
}
// Starts the Attach Listener thread
// Initialize thread_oop to put it into the system threadGroup
CHECK);
thread_oop, // ARG 1
CHECK);
// Check that thread and osthread were created
vm_exit_during_initialization("java.lang.OutOfMemoryError",
"unable to create new native thread");
}
}
}
// Performs clean-up tasks on platforms where we can detect that the last
// client has detached
// call the platform dependent clean-up
pd_detachall();
}