/*
* 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.
*/
/*
* This source code is provided to illustrate the usage of a given feature
* or technique and has been deliberately simplified. Additional steps
* required for a production-quality application, such as security checks,
* input validation and proper error handling, might not be present in
* this sample code.
*/
/**
* List of Strings to execute at each stop.
*/
/**
* The name of this tool.
*/
}
}
}
}
}
}
}
}
if (fwe instanceof ModificationWatchpointEvent) {
fwe.valueCurrent(),
} else {
}
}
}
if (catchLocation == null) {
} else {
}
}
/*
* These can be very numerous, so be as efficient as possible.
* If we are stopping here, then we will see the normal location
* info printed.
*/
// We are stopping; the name will be shown by the normal mechanism
} else {
// We aren't stopping, show the name
}
}
/*
* These can be very numerous, so be as efficient as possible.
*/
// Either we are not tracing a specific method, or we are
// and we are exitting that method.
// We will be stopping here, so do a newline
}
} else {
}
// We won't be stopping here, so show the method name
}
// In case we want to have a one shot trace exit some day, this
// code disables the request so we don't hit it again.
if (false) {
// This is a one shot deal; we don't want to stop
// here the next time.
}
}
}
return true;
}
// We are tracing a specific method, and this isn't it. Keep going.
return false;
}
public void vmInterrupted() {
t.nextToken(); // get rid of monitor number
executeCommand(t);
}
}
}
new Object [] {threadName,
}
private void printCurrentLocation() {
try {
} catch (IncompatibleThreadStateException exc) {
return;
}
} else {
// Output the current source line, if possible
try {
}
line});
}
}
}
}
}
void help() {
}
/*
* NOTE: this list must be kept sorted in ascending ASCII
* order by element [0]. Ref: isCommand() below.
*
*Command OK when OK when
* name disconnected? readonly?
*------------------------------------
*/
{"!!", "n", "y"},
{"?", "y", "y"},
{"bytecodes", "n", "y"},
{"catch", "y", "n"},
{"class", "n", "y"},
{"classes", "n", "y"},
{"classpath", "n", "y"},
{"clear", "y", "n"},
{"connectors", "y", "y"},
{"cont", "n", "n"},
{"disablegc", "n", "n"},
{"down", "n", "y"},
{"dump", "n", "y"},
{"enablegc", "n", "n"},
{"eval", "n", "y"},
{"exclude", "y", "n"},
{"exit", "y", "y"},
{"extension", "n", "y"},
{"fields", "n", "y"},
{"gc", "n", "n"},
{"help", "y", "y"},
{"ignore", "y", "n"},
{"interrupt", "n", "n"},
{"kill", "n", "n"},
{"lines", "n", "y"},
{"list", "n", "y"},
{"load", "n", "y"},
{"locals", "n", "y"},
{"lock", "n", "n"},
{"memory", "n", "y"},
{"methods", "n", "y"},
{"monitor", "n", "n"},
{"next", "n", "n"},
{"pop", "n", "n"},
{"print", "n", "y"},
{"quit", "y", "y"},
{"read", "y", "y"},
{"redefine", "n", "n"},
{"reenter", "n", "n"},
{"resume", "n", "n"},
{"run", "y", "n"},
{"save", "n", "n"},
{"set", "n", "n"},
{"sourcepath", "y", "y"},
{"step", "n", "n"},
{"stepi", "n", "n"},
{"stop", "y", "n"},
{"suspend", "n", "n"},
{"thread", "n", "y"},
{"threadgroup", "n", "y"},
{"threadgroups", "n", "y"},
{"threadlocks", "n", "y"},
{"threads", "n", "y"},
{"trace", "n", "n"},
{"unmonitor", "n", "n"},
{"untrace", "n", "n"},
{"unwatch", "y", "n"},
{"up", "n", "y"},
{"use", "y", "y"},
{"version", "y", "y"},
{"watch", "y", "n"},
{"where", "n", "y"},
{"wherei", "n", "y"},
};
/*
* Look up the command string in commandList.
* If found, return the index.
* If not found, return index < 0
*/
//Reference: binarySearch() in java/util/Arrays.java
// Adapted for use with String[][0].
int low = 0;
if (compare < 0) {
} else if (compare > 0) {
}
else {
return mid; // key found
}
}
};
/*
* Return true if the command is OK when disconnected.
*/
return false;
}
}
/*
* Return true if the command is OK when readonly.
*/
return false;
}
};
// Normally, prompt for the next command after this one is done
boolean showPrompt = true;
/*
* Anything starting with # is discarded as a no-op or 'comment'.
*/
/*
* Next check for an integer repetition prefix. If found,
* recursively execute cmd that number of times.
*/
try {
while (repeat-- > 0) {
showPrompt = false; // Bypass the printPrompt() below.
}
} catch (NumberFormatException exc) {
}
} else {
/*
* Check for an unknown command
*/
if (commandNumber < 0) {
cmd);
cmd);
} else {
try {
evaluator.commandPrint(t, false);
showPrompt = false; // asynchronous command
evaluator.commandPrint(t, false);
showPrompt = false; // asynchronous command
evaluator.commandSet(t);
showPrompt = false; // asynchronous command
evaluator.commandPrint(t, true);
showPrompt = false; // asynchronous command
evaluator.commandStep(t);
evaluator.commandKill(t);
evaluator.commandWhere(t, false);
evaluator.commandWhere(t, true);
evaluator.commandDown(t);
evaluator.commandLoad(t);
evaluator.commandRun(t);
/*
* Fire up an event handler, if the connection was just
* opened. Since this was done from the run command
* we don't stop the VM on its VM start event (so
* arg 2 is false).
*/
handler = new EventHandler(this, false);
}
evaluator.commandStop(t);
evaluator.commandList(t);
evaluator.commandUse(t);
monitorCommand(t);
unmonitorCommand(t);
evaluator.commandLock(t);
showPrompt = false; // asynchronous command
showPrompt = false; // asynchronous command
showPrompt = false; // asynchronous command
evaluator.commandSave(t);
showPrompt = false; // asynchronous command
evaluator.commandPopFrames(t, false);
evaluator.commandPopFrames(t, true);
readCommand(t);
help();
}
} else {
}
} catch (VMCannotBeModifiedException rovm) {
} catch (UnsupportedOperationException uoe) {
} catch (VMNotConnectedException vmnse) {
cmd);
} catch (Exception e) {
}
}
}
}
if (showPrompt) {
}
}
/*
* Maintain a list of commands to execute each time the VM is suspended.
*/
if (t.hasMoreTokens()) {
++monitorCount;
} else {
}
}
}
if (t.hasMoreTokens()) {
int monNum;
try {
} catch (NumberFormatException exc) {
return;
}
return;
}
}
} else {
}
}
if (t.hasMoreTokens()) {
}
} else {
}
}
/**
* Read and execute a command file. Return true if the file was read
* else false;
*/
try {
if (f.canRead()) {
// Process initial commands.
if (t.hasMoreTokens()) {
executeCommand(t);
}
}
}
} catch (IOException e) {
} finally {
try {
}
}
}
}
/**
* the canonical path passed in is the same as that
* Return null if that file doesn't exist,
* else return the canonical path of that file.
*/
if (!dotInitFile.exists()) {
return null;
}
try {
} catch (IOException ee) {
return null;
}
if (!readCommandFile(dotInitFile)) {
}
}
return myCanonFile;
}
/*
* Connection opened on startup. Start event handler
* immediately, telling it (through arg 2) to stop on the
* VM start event.
*/
this.handler = new EventHandler(this, true);
}
try {
/*
* Read start up files. This mimics the behavior
* of gdb which will read both ~/.gdbinit and then
* ./.gdbinit if they exist. We have the twist that
* we allow two different names, so we do this:
* if ~/jdb.ini exists,
* read it
* else if ~/.jdbrc exists,
* read it
*
* if ./jdb.ini exists,
* if it hasn't been read, read it
* It could have been read above because ~ == .
* or because of symlinks, ...
* else if ./jdbrx exists
* if it hasn't been read, read it
*/
{
// Doesn't exist, try alternate spelling
}
// Doesn't exist, try alternate spelling
}
}
// Process interactive commands.
while (true) {
ln = "quit";
}
}
if (t.hasMoreTokens()) {
executeCommand(t);
} else {
}
}
} catch (VMDisconnectedException e) {
}
}
private static void usage() {
}
usage();
}
usage();
}
private static boolean supportsSharedMemory() {
continue;
}
return true;
}
}
return false;
}
if (index != -1) {
} else {
return "port=" + address;
}
}
for (int i = 0; i < length; i++) {
return true;
}
}
return false;
}
// Quotes were stripped out for this argument, add 'em back.
if (c == '"') {
}
}
} else {
}
}
boolean launchImmediately = false;
("com.sun.tools.example.debug.tty.TTYResources",
Locale.getDefault());
} else {
try {
} catch (NumberFormatException nfe) {
usageError("dbgtrace flag value must be an integer:",
flagStr);
return;
}
}
usageError("Use java minus X to see");
return;
} else if (
// Standard VM options passed on
// -classpath handled below
// NonStandard options passed on
// Old-style options (These should remain in place as long as
// the standard VM accepts them)
usageError("Classic VM no longer supported.");
return;
// -client must be the first one
// -server must be the first one
usageError("No sourcepath specified.");
return;
}
usageError("No classpath specified.");
return;
}
if (connectSpec != null) {
return;
}
usageError("No attach address specified.");
return;
}
/*
* -attach is shorthand for one of the reference implementation's
* attaching connectors. Use the shared memory attach if it's
* available; otherwise, use sockets. Build a connect
* specification string based on this decision.
*/
if (supportsSharedMemory()) {
connectSpec = "com.sun.jdi.SharedMemoryAttach:name=" +
} else {
}
if (connectSpec != null) {
return;
}
usageError("No attach address specified.");
return;
}
}
/*
* -listen[any] is shorthand for one of the reference implementation's
* listening connectors. Use the shared memory listen if it's
* available; otherwise, use sockets. Build a connect
* specification string based on this decision.
*/
if (supportsSharedMemory()) {
connectSpec = "com.sun.jdi.SharedMemoryListen:";
}
} else {
connectSpec = "com.sun.jdi.SocketListen:";
}
}
launchImmediately = true;
return;
/*
* -connect allows the user to pick the connector
* used in bringing up the target VM. This allows
* use of connectors other than those in the reference
* implementation.
*/
if (connectSpec != null) {
return;
}
usageError("No connect specification.");
return;
}
connectSpec = argv[++i];
usage();
return;
} else {
// Everything from here is part of the command line
}
break;
}
}
/*
* Unless otherwise specified, set the default connect spec.
*/
/*
* Here are examples of jdb command lines and how the options
* are interpreted as arguments to the program being debugged.
* arg1 arg2
* ---- ----
* jdb hello a b a b
* jdb hello "a b" a b
* jdb hello a,b a,b
* jdb hello a, b a, b
* jdb hello "a, b" a, b
* jdb -connect "com.sun.jdi.CommandLineLaunch:main=hello a,b" illegal
* jdb -connect com.sun.jdi.CommandLineLaunch:main=hello "a,b" illegal
* jdb -connect 'com.sun.jdi.CommandLineLaunch:main=hello "a,b"' arg1 = a,b
* jdb -connect 'com.sun.jdi.CommandLineLaunch:main=hello "a b"' arg1 = a b
* jdb -connect 'com.sun.jdi.CommandLineLaunch:main=hello a b' arg1 = a arg2 = b
* jdb -connect 'com.sun.jdi.CommandLineLaunch:main=hello "a," b' arg1 = a, arg2 = b
*/
if (connectSpec == null) {
connectSpec = "com.sun.jdi.CommandLineLaunch:";
}
usageError("Cannot specify command line with connector:",
return;
}
}
usageError("Cannot specify target vm arguments with connector:",
return;
}
}
try {
}
new TTY();
} catch(Exception e) {
}
}
}