use of com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator in project openj9 by eclipse.
the class CheckVMThreadStacks method print.
@Override
public void print() {
try {
GCVMThreadListIterator vmThreadListIterator = GCVMThreadListIterator.from();
final ScanFormatter formatter = new ScanFormatter(this, "thread stacks");
while (vmThreadListIterator.hasNext()) {
J9VMThreadPointer walkThread = vmThreadListIterator.next();
formatter.section("thread slots", walkThread);
WalkState walkState = new WalkState();
walkState.walkThread = walkThread;
walkState.flags = J9_STACKWALK_ITERATE_O_SLOTS | J9_STACKWALK_DO_NOT_SNIFF_AND_WHACK | J9_STACKWALK_SKIP_INLINES;
walkState.callBacks = new BaseStackWalkerCallbacks() {
public void objectSlotWalkFunction(J9VMThreadPointer walkThread, WalkState walkState, PointerPointer objectSlot, VoidPointer stackAddress) {
try {
formatter.entry(objectSlot.at(0));
} catch (CorruptDataException e) {
}
}
};
StackWalker.walkStackFrames(walkState);
formatter.endSection();
formatter.section("thread stack", walkThread);
dumpStackTrace(walkThread);
formatter.endSection();
}
formatter.end("thread stacks");
} catch (CorruptDataException e) {
// TODO: handle exception
}
}
use of com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator in project openj9 by eclipse.
the class CheckVMThreads method check.
@Override
public void check() {
try {
GCVMThreadListIterator vmThreadListIterator = GCVMThreadListIterator.from();
while (vmThreadListIterator.hasNext()) {
J9VMThreadPointer walkThread = vmThreadListIterator.next();
GCVMThreadIterator vmthreadIterator = GCVMThreadIterator.fromJ9VMThread(walkThread);
while (vmthreadIterator.hasNext()) {
PointerPointer slot = PointerPointer.cast(vmthreadIterator.nextAddress());
if (_engine.checkSlotVMThread(slot, VoidPointer.cast(walkThread), CheckError.check_type_other, vmthreadIterator.getState()) != J9MODRON_SLOT_ITERATOR_OK) {
continue;
}
}
}
} catch (CorruptDataException e) {
// TODO: handle exception
}
}
use of com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator in project openj9 by eclipse.
the class RootScanner method scanThreads.
protected void scanThreads() throws CorruptDataException {
setReachability(Reachability.STRONG);
GCVMThreadListIterator vmThreadListIterator = GCVMThreadListIterator.from();
while (vmThreadListIterator.hasNext()) {
J9VMThreadPointer walkThread = vmThreadListIterator.next();
/* "Inline" the behaviour of GC_VMThreadIterator to distinguish between the types of roots */
GCVMThreadSlotIterator threadSlotIterator = GCVMThreadSlotIterator.fromJ9VMThread(walkThread);
GCVMThreadSlotIterator threadSlotAddressIterator = GCVMThreadSlotIterator.fromJ9VMThread(walkThread);
while (threadSlotIterator.hasNext()) {
doVMThreadSlot(threadSlotIterator.next(), threadSlotAddressIterator.nextAddress());
}
GCVMThreadJNISlotIterator jniSlotIterator = GCVMThreadJNISlotIterator.fromJ9VMThread(walkThread);
GCVMThreadJNISlotIterator jniSlotAddressIterator = GCVMThreadJNISlotIterator.fromJ9VMThread(walkThread);
while (jniSlotIterator.hasNext()) {
doVMThreadJNISlot(jniSlotIterator.next(), jniSlotAddressIterator.nextAddress());
}
if (J9BuildFlags.interp_hotCodeReplacement) {
GCVMThreadMonitorRecordSlotIterator monitorRecordSlotIterator = GCVMThreadMonitorRecordSlotIterator.fromJ9VMThread(walkThread);
GCVMThreadMonitorRecordSlotIterator addressIterator = GCVMThreadMonitorRecordSlotIterator.fromJ9VMThread(walkThread);
while (monitorRecordSlotIterator.hasNext()) {
doVMThreadMonitorRecordSlot(monitorRecordSlotIterator.next(), addressIterator.nextAddress());
}
}
if (_scanStackSlots) {
GCVMThreadStackSlotIterator.scanSlots(walkThread, _stackWalkerCallbacks, _includeStackFrameClassReferences, _trackVisibleStackFrameDepth);
}
}
}
use of com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator in project openj9 by eclipse.
the class FindStackValueCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (0 == args.length) {
out.println("Usage error: Missing stackvalue to search for. See usage.");
printUsage(out);
return;
} else if (1 < args.length) {
out.println("Usage error: Too many stackvalues to search for. See usage.");
printUsage(out);
return;
}
try {
long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
UDATAPointer value = UDATAPointer.cast(address);
GCVMThreadListIterator gcvmThreadListIterator = GCVMThreadListIterator.from();
while (gcvmThreadListIterator.hasNext()) {
J9VMThreadPointer vmThreadPointer = gcvmThreadListIterator.next();
J9JavaStackPointer javaStackPointer = vmThreadPointer.stackObject();
J9JavaStackIterator javaStackIterator = J9JavaStackIterator.fromJ9JavaStack(javaStackPointer);
boolean found = false;
UDATA relativeSP = new UDATA(javaStackPointer.end().sub(vmThreadPointer.sp()));
while (javaStackIterator.hasNext()) {
J9JavaStackPointer stack = javaStackIterator.next();
UDATAPointer localEnd = stack.end().sub(1).add(1);
UDATAPointer search = localEnd.sub(relativeSP);
while (!search.eq(localEnd)) {
if (search.at(0).longValue() == value.longValue()) {
if (!found) {
out.append(String.format("!j9vmthread %s\n", Long.toHexString(vmThreadPointer.getAddress())));
found = true;
}
out.append(String.format("\tFound at %s\n", Long.toHexString(search.getAddress())));
}
search = search.add(1);
}
}
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator in project openj9 by eclipse.
the class MonitorsCommand method j9vmthreadCommand.
/**
* See {@link MonitorsCommand#helpCommand(String[], PrintStream)} for
* function documentation
*
* @param args
* command args
* @param out
* the output stream
* @throws DDRInteractiveCommandException
*/
private void j9vmthreadCommand(String[] args, PrintStream out) throws DDRInteractiveCommandException {
if (args.length < 2) {
out.println("This command takes one address argument: \"!monitors j9vmthread <address>\"");
return;
}
try {
long address = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
VoidPointer ptr = VoidPointer.cast(address);
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
J9VMThreadPointer thread = null;
GCVMThreadListIterator threadIterator = GCVMThreadListIterator.from();
while (threadIterator.hasNext()) {
if (ptr.equals(threadIterator.next())) {
thread = J9VMThreadPointer.cast(ptr);
}
}
if (null == thread) {
throw new DDRInteractiveCommandException(String.format("Could not find any j9vmthread at address %s\n", ptr.getHexAddress()));
}
// Step 1: Print the general info for the VM and native threads:
out.println(String.format("!j9vmthread 0x%08x\t!j9thread 0x%08x\t// %s", thread.getAddress(), thread.osThread().getAddress(), J9VMThreadHelper.getName(thread)));
printMonitorsForJ9VMThread(out, vm, thread);
printMonitorsForJ9Thread(out, vm, thread.osThread());
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
Aggregations