use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class MonitorsCommand method tableCommand.
/**
* See {@link MonitorsCommand#helpCommand(String[], PrintStream)} for
* function documentation
*
* @param args
* command args
* @param out
* the output stream
* @throws DDRInteractiveCommandException
*/
private void tableCommand(String[] args, PrintStream out) throws DDRInteractiveCommandException {
FilterOptions filter = FilterOptions.defaultOption();
if (args.length > 2) {
filter = FilterOptions.parseOption(args[2]);
} else if (args.length == 2) {
out.println("No filter specified, defaulting to 'active' monitors.");
} else if (args.length < 2) {
out.println("This command takes one address argument: \"!monitors table <address>\"");
return;
}
try {
StringBuilder builder = new StringBuilder();
long address = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
VoidPointer ptr = VoidPointer.cast(address);
MonitorTableListIterator iterator = new MonitorTableListIterator();
boolean foundTable = false;
while (iterator.hasNext()) {
J9ObjectMonitorPointer objectMonitorPointer = iterator.next();
MonitorTable currentMonitorTable = iterator.currentMonitorTable();
if (currentMonitorTable.getMonitorTableListEntryPointer().equals(ptr)) {
tablePrintHelper(filter, builder, objectMonitorPointer);
foundTable = true;
}
}
out.append(builder);
if (false == foundTable) {
out.append(String.format("Could not find any J9MonitorTableListEntryPointer at address %s\n", ptr.getHexAddress()));
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class RamClassSummaryCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
ClassSummaryHelper classSummaryHelper = new ClassSummaryHelper(preferredOrder);
ClassSegmentIterator classSegmentIterator = new ClassSegmentIterator(vm.classMemorySegments());
while (classSegmentIterator.hasNext()) {
J9ClassPointer classPointer = (J9ClassPointer) classSegmentIterator.next();
numberOfClasses++;
ClassWalker classWalker = new RamClassWalker(classPointer, context);
LinearDumper linearDumper = new LinearDumper();
J9ClassRegionNode allRegionsNode = linearDumper.getAllRegions(classWalker);
classSummaryHelper.addRegionsForClass(allRegionsNode);
}
classSummaryHelper.printStatistics(out);
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class MethodForNameCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
if (args.length == 1) {
String name = args[0];
CommandUtils.dbgPrint(out, String.format("Searching for methods named '%s' in VM=%s...\n", name, J9RASHelper.getVM(DataType.getJ9RASPointer()).getHexAddress()));
int count = dbgGetMethodsForName(out, name);
CommandUtils.dbgPrint(out, String.format("Found %d method(s) named %s\n", count, name));
} else {
throw new DDRInteractiveCommandException(command + ": too " + (args.length < 1 ? "few" : "many") + " arguments. Expected 1");
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class MonitorsCommand method threadCommand.
/**
* Dumps all monitors that are active for the specified J9Thread/J9VMThread/java.lang.Thread
* @param args
* @param out
* @throws DDRInteractiveCommandException
*/
private void threadCommand(String[] args, PrintStream out) throws DDRInteractiveCommandException {
if (args.length < 2) {
out.println("This command takes one address argument: \"!monitors thread <address>\"");
return;
}
try {
long address = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
VoidPointer ptr = VoidPointer.cast(address);
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
J9VMThreadPointer mainThread = vm.mainThread();
J9ThreadLibraryPointer lib = mainThread.osThread().library();
J9PoolPointer pool = lib.thread_pool();
Pool<J9ThreadPointer> threadPool = Pool.fromJ9Pool(pool, J9ThreadPointer.class);
SlotIterator<J9ThreadPointer> poolIterator = threadPool.iterator();
J9ThreadPointer osThreadPtr = null;
while (poolIterator.hasNext()) {
osThreadPtr = poolIterator.next();
// Is there an associated J9VMThread?
J9VMThreadPointer vmThread = J9ThreadHelper.getVMThread(osThreadPtr);
J9ObjectPointer jlThread = null;
if (vmThread.notNull()) {
jlThread = vmThread.threadObject();
if ((null != jlThread) && jlThread.equals(ptr)) {
out.println("Found java/lang/Thread @ " + ptr.getHexAddress());
printMonitorsForJ9VMThread(out, vm, vmThread);
return;
} else if (vmThread.equals(ptr)) {
out.println("Found j9vmthread @ " + ptr.getHexAddress());
printMonitorsForJ9VMThread(out, vm, vmThread);
return;
}
}
if (osThreadPtr.equals(ptr)) {
out.println("Found j9thread @ " + ptr.getHexAddress());
if (vmThread.notNull()) {
printMonitorsForJ9VMThread(out, vm, vmThread);
}
printMonitorsForJ9Thread(out, vm, osThreadPtr);
return;
}
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class RuntimeSettingsCommand method run.
/**
* Run method for !runtimesettings extension.
*
* @param command !runtimesettings
* @param args args passed by !runtimesettings extension.
* @param context Context of current core file.
* @param out PrintStream to print the output to the console.
* @throws DDRInteractiveCommandException
*/
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (0 < args.length) {
out.println("!runtimesettings expects no args. Usage :");
printUsage(out);
return;
}
try {
Long currentSoftmx;
String qualifiedCurrentSoftmx = "";
String initialSoftmx = "not set";
J9RASPointer ras = DataType.getJ9RASPointer();
J9JavaVMPointer vm = J9RASHelper.getVM(ras);
IProcess process = vm.getProcess();
J9DDRImageProcess ddrProcess = new J9DDRImageProcess(process);
String cmdline;
/* Parse the command line of a running program that generated core
* file to get the original -Xsoftmx setting
*/
cmdline = ddrProcess.getCommandLine();
int start = cmdline.indexOf("-Xsoftmx");
int length = "-Xsoftmx".length();
int end = cmdline.indexOf(" ", start);
if (-1 != start) {
/* extract the value from the end of the option */
initialSoftmx = cmdline.substring(start + length, end);
initialSoftmx = initialSoftmx.toUpperCase();
}
currentSoftmx = new Long(GCExtensions.softMx().longValue());
qualifiedCurrentSoftmx = currentSoftmx.toString();
Matcher m = p.matcher(initialSoftmx);
/* if initial softmx value is set on the command line as qualified
* value, print current softmx value in qualified form, otherwise
* print current in byte value
*/
if (m.matches()) {
/* User may add multiple letters after the number on the command
* line, currently GC parser accepts this and simply ignores
* extra letters, so we need to do the same, set initialSoftmx
* to the first match of the pattern
*/
initialSoftmx = m.group(1);
/* convert size in bytes held in currentSoftmx to canonical form */
qualifiedCurrentSoftmx = qualifiedSize(currentSoftmx);
/* If qualifiedSize() returns size in bytes, it could not
* convert the value, so print the initialSoftmx variable in
* bytes
*/
m = p.matcher(qualifiedCurrentSoftmx);
if (!m.matches()) {
initialSoftmx = sizeInBytes(initialSoftmx);
}
} else {
/* InitialSoftmx value has either not been set or is in byte
* form, so print current value as byte form
*/
qualifiedCurrentSoftmx = currentSoftmx.toString();
}
printTableOfEqualSpacedColumns(out, new String[] { "name", "initial value", "current value" }, new String[][] { { "-Xsoftmx", initialSoftmx, qualifiedCurrentSoftmx } });
} catch (DataUnavailable e) {
/* For Z/OS core files, command line is not available */
out.println("COMMANDLINE is not available\n");
} catch (com.ibm.dtfj.image.CorruptDataException e) {
throw new DDRInteractiveCommandException("CorruptDataException occured while getting the commandline from process");
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
Aggregations