4170N/A * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A // These counters are for java.lang.management API support. 0N/A // They are created even if -XX:-UsePerfData is set and in 0N/A // that case, they will be allocated on C heap. 0N/A // Initialize optional support 0N/A // This depends on the heap inspector 3053N/A // Registration of the diagnostic commands 2076N/A // Start the service thread 0N/A // Load and initialize the sun.management.Agent class 0N/A // invoke startAgent method to start the management server 0N/A // if the performance counter is not initialized, 0N/A // then vm initialization failed; simply return. 0N/A // set them to -1 if thread contention monitoring is disabled. 0N/A// Helper function to construct a ThreadInfo object 0N/A // First allocate a ThreadObj object and 0N/A // push the receiver as the first argument 0N/A // initialize the arguments for the ThreadInfo constructor 0N/A // Call ThreadInfo constructor with no locked monitors and synchronizers 0N/A // First allocate a ThreadObj object and 0N/A // push the receiver as the first argument 0N/A // initialize the arguments for the ThreadInfo constructor 0N/A // push the locked monitors and synchronizers in the arguments 0N/A // Call ThreadInfo constructor with locked monitors and synchronizers 0N/A // Sequential search for now. Need to do better optimization later. 0N/A "the object is not an instance of java.lang.management.GarbageCollectorMXBean class",
0N/A "Invalid GC memory manager",
0N/A // Validate input thread IDs 0N/A // throw exception if invalid thread id. 0N/A "Invalid thread ID entry");
0N/A // check if the element of infoArray is of type ThreadInfo class 0N/A "infoArray element type is not ThreadInfo class");
0N/A// Returns a version string and sets major and minor version if 0N/A// the input parameters are non-null. 0N/A// Gets the list of VM monitoring and management optional supports 0N/A// Returns 0 if succeeded; otherwise returns non-zero. 0N/A// Returns a java.lang.String object containing the input arguments to the VM. 0N/A // add a space between each argument 0N/A // Return the list of input arguments passed to the VM 0N/A // and preserve the order that the VM processes. 0N/A // concatenate all jvm_flags 0N/A // append a space if args already contains one or more jvm_flags 0N/A // concatenate all jvm_args 0N/A// Returns an array of java.lang.String object containing the input arguments to the VM. 0N/A// one for each memory pool if obj == null; otherwise returns 0N/A// an array of memory pools for a given memory manager if 0N/A// it is a valid memory manager. 0N/A // Allocate the resulting MemoryPoolMXBean[] object 0N/A // Get all memory pools 0N/A // Get memory pools managed by a given memory manager 0N/A// one for each memory manager if obj == null; otherwise returns 0N/A// an array of memory managers for a given memory pool if 0N/A// it is a valid memory pool. 0N/A // Allocate the resulting MemoryManagerMXBean[] object 0N/A // Get all memory managers 0N/A // Get memory managers for a given memory pool 0N/A// of a given memory pool. 0N/A// of a given memory pool. 0N/A// of a given memory pool after most recent GC. 0N/A// Sets the memory pool sensor for a threshold type 0N/A "Sensor is not an instance of sun.management.Sensor class");
0N/A // have only one sensor for threshold high and low 0N/A // have only one sensor for threshold high and low 0N/A// Sets the threshold of a given memory pool. 0N/A// Returns the previous threshold. 0N/A// pool - the MemoryPoolMXBean object 0N/A// type - threshold type 0N/A// threshold - the new threshold (must not be negative) 0N/A "Invalid threshold value",
0N/A // return and the new threshold is effective for the next GC 0N/A // return and the new threshold is effective for the next GC 0N/A // When the threshold is changed, reevaluate if the low memory 0N/A // detection is enabled. 1988N/A// Gets an array containing the amount of memory allocated on the Java 1988N/A// heap for a set of threads (in bytes). Each element of the array is 1988N/A// the amount of memory allocated for the thread ID specified in the 1988N/A// corresponding entry in the given array of thread IDs; or -1 if the 1988N/A// thread does not exist or has terminated. 1988N/A // Check if threads is null 1988N/A // validate the thread id array 1988N/A // sizeArray must be of the same length as the given array of thread IDs 1988N/A "The length of the given long array does not match the length of " 1988N/A "the given array of thread IDs");
0N/A// the memory usage for the heap or non-heap memory. 0N/A // Calculate the memory usage 0N/A // if any one of the memory pool has undefined init_size or max_size, 1677N/A // In our current implementation, we make sure that all non-heap 1677N/A // pools have defined init and max sizes. Heap pools do not matter, 1677N/A // as we never use total_init and total_max for them. 0N/A// Returns the boolean value of a given attribute. 0N/A// Sets the given boolean attribute and returns the previous value. 0N/A // current implementation only has 1 ext attribute 0N/A // exclude externally visible JavaThreads 0N/A // last flag entry is always NULL, so subtract 1 350N/A // Exclude the locked (diagnostic, experimental) flags 0N/A // Hotspot-specific counters 0N/A// Returns the long value of a given attribute. 0N/A// Gets the value of all attributes specified in the given array 0N/A// and sets the value in the result array. 0N/A// Returns the number of attributes found. 0N/A// Helper function to do thread dump for a specific list of threads 0N/A // First get an array of threadObj handles. 0N/A // A JavaThread may terminate before we get the stack trace. 0N/A // Obtain thread dumps and thread snapshot information 0N/A// Gets an array of ThreadInfo objects. Each element is the ThreadInfo 0N/A// for the thread ID specified in the corresponding entry in 0N/A// the given array of thread IDs; or NULL if the thread does not exist 0N/A// or has terminated. 0N/A// ids - array of thread IDs 0N/A// maxDepth - the maximum depth of stack traces to be dumped: 0N/A// maxDepth == -1 requests to dump entire stack trace. 0N/A// maxDepth == 0 requests no stack trace. 0N/A// infoArray - array of ThreadInfo objects 1988N/A// QQQ - Why does this method return a value instead of void? 0N/A // Check if threads is null 0N/A "Invalid maxDepth", -
1);
0N/A // validate the thread id array 0N/A // validate the ThreadInfo[] parameters 0N/A // infoArray must be of the same length as the given array of thread IDs 0N/A "The length of the given ThreadInfo array does not match the length of the given array of thread IDs", -
1);
0N/A // make sure the AbstractOwnableSynchronizer klass is loaded before taking thread snapshots 0N/A // Must use ThreadDumpResult to store the ThreadSnapshot. 0N/A // GC may occur after the thread snapshots are taken but before 0N/A // this function returns. The threadObj and other oops kept 0N/A // in the ThreadSnapshot are marked and adjusted during GC. 0N/A // no stack trace dumped - do not need to stop the world 0N/A // if the thread does not exist or now it is terminated, 0N/A // create dummy snapshot 0N/A // obtain thread dump with the specific list of threads with stack trace 0N/A false,
/* no locked monitor */ 0N/A false,
/* no locked synchronizers */ 0N/A // and fill with the thread information 0N/A // if the thread does not exist or now it is terminated, set threadinfo to NULL 0N/A // Create java.lang.management.ThreadInfo object 0N/A// Dump thread info for the specified threads. 0N/A// It returns an array of ThreadInfo objects. Each element is the ThreadInfo 0N/A// for the thread ID specified in the corresponding entry in 0N/A// the given array of thread IDs; or NULL if the thread does not exist 0N/A// or has terminated. 0N/A// ids - array of thread IDs; NULL indicates all live threads 0N/A// locked_monitors - if true, dump locked object monitors 0N/A// locked_synchronizers - if true, dump locked JSR-166 synchronizers 0N/A // make sure the AbstractOwnableSynchronizer klass is loaded before taking thread snapshots 0N/A // validate the thread id array 0N/A // obtain thread dump of a specific list of threads 0N/A -
1,
/* entire stack */ 0N/A // obtain thread dump of all threads 0N/A -
1,
/* entire stack */ 0N/A // create the result ThreadInfo[] object 0N/A // if the thread does not exist or now it is terminated, set threadinfo to NULL 0N/A // Create Object[] filled with locked monitors 0N/A // Create int[] filled with the stack depth where a monitor was locked 0N/A // Count the total number of locked monitors 0N/A // Constructs Object[] and int[] to contain the object monitor and the stack depth 0N/A // where the thread locked it 0N/A // Monitor locked via JNI MonitorEnter call doesn't have stack depth info 0N/A // Create Object[] filled with locked JSR-166 synchronizers 0N/A // Create java.lang.management.ThreadInfo object 0N/A// Returns an array of Class objects. 0N/A// Reset statistic. Return true if the requested statistic is reset. 0N/A// Otherwise, return false. 0N/A// obj - specify which instance the statistic associated with to be reset 0N/A// For PEAK_POOL_USAGE stat, obj is required to be a memory pool object. 0N/A// For THREAD_CONTENTION_COUNT and TIME stat, obj is required to be a thread ID. 0N/A// type - the type of statistic to be reset 0N/A // Look for the JavaThread of this given tid 0N/A // reset contention statistics for all threads if tid == 0 0N/A // reset contention statistics for a given thread 0N/A// Returns the fast estimate of CPU time consumed by 0N/A// a given thread (in nanoseconds). 0N/A// If thread_id == 0, return CPU time for the current thread. 0N/A "Invalid thread ID", -
1);
0N/A// Returns the CPU time consumed by a given thread (in nanoseconds). 0N/A// If thread_id == 0, CPU time for the current thread is returned. 0N/A// If user_sys_cpu_time = true, user level and system CPU time of 0N/A// a given thread is returned; otherwise, only user level CPU time 0N/A "Invalid thread ID", -
1);
1988N/A// Gets an array containing the CPU times consumed by a set of threads 1988N/A// (in nanoseconds). Each element of the array is the CPU time for the 1988N/A// thread ID specified in the corresponding entry in the given array 1988N/A// of thread IDs; or -1 if the thread does not exist or has terminated. 1988N/A// If user_sys_cpu_time = true, the sum of user level and system CPU time 1988N/A// for the given thread is returned; otherwise, only user level CPU time 1988N/A // Check if threads is null 1988N/A // validate the thread id array 1988N/A // timeArray must be of the same length as the given array of thread IDs 1988N/A "The length of the given long array does not match the length of " 1988N/A "the given array of thread IDs");
0N/A// Returns a String array of all VM global flag names 0N/A // last flag entry is always NULL, so subtract 1 0N/A // allocate a temp array 350N/A // Exclude the locked (experimental, diagnostic) flags 0N/A // Return array of right length 1067N/A// Utility function used by jmm_GetVMGlobals. Returns false if flag type 1067N/A// can't be determined, true otherwise. If false is returned, then *global 1067N/A// will be incomplete and invalid. 0N/A// Fill globals array of count length with jmmVMGlobal entries 0N/A// specified by names. If names == NULL, fill globals array 0N/A// with all Flags. Return value is number of entries 0N/A// created in globals. 0N/A// If a Flag with a given name in an array element does not 0N/A// exist, globals[i].name will be set to NULL. 0N/A // return the requested globals 0N/A // Make sure we have a String array 0N/A "Array element type is not String class", 0);
0N/A // return all globals if names == NULL 0N/A // last flag entry is always NULL, so subtract 1 350N/A // Exclude the locked (diagnostic, experimental) flags 0N/A "The flag name cannot be null.");
0N/A "Flag does not exist.");
0N/A "This flag is not writeable.");
4088N/A// Called with Threads_lock held 0N/A // exclude externally visible JavaThreads 0N/A // skip if the result array is not big enough 4088N/A// Called without Threads_lock, we can allocate String objects. 0N/A// Fills names with VM internal thread names and times with the corresponding 0N/A// CPU times. If names or times is NULL, a NullPointerException is thrown. 0N/A// If the element type of names is not String, an IllegalArgumentException is 0N/A// If an array is not large enough to hold all the entries, only the entries 0N/A// that fit will be returned. Return value is the number of VM internal 0N/A // Make sure we have a String array 0N/A "Array element type is not String class", 0);
0N/A // no deadlock found and return 0N/A for (
int i = 0; i <
len; i++) {
0N/A// Finds cycles of threads that are deadlocked involved in object monitors 0N/A// and JSR-166 synchronizers. 0N/A// Returns an array of Thread objects which are in deadlock, if any. 0N/A// Otherwise, returns NULL. 0N/A// object_monitors_only - if true, only check object monitors 0N/A// Finds cycles of threads that are deadlocked on monitor locks 0N/A// Returns an array of Thread objects which are in deadlock, if any. 0N/A// Otherwise, returns NULL. 0N/A// Gets the information about GC extension attributes including 0N/A// the name of the attribute, its type, and a short description. 0N/A// mgr - GC memory manager 0N/A// info - caller allocated array of jmmExtAttributeInfo 0N/A// count - number of elements of the info array 0N/A// Returns the number of GC extension attributes filled in the info array; or 0N/A// -1 if info is not big enough 0N/A // All GC memory managers have 1 attribute (number of GC threads) 0N/A// of a given length and return the objArrayOop 0N/A // array must be of the given length 0N/A "The length of the given MemoryUsage array does not match the number of memory pools.", 0);
0N/A // check if the element of array is of type MemoryUsage class 0N/A "The element type is not MemoryUsage class", 0);
0N/A// Gets the statistics of the last GC of a given GC memory manager. 0N/A// obj - GarbageCollectorMXBean object 0N/A// gc_stat - caller allocated jmmGCStat where: 0N/A// a. before_gc_usage - array of MemoryUsage objects 0N/A// b. after_gc_usage - array of MemoryUsage objects 0N/A// c. gc_ext_attributes_values_size is set to the 0N/A// gc_ext_attribute_values array allocated 0N/A// d. gc_ext_attribute_values is a caller allocated array of jvalue. 0N/A// gc_index == 0 indicates no GC statistics available 0N/A// before_gc_usage and after_gc_usage - filled with per memory pool 0N/A// before and after GC usage in the same order as the memory pools 0N/A// returned by GetMemoryPools for a given GC memory manager. 0N/A// num_gc_ext_attributes indicates the number of elements in 0N/A// the gc_ext_attribute_values array is filled; or 0N/A// -1 if the gc_ext_attributes_values array is not big enough 0N/A // Get the GCMemoryManager 0N/A // Make a copy of the last GC statistics 0N/A // GC may occur while constructing the last GC information 0N/A // Current implementation does not have GC extension attributes 0N/A // Fill the arrays of MemoryUsage objects with before and after GC 0N/A // per pool memory usage 0N/A // If max size == 0, this pool is a survivor space. 0N/A // Set max size = -1 since the pools will be swapped after GC. 0N/A // Current implementation only has 1 attribute (number of GC threads) 0N/A// Dump heap - Returns 0 if succeeds. 0N/A "Output file name cannot be null.", -
1);
0N/A "Output file name cannot be null.", -
1);
2976N/A // Make sure we have a String array 2976N/A "Array element type is not String class");
2976N/A "Command name cannot be null.");
2976N/A "Command name cannot be null.");
2976N/A "Unknown diagnostic command");
2976N/A "Command line cannot be null.");
2976N/A "Command line content cannot be null.");
2976N/A "Unknown diagnostic command");
2976N/A "Command line cannot be null.");
2976N/A "Command line content cannot be null.");