/*
* 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.
*/
class Commands {
abstract class AsyncExecution {
abstract void action();
AsyncExecution() {
execute();
}
void execute() {
/*
* Save current thread and stack frame. (BugId 4296031)
*/
public void run() {
try {
action();
} catch (UnsupportedOperationException uoe) {
//(BugId 4453329)
} catch (Exception e) {
e.getMessage());
} finally {
/*
* This was an asynchronous command. Events may have been
* processed while it was running. Restore the thread and
* stack frame the user was looking at. (BugId 4296031)
*/
if (threadInfo != null) {
try {
} catch (IncompatibleThreadStateException e) {
} catch (ArrayIndexOutOfBoundsException e) {
}
}
}
}
};
}
}
Commands() {
}
try {
return threadInfo.getCurrentFrame();
}
};
}
} catch (InvocationException ie) {
} else {
String s;
try {
} catch (MissingResourceException mex) {
}
}
}
return result;
}
try {
} catch (ParseException e) {
} else {
String s;
try {
} catch (MissingResourceException mex) {
s = e.toString();
}
}
}
return valStr;
}
if (threadInfo == null) {
}
return threadInfo;
}
// output param types except for the last
}
if (lastParam >= 0) {
// output the last param
// lastParam is an array. Replace the [] with ...
} else {
}
}
}
}
//no current value and no default.
"Connector required argument nodefault" :
} else {
"Connector required argument default" :
"Connector argument default",
}
}
}
}
void commandClasses() {
}
}
if (!t.hasMoreTokens()) {
return;
}
boolean showAll = false;
if (t.hasMoreTokens()) {
showAll = true;
} else {
return;
}
}
return;
}
while (superclass != null) {
}
}
}
}
} else if (type instanceof InterfaceType) {
}
}
}
}
} else { // array type
}
}
if (!t.hasMoreTokens()) {
return;
}
}
} else {
}
}
if (!t.hasMoreTokens()) {
return;
}
String s;
} else {
}
fieldsList.append(s);
}
} else {
}
}
int maxIdLength = 0;
int maxNameLength = 0;
while (threadIter.hasNext()) {
}
while (threadIter.hasNext()) {
continue;
}
// Note any thread group changes
}
/*
* Do a bit of filling with whitespace to get thread ID
* and thread names to line up in the listing, and also
* allow for proper localization. This also works for
* very long thread names, at the possible cost of lines
* being wrapped by the display device.
*/
}
}
/*
* Select the output format to use based on thread status
* and breakpoint.
*/
if (thr.isAtBreakpoint()) {
statusFormat = "Thread description name unknownStatus BP";
} else {
statusFormat = "Thread description name unknownStatus";
}
break;
if (thr.isAtBreakpoint()) {
statusFormat = "Thread description name zombieStatus BP";
} else {
statusFormat = "Thread description name zombieStatus";
}
break;
if (thr.isAtBreakpoint()) {
statusFormat = "Thread description name runningStatus BP";
} else {
statusFormat = "Thread description name runningStatus";
}
break;
if (thr.isAtBreakpoint()) {
statusFormat = "Thread description name sleepingStatus BP";
} else {
statusFormat = "Thread description name sleepingStatus";
}
break;
if (thr.isAtBreakpoint()) {
statusFormat = "Thread description name waitingStatus BP";
} else {
statusFormat = "Thread description name waitingStatus";
}
break;
if (thr.isAtBreakpoint()) {
statusFormat = "Thread description name condWaitstatus BP";
} else {
statusFormat = "Thread description name condWaitstatus";
}
break;
default:
}
nameBuffer.toString()});
}
}
if (!t.hasMoreTokens()) {
return;
}
} else {
}
}
void commandThreadGroups() {
int cnt = 0;
++cnt;
}
}
if (!t.hasMoreTokens()) {
return;
}
if (threadInfo != null) {
}
}
if (!t.hasMoreTokens()) {
return;
}
} else {
}
}
/*
* The 'run' command makes little sense in a
* that doesn't support restarts or multiple VMs. However,
* this is an attempt to emulate the behavior of the old
* JDB as much as possible. For new users and implementations
* it is much more straightforward to launch immedidately
* with the -launch option.
*/
if (!connection.isLaunch()) {
if (!t.hasMoreTokens()) {
commandCont();
} else {
}
return;
}
if (connection.isOpen()) {
return;
}
/*
* Set the main class and any arguments. Note that this will work
* only with the standard launcher, "com.sun.jdi.CommandLineLauncher"
*/
if (t.hasMoreTokens()) {
if (!argsSet) {
return;
}
} else {
return;
}
}
/*
* Launch the VM.
*/
connection.open();
}
}
}
return list;
}
if (!t.hasMoreTokens()) {
} else {
while (t.hasMoreTokens()) {
if (threadInfo != null) {
}
}
}
}
if (!t.hasMoreTokens()) {
} else {
while (t.hasMoreTokens()) {
if (threadInfo != null) {
}
}
}
}
void commandCont() {
return;
}
}
/*
* A previous step may not have completed on this thread;
* if so, it gets removed here.
*/
break;
}
}
}
/* step
*
*/
if (threadInfo == null) {
return;
}
int depth;
if (t.hasMoreTokens() &&
} else {
}
}
// We want just the next step event and no others
}
/* stepi
* step instruction.
*/
void commandStepi() {
if (threadInfo == null) {
return;
}
// We want just the next step event and no others
}
void commandNext() {
if (threadInfo == null) {
return;
}
// We want just the next step event and no others
}
if (!t.hasMoreTokens()) {
return;
}
try {
} catch (InvalidTypeException e) {
}
} else {
}
}
final StringTokenizer tokenizer) {
new AsyncExecution() {
void action() {
}
};
}
if (!t.hasMoreTokens()) {
return;
}
if (threadInfo != null) {
return;
}
}
void listCaughtExceptions() {
boolean noExceptions = true;
// Print a listing of the catch patterns currently in place
if (spec instanceof ExceptionSpec) {
if (noExceptions) {
noExceptions = false;
}
}
}
if (noExceptions) {
}
}
boolean notifyCaught = false;
boolean notifyUncaught = false;
notifyCaught = false;
notifyUncaught = true;
notifyCaught = true;
notifyUncaught = false;
notifyCaught = true;
notifyUncaught = true;
} else {
/*
* Handle the same as "all" for backward
* compatibility with existing .jdbrc files.
*
* Insert an "all" and take the current token as the
* intended classPattern
*
*/
notifyCaught = true;
notifyUncaught = true;
}
classPattern = t.nextToken();
}
try {
} catch (ClassNotFoundException exc) {
}
}
return spec;
}
if (!t.hasMoreTokens()) {
} else {
} else {
}
}
}
if (!t.hasMoreTokens()) {
} else {
} else {
}
}
}
}
if (threadInfo == null) {
return;
}
int nLevels = 1;
if (t.hasMoreTokens()) {
int i;
try {
nf.setParseIntegerOnly(true);
i = n.intValue();
i = 0;
}
if (i <= 0) {
return;
}
nLevels = i;
}
try {
} catch (IncompatibleThreadStateException e) {
} catch (ArrayIndexOutOfBoundsException e) {
}
}
if (threadInfo == null) {
return;
}
int nLevels = 1;
if (t.hasMoreTokens()) {
int i;
try {
nf.setParseIntegerOnly(true);
i = n.intValue();
i = 0;
}
if (i <= 0) {
return;
}
nLevels = i;
}
try {
} catch (IncompatibleThreadStateException e) {
} catch (ArrayIndexOutOfBoundsException e) {
}
}
try {
} catch (IncompatibleThreadStateException e) {
return;
}
} else {
}
}
}
long pc = -1;
if (showPC) {
}
} else if (lineNumber != -1) {
try {
} catch (AbsentInformationException e) {
}
}
if (pc != -1) {
} else {
methodInfo});
}
}
if (!t.hasMoreTokens()) {
if (threadInfo == null) {
return;
}
} else {
}
} else {
if (threadInfo != null) {
}
}
}
}
if (!t.hasMoreTokens()) {
if (threadInfo == null) {
return;
}
} else {
if (threadInfo != null) {
}
}
}
void commandMemory() {
}
void commandGC() {
}
/*
* The next two methods are used by this class and by EventHandler
* to print consistent locations and error messages.
*/
}
void listBreakpoints() {
boolean noBreakpoints = true;
// Print set breakpoints
if (spec instanceof BreakpointSpec) {
if (noBreakpoints) {
noBreakpoints = false;
}
}
}
if (noBreakpoints) {
}
}
}
try {
// We can't use hasMoreTokens here because it will cause any leading
// paren to be lost.
try {
} catch (NoSuchElementException e) {
}
nf.setParseIntegerOnly(true);
int lineNumber = n.intValue();
if (t.hasMoreTokens()) {
return null;
}
try {
} catch (ClassNotFoundException exc) {
}
} else {
// Try stripping method from class.method token.
return null;
}
methodName + rest);
return null;
}
// Trim the parens
while (t.hasMoreTokens()) {
}
}
try {
} catch (MalformedMemberNameException exc) {
} catch (ClassNotFoundException exc) {
}
}
} catch (Exception e) {
return null;
}
return breakpoint;
}
}
}
if (t.hasMoreTokens()) {
}
} else {
return;
}
// Enforcement of "at" vs. "in". The distinction is really
// unnecessary and we should consider not checking for this
// (and making "at" and "in" optional).
return;
}
}
}
if (!t.hasMoreTokens()) {
return;
}
} else {
}
}
}
boolean access = false;
boolean modification = false;
}
access = true;
access = true;
modification = true;
} else {
modification = true;
}
if (dot < 0) {
return list;
}
try {
if (access) {
}
if (modification) {
}
} catch (MalformedMemberNameException exc) {
} catch (ClassNotFoundException exc) {
}
return list;
}
if (!t.hasMoreTokens()) {
return;
}
}
}
if (!t.hasMoreTokens()) {
return;
}
} else {
}
}
}
if (threadInfo != null) {
}
}
/*
* trace [go] methods [thread]
* trace [go] method exit | exits [thread]
*/
if (t.hasMoreTokens()) {
goStr = " go ";
if (t.hasMoreTokens()) {
}
// this is undocumented as it doesn't work right.
if (t.hasMoreTokens()) {
}
}
if (t.hasMoreTokens()) {
if (t.hasMoreTokens()) {
}
try {
} catch (IncompatibleThreadStateException ee) {
return;
}
goStr + "method exit " +
"in effect for",
} else {
goStr + "method exits " +
"in effect");
}
return;
}
} else {
return;
}
}
// Turn on method entry trace
if (t.hasMoreTokens()) {
}
if (threadInfo != null) {
/*
* To keep things simple we want each 'trace' to cancel
* previous traces. However in this case, we don't do that
* to preserve backward compatibility with pre JDK 6.0.
* IE, you can currently do
* trace methods 0x21
* trace methods 0x22
* and you will get xxx traced just on those two threads
* But this feature is kind of broken because if you then do
* untrace 0x21
* it turns off both traces instead of just the one.
* Another bogosity is that if you do
* trace methods
* trace methods
* and you will get two traces.
*/
} else {
}
"methods in effect");
return;
}
return;
}
// trace all by itself.
if (methodTraceCommand != null) {
}
// More trace lines can be added here.
}
// untrace
// untrace methods
if (t.hasMoreTokens()) {
}
}
}
if (threadInfo == null) {
return;
}
try {
} catch (IncompatibleThreadStateException e) {
return;
}
return;
}
return;
}
try {
if (t.hasMoreTokens()) {
// See if token is a line number.
try {
nf.setParseIntegerOnly(true);
// It isn't -- see if it's a method name.
return;
return;
}
}
}
if (lineno < 0) {
} else {
if (sourceLine == null) {
break;
}
if (i == lineno) {
sourceLine});
} else {
sourceLine});
}
}
}
} catch (AbsentInformationException e) {
} catch(FileNotFoundException exc) {
} catch(IOException exc) {
}
}
if (!t.hasMoreTokens()) {
} else {
try {
} else {
}
}
}
}
}
} else {
}
} catch (AbsentInformationException e) {
}
}
}
} else {
}
}
/* Get or set the source file path list. */
if (!t.hasMoreTokens()) {
} else {
/*
* Take the remainder of the command line, minus
* leading or trailing whitespace. Embedded
* whitespace is fine.
*/
}
}
/* Print a stack variable */
}
/* Print all local variables in current stack frame. */
void commandLocals() {
if (threadInfo == null) {
return;
}
try {
throw new AbsentInformationException();
}
return;
}
if (var.isArgument()) {
}
}
if (!var.isArgument()) {
}
}
} catch (AbsentInformationException aie) {
} catch (IncompatibleThreadStateException exc) {
}
}
StringBuffer o = new StringBuffer();
o.append(" ");
o.append(".");
}
}
}
} else if (refType instanceof InterfaceType) {
}
} else {
/* else refType is an instanceof ArrayType */
if (obj instanceof ArrayReference) {
}
}
}
}
}
/* Print a specified reference.
*/
if (!t.hasMoreTokens()) {
return;
}
while (t.hasMoreTokens()) {
!(val instanceof StringReference)) {
} else {
strVal});
}
}
}
}
new AsyncExecution() {
void action() {
doPrint(t, dumpObject);
}
};
}
/*
* Bare bones error checking.
*/
return;
}
/*
* The set command is really just syntactic sugar. Pass it on to the
* print command.
*/
}
if (!t.hasMoreTokens()) {
return;
}
try {
strVal});
}
} else {
}
} else {
}
}
} else {
}
} catch (IncompatibleThreadStateException e) {
}
}
new AsyncExecution() {
void action() {
doLock(t);
}
};
}
try {
} else {
}
}
} else {
}
} catch (IncompatibleThreadStateException e) {
}
}
if (!t.hasMoreTokens()) {
if (threadInfo == null) {
} else {
}
return;
}
}
} else {
if (threadInfo != null) {
}
}
}
if (!t.hasMoreTokens()) {
return;
}
}
} else {
}
}
new AsyncExecution() {
void action() {
doDisableGC(t);
}
};
}
if (!t.hasMoreTokens()) {
return;
}
}
} else {
}
}
new AsyncExecution() {
void action() {
doEnableGC(t);
}
};
}
if (!t.hasMoreTokens()) {
return;
}
if (!t.hasMoreTokens()) {
return;
}
}
} else {
}
}
if (!t.hasMoreTokens()) {
return;
}
if ((value instanceof ObjectReference) &&
} else {
} else {
}
}
}
} else {
new AsyncExecution() {
void action() {
doSave(t);
}
};
}
}
if (!t.hasMoreTokens()) {
return;
}
if (!t.hasMoreTokens()) {
return;
}
// Overloading is not handled here.
// TO DO: handle multiple classes found
} else {
}
return;
}
return;
}
if (!method.isAbstract()) {
break;
}
}
if ((i > 0) && (i % 16 == 0)) {
}
}
}
}
}
}
if (!t.hasMoreTokens()) {
} else {
rest = "";
}
}
}
if (!t.hasMoreTokens()) {
} else {
return;
}
return;
}
if (!t.hasMoreTokens()) {
return;
}
try {
return;
}
= new HashMap<ReferenceType, byte[]>();
try {
exc});
}
}
}
if (t.hasMoreTokens()) {
if (threadInfo == null) {
return;
}
} else {
if (threadInfo == null) {
return;
}
}
try {
if (reenter) {
commandStepi();
}
}
}
if (!t.hasMoreTokens()) {
return;
}
try {
} catch (AbsentInformationException e) {
}
} else {
}
}
new Object [] { debuggerName,
try {
} catch (VMNotConnectedException e) {
}
}
}
}