if (!suspendedThreads.containsKey(currentSuspendedThread)) {
iceLogger.log(Level.INFO, "The current thread is no longer suspended. Change to another thread.");
return;
}
SuspensionState suspension = suspendedThreads.get(currentSuspendedThread);
// Get first word from info.
StringTokenizer tokenizer = new StringTokenizer(info);
try {
String firstWord = tokenizer.nextToken();
String action = firstWord.toLowerCase();
// :show function
if (action.equals("function")) {
// Show the name of the suspended function.
logInfo(" " + suspension.getFunctionName());
} else
// :show argnames or :show argtypes
if (action.equals("argnames") || action.equals("argtypes")) {
// Display the argument names/types
String[] argNames = suspension.getArgNames();
String[] argTypes = suspension.getArgTypes();
if (argNames.length == 0) {
logInfo(" " + suspension.getFunctionName() + " has no arguments.");
} else {
for (int i = 0; i < argNames.length; ++i) {
logInfo(" " + argNames[i] + " - " + argTypes[i]);
}
}
} else
// :show stack [expanded]
if (action.equals("stack")) {
// Show the suspended call stack.
// By default this is limited to only showing generated CAL functions.
// Specifying expanded shows everything in the suspended call stack.
try {
String d = tokenizer.nextToken().toLowerCase();
if (d.equals("expanded")) {
StackTraceElement[] stackTrace = suspension.getStackTrace();
for (int i = 0; i < stackTrace.length; ++i) {
logInfo(stackTrace[i].toString());
}
} else {
iceLogger.log (Level.INFO, "Unrecognized directive: " + d);
}
} catch (NoSuchElementException e) {
// There were no tokens after 'stack' so do the default behaviour.
StackTraceElement[] stackTrace = suspension.getStackTrace();
for (int i = 0; i < stackTrace.length; ++i) {
StackTraceElement ste = stackTrace[i];
if (ste.getClassName().indexOf("cal_") >= 0) {
logInfo(stackTrace[i].toString());
}
}
}
} else {
// :show <argument name>
// Determine which argument and show the name, type, and value.
String[] argNames = suspension.getArgNames();
CalValue[] argValues = suspension.getArgValues();
String[] argTypes = suspension.getArgTypes();
for (int i = 0; i < argNames.length; ++i) {
if (argNames[i].equals(firstWord)) {
logInfo(" " + argNames[i] + " - " + argTypes[i] + " - " + DebugSupport.showInternal(argValues[i]));
return;