use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.
the class DumpContendedLoadTable method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (0 != args.length) {
String argument = args[0];
if (argument.equalsIgnoreCase("help")) {
help(out);
return;
}
}
try {
J9JavaVMPointer javaVM = J9RASHelper.getVM(DataType.getJ9RASPointer());
J9HashTablePointer contTable = javaVM.contendedLoadTable();
J9PoolPointer poolPtr = contTable.listNodePool();
Pool<J9ContendedLoadTableEntryPointer> pool = Pool.fromJ9Pool(poolPtr, J9ContendedLoadTableEntryPointer.class);
SlotIterator<J9ContendedLoadTableEntryPointer> poolIterator = pool.iterator();
if (poolIterator.hasNext()) {
out.println("Active class loads:");
while (poolIterator.hasNext()) {
J9ContendedLoadTableEntryPointer entryPointer = poolIterator.next();
String ldStatus = loadingStatusValues.get(entryPointer.status().longValue());
if (null == ldStatus) {
ldStatus = "ILLEGAL VALUE: " + entryPointer.status();
}
J9VMThreadPointer loadingThread = entryPointer.thread();
out.print(String.format("\tClassname: %s;\n\t\tLoader: %s; Loading thread: %s %s\n\t\tStatus: %s; Table entry hash 0x%X\n", entryPointer.className().getCStringAtOffset(0, entryPointer.classNameLength().longValue()), entryPointer.classLoader().formatShortInteractive(), J9VMThreadHelper.getName(loadingThread), loadingThread.formatShortInteractive(), ldStatus, entryPointer.hashValue().longValue()));
}
MonitorIterator iterator = new MonitorIterator(javaVM);
while (iterator.hasNext()) {
Object current = iterator.next();
if (current instanceof J9ThreadMonitorPointer) {
// System Monitor
SystemMonitor monitor = SystemMonitor.fromJ9ThreadMonitor((J9ThreadMonitorPointer) current);
final String monitorName = monitor.getName();
if (monitorName.matches(".*VM class table.*")) {
List<J9ThreadPointer> waitingThreads = monitor.getWaitingThreads();
if (!waitingThreads.isEmpty()) {
out.print("Waiting threads:\n");
for (J9ThreadPointer tp : waitingThreads) {
J9VMThreadPointer vmThread = J9ThreadHelper.getVMThread(tp);
if (vmThread.notNull()) {
out.print(String.format("\t%s\t%s\n", vmThread.formatShortInteractive(), J9VMThreadHelper.getName(vmThread)));
} else {
out.print(String.format("\t%s\t%s\n", tp.formatShortInteractive(), "[osthread]"));
}
}
}
break;
}
}
}
} else {
out.println("No active class loads");
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.
the class DumpRomClassCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
long maps = 0;
if (args.length != 1 && args.length != 2) {
printUsage(out);
return;
}
if (args.length == 2 && args[1].equals("maps")) {
maps |= J9BCTranslationData.BCT_DumpMaps;
}
if (J9BuildFlags.env_littleEndian) {
maps |= J9BCTranslationData.BCT_LittleEndianOutput;
} else {
maps |= J9BCTranslationData.BCT_BigEndianOutput;
}
/* check for name:<name> */
if (args[0].startsWith("name:")) {
long hitCount = 0;
String searchClassName = args[0].substring(args[0].indexOf(':') + 1);
PatternString pattern = new PatternString(searchClassName);
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
ClassSegmentIterator iterator = new ClassSegmentIterator(vm.classMemorySegments());
while (iterator.hasNext()) {
J9ClassPointer classPointer = (J9ClassPointer) iterator.next();
String javaName = J9ClassHelper.getJavaName(classPointer);
if (pattern.isMatch(javaName)) {
hitCount++;
J9ROMClassPointer clazz = classPointer.romClass();
String hexString = clazz.getHexAddress();
out.println(String.format("ROMClass %1$s named %2$s\n", hexString, javaName));
J9BCUtil.j9bcutil_dumpRomClass(out, clazz, maps);
}
}
out.println(String.format("Found %1$d class(es) with name %2$s\n", hitCount, searchClassName));
} else {
/* treat argument as address */
long addr = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
J9ROMClassPointer clazz = J9ROMClassPointer.cast(addr);
J9BCUtil.j9bcutil_dumpRomClass(out, clazz, maps);
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.
the class DumpRomClassLinearCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (args.length == 0)
throw new DDRInteractiveCommandException("This debug extension needs an address argument !dumpromclasslinear <addr>[,n]");
String[] arguments = args[0].split(",");
long addr = Long.decode(arguments[0]);
long nestingThreshold;
if (arguments.length > 1) {
nestingThreshold = Long.decode(arguments[1]);
} else {
nestingThreshold = 1;
}
J9ROMClassPointer clazz = J9ROMClassPointer.cast(addr);
try {
// ROM Class 'org/apache/tomcat/util/buf/MessageBytes' at 0x0DCF9008:
out.println(String.format("ROM Class '%s' at %s", J9UTF8Helper.stringValue(clazz.className()), clazz.getHexAddress()));
ClassWalker classWalker = new RomClassWalker(clazz, context);
new LinearDumper().gatherLayoutInfo(out, classWalker, nestingThreshold);
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.
the class DumpAllRegionsCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
boolean statsRequested = false;
boolean skipReport = false;
if (0 != args.length) {
String argument = args[0];
if (argument.equalsIgnoreCase("help")) {
help(out);
return;
}
statsRequested = argument.equalsIgnoreCase("stats");
skipReport = statsRequested;
}
try {
GCHeapRegionIterator gcHeapRegionIterator = GCHeapRegionIterator.from();
int[] stats = new int[regionTypesString.length];
int total = 0;
String header1, header2, header3;
String footer;
String formatString;
String regionType;
initializeStats(stats);
if (J9BuildFlags.env_data64) {
header1 = "+----------------+----------------+----------------+----------------+--------+----------------+----------------------\n";
header2 = "| region | start | end | subspace | flags | size | region type \n";
header3 = "+----------------+----------------+----------------+----------------+--------+----------------+----------------------\n";
formatString = " %016x %016x %016x %016x %08x %16x %s\n";
footer = "+----------------+----------------+----------------+----------------+--------+----------------+----------------------\n";
} else {
header1 = "+--------+--------+--------+--------+--------+--------+----------------------\n";
header2 = "| region | start | end |subspace| flags | size | region type \n";
header3 = "+--------+--------+--------+--------+--------+--------+----------------------\n";
formatString = " %08x %08x %08x %08x %08x %8x %s\n";
footer = "+--------+--------+--------+--------+--------+--------+----------------------\n";
}
if (!skipReport) {
out.append(header1);
out.append(header2);
out.append(header3);
}
while (gcHeapRegionIterator.hasNext()) {
GCHeapRegionDescriptor heapRegionDescriptor = gcHeapRegionIterator.next();
int index = (int) heapRegionDescriptor.getRegionType();
total += 1;
if (index < regionTypesString.length) {
regionType = regionTypesString[index];
stats[index] += 1;
} else {
regionType = "Unknown";
}
if (!skipReport) {
out.append(String.format(formatString, heapRegionDescriptor.getHeapRegionDescriptorPointer().getAddress(), heapRegionDescriptor.getLowAddress().getAddress(), heapRegionDescriptor.getHighAddress().getAddress(), heapRegionDescriptor.getSubSpace().getAddress(), heapRegionDescriptor.getTypeFlags().longValue(), heapRegionDescriptor.getSize().longValue(), regionType));
}
}
if (!skipReport) {
out.append(footer);
}
if (statsRequested) {
String formatStringStats = " \t%s: %d\n";
for (int i = 0; i < regionTypesString.length; i++) {
if (0 != stats[i]) {
out.append(String.format(formatStringStats, regionTypesString[i], stats[i]));
}
}
out.append(String.format(formatStringStats, "++++ TOTAL", total));
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.
the class DumpAllRomClassLinearCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
long nestingThreashold;
if (args.length > 1) {
throw new DDRInteractiveCommandException("This debug extension accepts none or one argument!");
} else if (args.length == 1) {
nestingThreashold = Long.valueOf(args[0]);
} else {
nestingThreashold = 1;
}
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
if (null != vm) {
out.println();
out.println("!j9javavm " + vm.getHexAddress());
} else {
throw new DDRInteractiveCommandException("Unable to find the VM in core dump!");
}
out.println();
ROMClassesIterator iterator = new ROMClassesIterator(out, vm.classMemorySegments());
while (iterator.hasNext()) {
J9ROMClassPointer classPointer = iterator.next();
out.println("!dumpromclasslinear " + classPointer.getHexAddress());
// ROM Class 'org/apache/tomcat/util/buf/MessageBytes' at 0x0DCF9008:
out.println(String.format("ROM Class '%s' at %s", J9UTF8Helper.stringValue(classPointer.className()), classPointer.getHexAddress()));
out.println();
ClassWalker classWalker = new RomClassWalker(classPointer, context);
new LinearDumper().gatherLayoutInfo(out, classWalker, nestingThreashold);
out.println();
}
} catch (CorruptDataException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
Aggregations