/*
* 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
/*
* The HotSpot implementation of com.sun.tools.attach.VirtualMachine.
*/
}
/*
* Load agent library
* If isAbsolute is true then the agent library is the absolute path
* to the library and thus will not be expanded in the target VM.
* if isAbsolute is false then the agent library is just a library
* name and it will be expended in the target VM.
*/
{
options);
try {
if (result != 0) {
}
} finally {
}
}
/*
* Load agent library - library name will be expanded in target VM
*/
{
}
/*
* Load agent - absolute path of library provided to target VM
*/
{
}
/*
* Load JPLIS agent which will load the agent JAR file and invoke
* the agentmain method.
*/
{
}
try {
} catch (AgentLoadException x) {
throw new InternalError("instrument library is missing in target VM");
} catch (AgentInitializationException x) {
/*
* Translate interesting errors into the right exception and
* message (FIXME: create a better interface to the instrument
* implementation so this isn't necessary)
*/
int rc = x.returnValue();
switch (rc) {
case JNI_ENOMEM:
throw new AgentLoadException("Insuffient memory");
case ATTACH_ERROR_BADJAR:
throw new AgentLoadException("Agent JAR not found or no Agent-Class attribute");
case ATTACH_ERROR_NOTONCP:
throw new AgentLoadException("Unable to add JAR file to system class path");
case ATTACH_ERROR_STARTFAIL:
throw new AgentInitializationException("Agent JAR loaded but agent failed to initialize");
default :
}
}
}
/*
* The possible errors returned by JPLIS's agentmain
*/
/*
* Send "properties" command to target VM
*/
try {
} finally {
}
return props;
}
try {
} finally {
}
return props;
}
// --- HotSpot specific methods ---
// same as SIGQUIT
}
// Remote ctrl-break. The output of the ctrl-break actions can
// be read from the input stream.
}
// Remote heap dump. The output (error message) can be read from the
// returned input stream.
}
// Heap histogram (heap inspection in HotSpot)
}
// set JVM command line flag
}
// print command line flag
}
}
// -- Supporting methods
/*
* Execute the given command in the target VM - specific platform
* implementation must implement this.
*/
throws AgentLoadException, IOException;
/*
* Convenience method for simple commands
*/
try {
} catch (AgentLoadException x) {
throw new InternalError("Should not get here");
}
}
/*
* Utility method to read an 'int' from the input stream. Ideally
* we should be using java.util.Scanner here but this implementation
* guarantees not to read ahead.
*/
// read to \n or EOF
int n;
byte buf[] = new byte[1];
do {
if (n > 0) {
char c = (char)buf[0];
if (c == '\n') {
break; // EOL found
} else {
}
}
} while (n > 0);
throw new IOException("Premature EOF");
}
int value;
try {
} catch (NumberFormatException x) {
throw new IOException("Non-numeric value found - int expected");
}
return value;
}
// -- attach timeout support
private volatile long attachTimeout;
/*
* Return attach timeout based on the value of the sun.tools.attach.attachTimeout
* property, or the default timeout if the property is not set to a positive
* value.
*/
long attachTimeout() {
if (attachTimeout == 0) {
synchronized(this) {
if (attachTimeout == 0) {
try {
String s =
} catch (SecurityException se) {
} catch (NumberFormatException ne) {
}
if (attachTimeout <= 0) {
}
}
}
}
return attachTimeout;
}
}