use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.
the class J9StaticsCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
if (args.length != 1) {
CommandUtils.dbgPrint(out, "Usage: !j9statics <classAddress>\n");
return;
}
long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
J9ClassPointer ramClass = J9ClassPointer.cast(address);
J9ROMClassPointer romClass = ramClass.romClass();
J9UTF8Pointer className = romClass.className();
CommandUtils.dbgPrint(out, "Static fields in %s:\n", J9UTF8Helper.stringValue(className));
Iterator<J9ObjectFieldOffset> ofoIterator = J9ObjectFieldOffsetIterator.J9ObjectFieldOffsetIteratorFor(ramClass, J9ClassHelper.superclass(ramClass), new U32(J9ROMFieldOffsetWalkState.J9VM_FIELD_OFFSET_WALK_INCLUDE_STATIC));
while (ofoIterator.hasNext()) {
J9ObjectFieldOffset fieldOffset = ofoIterator.next();
J9ROMFieldShapePointer field = fieldOffset.getField();
String name = J9ROMFieldShapeHelper.getName(field);
String sig = J9ROMFieldShapeHelper.getSignature(field);
UDATAPointer fieldAddress = ramClass.ramStatics().addOffset(fieldOffset.getOffsetOrAddress());
switch(sig.charAt(0)) {
case 'L':
case '[':
CommandUtils.dbgPrint(out, "\t%s %s %s (!j9romstaticstringfieldshape %s) = !j9object %s\n", fieldAddress.getHexAddress(), name, sig, field.getHexAddress(), fieldAddress.at(0).getHexValue());
break;
case 'D':
DoublePointer doublePointer = DoublePointer.cast(fieldAddress);
CommandUtils.dbgPrint(out, "\t%s %s %s (!j9romstaticdoublefieldshape %s) = %s (%s)\n", fieldAddress.getHexAddress(), name, sig, field.getHexAddress(), doublePointer.getHexValue(), new Double(doublePointer.doubleAt(0)).toString());
break;
case 'F':
FloatPointer floatPointer = FloatPointer.cast(fieldAddress);
CommandUtils.dbgPrint(out, "\t%s %s %s (!j9romstaticsinglefieldshape %s) = %s (%s)\n", fieldAddress.getHexAddress(), name, sig, field.getHexAddress(), floatPointer.getHexValue(), new Float(floatPointer.floatAt(0)).toString());
break;
case 'J':
I64Pointer longPointer = I64Pointer.cast(fieldAddress);
CommandUtils.dbgPrint(out, "\t%s %s %s (!j9romstaticdoublefieldshape %s) = %s (%d)\n", fieldAddress.getHexAddress(), name, sig, field.getHexAddress(), longPointer.getHexValue(), longPointer.at(0).longValue());
break;
case 'I':
I32Pointer intPointer = I32Pointer.cast(fieldAddress);
CommandUtils.dbgPrint(out, "\t%s %s %s (!j9romstaticsinglefieldshape %s) = %s (%d)\n", fieldAddress.getHexAddress(), name, sig, field.getHexAddress(), intPointer.getHexValue(), intPointer.at(0).intValue());
break;
case 'B':
I8Pointer bytePointer = I8Pointer.cast(fieldAddress);
CommandUtils.dbgPrint(out, "\t%s %s %s (!j9romstaticsinglefieldshape %s) = %s (%s)\n", fieldAddress.getHexAddress(), name, sig, field.getHexAddress(), bytePointer.getHexValue(), bytePointer.at(0).byteValue());
break;
case 'S':
I16Pointer shortPointer = I16Pointer.cast(fieldAddress);
CommandUtils.dbgPrint(out, "\t%s %s %s (!j9romstaticsinglefieldshape %s) = %s (%d)\n", fieldAddress.getHexAddress(), name, sig, field.getHexAddress(), shortPointer.getHexValue(), shortPointer.at(0).shortValue());
break;
case 'Z':
BoolPointer booleanPointer = BoolPointer.cast(fieldAddress);
CommandUtils.dbgPrint(out, "\t%s %s %s (!j9romstaticsinglefieldshape %s) = %s (%s)\n", fieldAddress.getHexAddress(), name, sig, field.getHexAddress(), booleanPointer.getHexValue(), booleanPointer.boolAt(0) ? "true" : "false");
break;
default:
CommandUtils.dbgPrint(out, "\t%s %s %s (!j9romstaticsinglefieldshape %s) = %s\n", fieldAddress.getHexAddress(), name, sig, field.getHexAddress(), fieldAddress.at(0).getHexValue());
break;
}
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.
the class J9VTablesCommand method run.
public void run(String command, String[] args, Context context, final PrintStream out) throws DDRInteractiveCommandException {
try {
final J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
J9ClassPointer ramClass;
UDATA vTableSlotCount;
// UDATA jitVTableSlotCount;
UDATAPointer jitVTable = UDATAPointer.NULL;
UDATAPointer vTable;
long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
ramClass = J9ClassPointer.cast(address);
vTable = J9ClassHelper.vTable(ramClass);
vTableSlotCount = vTable.at(0);
if (J9BuildFlags.interp_nativeSupport) {
if (!vm.jitConfig().isNull()) {
jitVTable = UDATAPointer.cast(U8Pointer.cast(ramClass).sub((vTableSlotCount.longValue() + 1) * UDATA.SIZEOF));
// jitVTableSlotCount = vTableSlotCount.sub(1);
}
}
CommandUtils.dbgPrint(out, String.format("VTable for j9class %s (size=%d - 1 for skipped resolve method)\n", ramClass.getHexAddress(), vTableSlotCount.longValue()));
CommandUtils.dbgPrint(out, String.format("\tInterpreted%s\n", (!jitVTable.isNull()) ? "\t\tJitted\n" : ""));
/* First entry in vtable is the vtable count.
* Second entry is the magic method reference.
* Skip both and start from the third element in vTable which is the first virtual method reference.
**/
for (long i = 2; i < vTableSlotCount.longValue() + 1; i++) {
String name = J9MethodHelper.getName(J9MethodPointer.cast(vTable.at(i)));
String intAddr = U8Pointer.cast(vTable.at(i)).getHexAddress();
if (!jitVTable.isNull()) {
String jitAddr = U8Pointer.cast(jitVTable.at(vTableSlotCount.sub(i))).getHexAddress();
CommandUtils.dbgPrint(out, String.format(" %d\t!j9method %s\t%s\t%s\n", i - 1, intAddr, jitAddr, name));
} else {
CommandUtils.dbgPrint(out, String.format(" %d\t!j9method %s\t%s\t\n", i - 1, intAddr, name));
}
}
return;
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.
the class J9ClassShapeCommand method findClassByName.
public static J9ClassPointer[] findClassByName(J9JavaVMPointer vm, String searchClassName) throws DDRInteractiveCommandException {
ArrayList<J9ClassPointer> result = new ArrayList<J9ClassPointer>();
try {
PatternString pattern = new PatternString(searchClassName);
ClassSegmentIterator classSegmentIterator = new ClassSegmentIterator(vm.classMemorySegments());
while (classSegmentIterator.hasNext()) {
J9ClassPointer classPointer = (J9ClassPointer) classSegmentIterator.next();
String javaName = J9ClassHelper.getJavaName(classPointer);
if (pattern.isMatch(javaName)) {
result.add(classPointer);
}
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
return result.toArray(new J9ClassPointer[result.size()]);
}
use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.
the class J9MemTagCommands method printCallsitesTable.
private void printCallsitesTable(Map<String, J9DbgExtMemStats> callSites, final int sortType) throws DDRInteractiveCommandException {
out.println(" total alloc | largest");
out.println(" blocks| bytes | bytes | callsite");
out.println("-------+-------+-------+-------+-------+-------+-------+-------+-------+-------");
if (SORT_TYPE_NAME == sortType || SORT_TYPE_ALLOCSIZE == sortType) {
List<Map.Entry<String, J9DbgExtMemStats>> entries = new LinkedList(callSites.entrySet());
Collections.sort(entries, new Comparator<Map.Entry<String, J9DbgExtMemStats>>() {
public int compare(Entry<String, J9DbgExtMemStats> o1, Entry<String, J9DbgExtMemStats> o2) {
if (SORT_TYPE_NAME == sortType) {
return o1.getKey().compareTo(o2.getKey());
} else {
if (o1.getValue().getTotalBytesAllocated() < o2.getValue().getTotalBytesAllocated())
return 1;
else if (o1.getValue().getTotalBytesAllocated() == o2.getValue().getTotalBytesAllocated()) {
return 0;
} else {
return -1;
}
}
}
});
for (int i = 0; i < entries.size(); i++) {
Entry<String, J9DbgExtMemStats> entry = entries.get(i);
String callSite = entry.getKey();
J9DbgExtMemStats memStat = entry.getValue();
out.println(String.format("%7d %7d %7d %s", memStat.getTotalBlocksAllocated(), memStat.getTotalBytesAllocated(), memStat.getLargestBlockAllocated(), callSite));
}
} else if (SORT_TYPE_DEFAULT == sortType) {
for (Entry<String, J9DbgExtMemStats> entry : callSites.entrySet()) {
String callSite = entry.getKey();
J9DbgExtMemStats memStat = entry.getValue();
out.println(String.format("%7d %7d %7d %s", memStat.getTotalBlocksAllocated(), memStat.getTotalBytesAllocated(), memStat.getLargestBlockAllocated(), callSite));
}
} else {
/**
*/
throw new DDRInteractiveCommandException("Unknown sort type: " + sortType);
}
out.println("-------+-------+-------+-------+-------+-------+-------+-------+-------+-------");
}
use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.
the class J9RegCommand method run.
/**
* Run method for !j9reg extension.
*
* @param command !j9reg
* @param args args passed by !j9reg 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 {
int level = 0;
if (0 == args.length) {
level = 1;
} else if (1 == args.length) {
try {
level = Integer.parseInt(args[0]);
} catch (NumberFormatException e) {
out.println(args[0] + " is not a valid integer. Please try again.");
return;
}
} else {
printUsage(out);
}
J9JavaVMPointer vm;
try {
vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
VMRegMapHelper.printRegisters(vm, level, out);
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException("Failed to get vm address from RAS");
} catch (UnknownArchitectureException uae) {
throw new DDRInteractiveCommandException(uae.getMessage(), uae);
}
}
Aggregations