use of com.ibm.j9ddr.vm29.types.U16 in project openj9 by eclipse.
the class LocalMapCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
if (args.length != 1) {
CommandUtils.dbgPrint(out, "bad or missing PC\n");
return;
}
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
U8Pointer pc = U8Pointer.cast(address);
CommandUtils.dbgPrint(out, "Searching for PC=%d in VM=%s...\n", pc.longValue(), vm.getHexAddress());
J9MethodPointer localMethod = J9JavaVMHelper.getMethodFromPC(vm, pc);
if (localMethod.notNull()) {
int[] localMap = new int[65536 / 32];
CommandUtils.dbgPrint(out, "Found method %s !j9method %s\n", J9MethodHelper.getName(localMethod), localMethod.getHexAddress());
UDATA offsetPC = new UDATA(pc.sub(U8Pointer.cast(localMethod.bytecodes())));
CommandUtils.dbgPrint(out, "Relative PC = %d\n", offsetPC.longValue());
J9ClassPointer localClass = J9_CLASS_FROM_CP(localMethod.constantPool());
long methodIndex = new UDATA(localMethod.sub(localClass.ramMethods())).longValue();
CommandUtils.dbgPrint(out, "Method index is %d\n", methodIndex);
J9ROMMethodPointer localROMMethod = J9ROMCLASS_ROMMETHODS(localClass.romClass());
while (methodIndex != 0) {
localROMMethod = ROMHelp.nextROMMethod(localROMMethod);
--methodIndex;
}
CommandUtils.dbgPrint(out, "Using ROM method %s\n", localROMMethod.getHexAddress());
U16 tempCount = localROMMethod.tempCount();
U8 argCount = localROMMethod.argCount();
long localCount = tempCount.add(argCount).longValue();
if (localCount > 0) {
int errorCode = LocalMap.j9localmap_LocalBitsForPC(localROMMethod, offsetPC, localMap);
if (errorCode != 0) {
CommandUtils.dbgPrint(out, "Local map failed, error code = %d\n", errorCode);
} else {
int currentDescription = localMap[(int) ((localCount + 31) / 32)];
long descriptionLong = 0;
CommandUtils.dbgPrint(out, "Local map (%d slots mapped): local %d --> ", localCount, localCount - 1);
long bitsRemaining = localCount % 32;
if (bitsRemaining != 0) {
descriptionLong = currentDescription << (32 - bitsRemaining);
currentDescription--;
}
while (localCount != 0) {
if (bitsRemaining == 0) {
descriptionLong = currentDescription;
currentDescription--;
bitsRemaining = 32;
}
CommandUtils.dbgPrint(out, "%d", (descriptionLong & (1 << 32)) != 0 ? 1 : 0);
descriptionLong = descriptionLong << 1;
--bitsRemaining;
--localCount;
}
CommandUtils.dbgPrint(out, " <-- local 0\n");
}
} else {
CommandUtils.dbgPrint(out, "No locals to map\n");
}
} else {
CommandUtils.dbgPrint(out, "Not found\n");
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.types.U16 in project openj9 by eclipse.
the class J9BCUtil method dumpStackMapSlots.
static U8Pointer dumpStackMapSlots(PrintStream out, J9ROMClassPointer classfile, U8Pointer slotData, long slotCount) throws CorruptDataException {
int slotType;
String[] slotTypes = { "top", "int", "float", "double", "long", "null", "uninitialized_this" };
String[] primitiveArrayTypes = { "I", "F", "D", "J", "S", "B", "C", "Z" };
out.print("(");
for (int i = 0; i < slotCount; i++) {
slotType = slotData.at(0).intValue();
slotData = slotData.add(1);
if (slotType <= 0x06) /*FR_STACKMAP_TYPE_INIT_OBJECT*/
{
out.print(slotTypes[slotType]);
} else if (slotType == 0x07) /* CFR_STACKMAP_TYPE_OBJECT */
{
long index = new U16(slotData.at(0)).leftShift(8).add(slotData.at(1)).longValue();
J9ROMConstantPoolItemPointer constantPool = ConstantPoolHelpers.J9_ROM_CP_FROM_ROM_CLASS(classfile);
J9ROMStringRefPointer item = J9ROMStringRefPointer.cast(constantPool.add(index));
J9UTF8Pointer data = item.utf8Data();
String s = J9UTF8Helper.stringValue(data);
if (s.charAt(0) != '[') {
out.print("L");
}
out.print(s);
slotData = slotData.add(2);
} else if (slotType == 0x08) /* CFR_STACKMAP_TYPE_NEW_OBJECT */
{
long index = new U16(slotData.at(0)).leftShift(8).add(slotData.at(1)).longValue();
out.print("this pc:" + index);
slotData = slotData.add(2);
} else {
/* J9-ism: primitive array types start at slotType 9 and arity is really NEXT_U16()+1*/
StringBuffer primitiveType = new StringBuffer("[");
long index = new U16(slotData.at(0)).leftShift(8).add(slotData.at(1)).longValue();
while (index-- > 0) {
primitiveType.append("[");
}
primitiveType.append(primitiveArrayTypes[slotType - 9]);
out.print(primitiveType.toString());
slotData = slotData.add(2);
}
if (i != (slotCount - 1)) {
out.print(", ");
}
}
out.print(")");
return slotData;
}
Aggregations