use of com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer in project openj9 by eclipse.
the class FindMethodFromPcCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
U8Pointer pc = U8Pointer.cast(address);
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
if (pc.isNull()) {
CommandUtils.dbgPrint(out, "bad or missing PC\n");
return;
}
CommandUtils.dbgPrint(out, "Searching for PC=%s in VM=%s...\n", pc.getHexAddress(), vm.getHexAddress());
J9MethodPointer result = J9JavaVMHelper.getMethodFromPC(vm, pc);
if (!result.isNull()) {
CommandUtils.dbgPrint(out, "!j9method %s %s\n", result.getHexAddress(), J9MethodHelper.getName(result));
CommandUtils.dbgPrint(out, "Bytecode PC offset = %s\n", pc.sub(result.bytecodes()).getHexValue());
} else {
CommandUtils.dbgPrint(out, "Not found\n");
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer in project openj9 by eclipse.
the class JitstackCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (!J9BuildFlags.interp_nativeSupport) {
CommandUtils.dbgPrint(out, "No JIT in this build\n");
return;
}
try {
String[] realArgs = null;
if (args.length != 0) {
realArgs = args[0].split(",");
}
if (args.length == 0 || !((realArgs.length == 3) || (realArgs.length == 4))) {
CommandUtils.dbgPrint(out, "Usage:\n");
CommandUtils.dbgPrint(out, "\t!jitstack thread,sp,pc\n");
CommandUtils.dbgPrint(out, "\t!jitstack thread,sp,pc,els\n");
CommandUtils.dbgPrint(out, "\tUse !jitstackslots instead of !jitstack to see slot values\n");
return;
}
long address = CommandUtils.parsePointer(realArgs[0], J9BuildFlags.env_data64);
J9VMThreadPointer thread = J9VMThreadPointer.cast(address);
StackWalkerUtils.enableVerboseLogging(2, out);
WalkState walkState = new WalkState();
address = CommandUtils.parsePointer(realArgs[1], J9BuildFlags.env_data64);
UDATAPointer sp = UDATAPointer.cast(address);
address = CommandUtils.parsePointer(realArgs[2], J9BuildFlags.env_data64);
U8Pointer pc = U8Pointer.cast(address);
UDATAPointer arg0EA = UDATAPointer.NULL;
J9MethodPointer literals = J9MethodPointer.NULL;
J9VMEntryLocalStoragePointer entryLocalStorage = J9VMEntryLocalStoragePointer.NULL;
if (realArgs.length == 4) {
address = CommandUtils.parsePointer(realArgs[3], J9BuildFlags.env_data64);
entryLocalStorage = J9VMEntryLocalStoragePointer.cast(address);
} else {
entryLocalStorage = thread.entryLocalStorage();
}
walkState.flags = J9_STACKWALK_RECORD_BYTECODE_PC_OFFSET;
walkState.flags |= J9_STACKWALK_START_AT_JIT_FRAME;
if (command.equalsIgnoreCase("!jitstackslots")) {
walkState.flags |= J9_STACKWALK_ITERATE_O_SLOTS;
// 100 is highly arbitrary but basically means "print everything".
// It is used in jextract where the message levels have been copied
// from to begin with, so it should mean we get the same output.
StackWalkerUtils.enableVerboseLogging(100, out);
}
walkState.walkThread = thread;
walkState.callBacks = new BaseStackWalkerCallbacks();
walkState.frameFlags = new UDATA(0);
StackWalkResult result = StackWalker.walkStackFrames(walkState, sp, arg0EA, pc, literals, entryLocalStorage);
if (result != StackWalkResult.NONE) {
out.println("Stack walk result: " + result);
}
StackWalkerUtils.disableVerboseLogging();
out.flush();
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer 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.pointer.generated.J9MethodPointer in project openj9 by eclipse.
the class StackWalkCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
UDATAPointer sp = UDATAPointer.NULL;
UDATAPointer arg0EA = UDATAPointer.NULL;
U8Pointer pc = U8Pointer.NULL;
J9MethodPointer literals = J9MethodPointer.NULL;
J9VMEntryLocalStoragePointer entryLocalStorage = J9VMEntryLocalStoragePointer.NULL;
String[] realArgs = null;
if (args.length != 0) {
realArgs = args[0].split(",");
}
if (args.length == 0 || !((realArgs.length == 1) || (realArgs.length == 5) || (realArgs.length == 6))) {
CommandUtils.dbgPrint(out, "Usage:\n");
CommandUtils.dbgPrint(out, "\t!stack thread\n");
CommandUtils.dbgPrint(out, "\t!stack thread,sp,a0,pc,literals\n");
CommandUtils.dbgPrint(out, "\t!stack thread,sp,a0,pc,literals,els\n");
CommandUtils.dbgPrint(out, "\tUse !stackslots instead of !stack to see slot values\n");
if (J9BuildFlags.interp_nativeSupport) {
CommandUtils.dbgPrint(out, "\tUse !jitstack or !jitstackslots to start the walk at a JIT frame\n");
}
// dbgPrintRegisters(1);
return;
}
long address = CommandUtils.parsePointer(realArgs[0], J9BuildFlags.env_data64);
if (0 == address) {
/* Parse error is captured in CommandUtils.parsePointer method and message is printed */
return;
}
J9VMThreadPointer thread = J9VMThreadPointer.cast(address);
StackWalkerUtils.enableVerboseLogging(3, out);
WalkState walkState = new WalkState();
walkState.flags = J9_STACKWALK_RECORD_BYTECODE_PC_OFFSET;
if (realArgs.length >= 5) {
address = CommandUtils.parsePointer(realArgs[1], J9BuildFlags.env_data64);
sp = UDATAPointer.cast(address);
address = CommandUtils.parsePointer(realArgs[2], J9BuildFlags.env_data64);
arg0EA = UDATAPointer.cast(address);
address = CommandUtils.parsePointer(realArgs[3], J9BuildFlags.env_data64);
pc = U8Pointer.cast(address);
address = CommandUtils.parsePointer(realArgs[4], J9BuildFlags.env_data64);
literals = J9MethodPointer.cast(address);
} else {
sp = thread.sp();
arg0EA = thread.arg0EA();
pc = thread.pc();
literals = thread.literals();
}
if (realArgs.length >= 6) {
address = CommandUtils.parsePointer(realArgs[5], J9BuildFlags.env_data64);
entryLocalStorage = J9VMEntryLocalStoragePointer.cast(address);
} else {
if (J9BuildFlags.interp_nativeSupport) {
entryLocalStorage = thread.entryLocalStorage();
}
}
if (command.equalsIgnoreCase("!stackslots")) {
walkState.flags |= J9_STACKWALK_ITERATE_O_SLOTS;
// 100 is highly arbitrary but basically means "print everything".
// It is used in jextract where the message levels have been copied
// from to begin with, so it should mean we get the same output.
StackWalkerUtils.enableVerboseLogging(100, out);
walkState.callBacks = new BaseStackWalkerCallbacks();
} else {
StackWalkerUtils.enableVerboseLogging(0, out);
walkState.callBacks = new TerseStackWalkerCallbacks();
walkState.flags |= J9_STACKWALK_ITERATE_FRAMES;
}
walkState.walkThread = thread;
StackWalkResult result = StackWalker.walkStackFrames(walkState, sp, arg0EA, pc, literals, entryLocalStorage);
if (result != StackWalkResult.NONE) {
out.println("Stack walk result: " + result);
}
StackWalkerUtils.disableVerboseLogging();
out.flush();
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer in project openj9 by eclipse.
the class VmCheckCommand method verifyClassMethods.
private int verifyClassMethods(J9JavaVMPointer vm, PrintStream out, J9ClassPointer clazz) throws CorruptDataException {
int count = 0;
J9ROMClassPointer romClass = clazz.romClass();
int methodCount = romClass.romMethodCount().intValue();
J9MethodPointer methods = clazz.ramMethods();
boolean isInterfaceClass = J9ROMClassHelper.isInterface(romClass);
J9ConstantPoolPointer ramConstantPool = J9ConstantPoolPointer.cast(clazz.ramConstantPool());
for (int i = 0; i < methodCount; i++) {
J9MethodPointer method = methods.add(i);
J9ROMMethodPointer romMethod = J9MethodHelper.romMethod(method);
boolean methodInVTable = J9ROMMethodHelper.hasVTable(romMethod);
if (!findROMMethodInClass(vm, romClass, romMethod, methodCount)) {
reportError(out, "romMethod=0x%s (ramMethod=0x%s) not found in romClass=0x%s", Long.toHexString(romMethod.getAddress()), Long.toHexString(method.getAddress()), Long.toHexString(romClass.getAddress()));
}
if (!isInterfaceClass && methodInVTable) {
if (!findMethodInVTable(method, clazz)) {
reportError(out, "romMethod=0x%s (ramMethod=0x%s) not found in vTable of ramClass=0x%s", Long.toHexString(romMethod.getAddress()), Long.toHexString(method.getAddress()), Long.toHexString(clazz.getAddress()));
}
}
if (!ramConstantPool.eq(ConstantPoolHelpers.J9_CP_FROM_METHOD(method))) {
reportError(out, "ramConstantPool=0x%s on ramMethod=0x%s not equal to ramConstantPool=0x%s on ramClass=0x%s", Long.toHexString(ConstantPoolHelpers.J9_CP_FROM_METHOD(method).getAddress()), Long.toHexString(method.getAddress()), Long.toHexString(ramConstantPool.getAddress()), Long.toHexString(clazz.getAddress()));
}
count++;
}
return count;
}
Aggregations