use of com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer 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.pointer.generated.J9VMThreadPointer in project openj9 by eclipse.
the class DTFJContext method getThreadInfoCache.
public static List<ThreadInfo> getThreadInfoCache() throws CorruptDataException {
if (threadInfoCache == null) {
List<ThreadInfo> localThreadInfoCache = new ArrayList<ThreadInfo>();
J9VMThreadPointer vmThread = DTFJContext.getVm().mainThread();
J9VMThreadPointer firstThread = vmThread;
do {
ThreadInfo info = getJ9State(vmThread);
localThreadInfoCache.add(info);
vmThread = vmThread.linkNext();
} while (!vmThread.eq(firstThread));
threadInfoCache = localThreadInfoCache;
}
return threadInfoCache;
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer in project openj9 by eclipse.
the class J9VMThreadPointerUtil method getJ9State.
// Taken from thrinfo.c getVMThreadStateHelper
// Note that DDR has access to a wrapper for getting information about object monitors
// this should be used as the single point of access for obtaining this information rather
// than local copies of the functionality e.g. monitorPeekTable.
public static ThreadInfo getJ9State(J9VMThreadPointer targetThread) throws CorruptDataException {
final ThreadInfo thrinfo = new ThreadInfo();
if (targetThread.isNull()) {
thrinfo.state = new UDATA(J9VMTHREAD_STATE_UNKNOWN).longValue();
return thrinfo;
}
thrinfo.thread = targetThread;
long vmstate = J9VMTHREAD_STATE_RUNNING;
UDATA publicFlags = targetThread.publicFlags();
J9ThreadPointer j9self = targetThread.osThread();
/* j9self may be NULL if this function is used by RAS on a corrupt VM */
ThreadState j9state = new ThreadState(j9self);
if (publicFlags.anyBitsIn(J9_PUBLIC_FLAGS_THREAD_BLOCKED | J9_PUBLIC_FLAGS_THREAD_WAITING)) {
/* Assert_VMUtil_true(targetThread->blockingEnterObject != NULL); */
thrinfo.lockObject = targetThread.blockingEnterObject();
// use the DDR object monitor wrapper
ObjectMonitor monitor = ObjectMonitor.fromJ9Object(thrinfo.lockObject);
// isInflated
if (monitor.isInflated()) {
if (publicFlags.anyBitsIn(J9_PUBLIC_FLAGS_THREAD_BLOCKED)) {
if (monitor.getOwner().notNull() && !monitor.getOwner().equals(j9self)) {
/*
* The omrthread may be accessing other raw monitors, but
* the vmthread is blocked while the object monitor is
* owned by a competing thread.
*/
vmstate = J9VMTHREAD_STATE_BLOCKED;
thrinfo.rawLock = J9ThreadMonitorPointer.cast(monitor.getInflatedMonitor());
}
} else {
if (j9self.isNull()) {
if (publicFlags.anyBitsIn(J9_PUBLIC_FLAGS_THREAD_TIMED)) {
vmstate = J9VMTHREAD_STATE_WAITING_TIMED;
} else {
vmstate = J9VMTHREAD_STATE_WAITING;
}
thrinfo.rawLock = J9ThreadMonitorPointer.cast(monitor.getInflatedMonitor());
} else if (monitor.getInflatedMonitor().equals(j9state.blocker)) {
vmstate = getInflatedMonitorState(j9self, j9state, thrinfo);
}
/*
* If the omrthread is using a different monitor, it must be for vm access.
* So the vmthread is either not waiting yet or already awakened.
*/
}
} else {
if (monitor.getOwner().notNull() && (!monitor.getOwner().equals(targetThread))) {
/* count = J9_FLATLOCK_COUNT(lockWord); */
/* rawLock = (omrthread_monitor_t)monitorTablePeekMonitor(targetThread->javaVM, lockObject); */
vmstate = J9VMTHREAD_STATE_BLOCKED;
}
}
/*
* targetThread may be blocked attempting to reacquire VM access, after
* succeeding to acquire the object monitor. In this case, the returned
* vmstate depends on includeRawMonitors.
* includeRawMonitors == FALSE: the vmstate is RUNNING.
* includeRawMonitors == TRUE: the vmstate depends on the state of
* the omrthread. e.g. The omrthread may be blocked on publicFlagsMutex.
*/
} else if (publicFlags.anyBitsIn(J9_PUBLIC_FLAGS_THREAD_PARKED)) {
/* if the osthread is not parked, then the thread is runnable */
if (j9self.isNull() || (j9state.flags.anyBitsIn(J9THREAD_FLAG_PARKED))) {
thrinfo.lockObject = targetThread.blockingEnterObject();
if (publicFlags.anyBitsIn(J9_PUBLIC_FLAGS_THREAD_TIMED)) {
vmstate = J9VMTHREAD_STATE_PARKED_TIMED;
} else {
vmstate = J9VMTHREAD_STATE_PARKED;
}
}
} else if (publicFlags.anyBitsIn(J9_PUBLIC_FLAGS_THREAD_SLEEPING)) {
/* if the osthread is not sleeping, then the thread is runnable */
if (j9self.isNull() || (j9state.flags.anyBitsIn(J9THREAD_FLAG_SLEEPING))) {
vmstate = J9VMTHREAD_STATE_SLEEPING;
}
} else {
/* no vmthread flags apply, so go through the omrthread flags */
if (j9self.isNull()) {
vmstate = J9VMTHREAD_STATE_UNKNOWN;
} else if (j9state.flags.anyBitsIn(J9THREAD_FLAG_PARKED)) {
if (j9state.flags.anyBitsIn(J9THREAD_FLAG_TIMER_SET)) {
vmstate = J9VMTHREAD_STATE_PARKED_TIMED;
} else {
vmstate = J9VMTHREAD_STATE_PARKED;
}
} else if (j9state.flags.anyBitsIn(J9THREAD_FLAG_SLEEPING)) {
vmstate = J9VMTHREAD_STATE_SLEEPING;
} else if (j9state.flags.anyBitsIn(J9THREAD_FLAG_DEAD)) {
vmstate = J9VMTHREAD_STATE_DEAD;
}
}
if (J9VMTHREAD_STATE_RUNNING == vmstate) {
/* check if the omrthread is blocked/waiting on a raw monitor */
thrinfo.lockObject = null;
vmstate = getInflatedMonitorState(j9self, j9state, thrinfo);
}
if (thrinfo.rawLock != null) {
if (thrinfo.rawLock.flags().allBitsIn(J9THREAD_MONITOR_OBJECT)) {
thrinfo.lockObject = J9ObjectPointer.cast(thrinfo.rawLock.userData());
}
}
/* j9state was zeroed if j9self is NULL */
if (j9state.flags.anyBitsIn(J9THREAD_FLAG_INTERRUPTED)) {
vmstate |= J9VMTHREAD_STATE_INTERRUPTED;
}
if (j9state.flags.anyBitsIn(J9THREAD_FLAG_SUSPENDED)) {
vmstate |= J9VMTHREAD_STATE_SUSPENDED;
}
if (publicFlags.anyBitsIn(J9_PUBLIC_FLAGS_HALT_THREAD_JAVA_SUSPEND)) {
vmstate |= J9VMTHREAD_STATE_SUSPENDED;
}
thrinfo.state = new UDATA(vmstate).longValue();
return thrinfo;
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer 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.pointer.generated.J9VMThreadPointer in project openj9 by eclipse.
the class WhatIsCommand method runWhatIs.
private void runWhatIs(String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (args.length == 0) {
badOrMissingSearchValue(out);
return;
}
long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
UDATA localSearchValue = new UDATA(address);
if (localSearchValue.eq(0)) {
badOrMissingSearchValue(out);
return;
}
if (searchValue == null || !searchValue.eq(localSearchValue)) {
searchValue = localSearchValue;
} else {
out.println("Skip count now " + (++skipCount) + ". Run !whatis 0 to reset it.");
}
resetFieldData();
long startTime = System.currentTimeMillis();
// Walk from the VM
J9JavaVMPointer vm = null;
try {
vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException("Couldn't get VM", e);
}
boolean found = walkStructuresFrom(vm);
// Walk from each VM thread
if (!found) {
try {
J9VMThreadPointer mainThread = vm.mainThread();
List<J9VMThreadPointer> threads = new LinkedList<J9VMThreadPointer>();
if (mainThread.notNull()) {
J9VMThreadPointer threadCursor = vm.mainThread();
do {
threads.add(threadCursor);
threadCursor = threadCursor.linkNext();
} while (!threadCursor.eq(mainThread) && !found);
/* Walk the thread list backwards so we will find the match next to the closest thread (prevents walkStructures from doing anything useful with the linkNext list) */
Collections.reverse(threads);
for (J9VMThreadPointer thisThread : threads) {
found = walkStructuresFrom(thisThread);
if (found) {
break;
}
}
}
} catch (CorruptDataException e) {
out.println("CDE walking thread list.");
e.printStackTrace(out);
}
}
// Walk from each class
if (!found) {
try {
GCClassLoaderIterator it = GCClassLoaderIterator.from();
OUTER: while (it.hasNext()) {
J9ClassLoaderPointer loader = it.next();
Iterator<J9ClassPointer> classIt = ClassIterator.fromJ9Classloader(loader);
while (classIt.hasNext()) {
J9ClassPointer clazz = classIt.next();
found = walkStructuresFrom(clazz);
if (found) {
break OUTER;
}
}
}
} catch (CorruptDataException e) {
out.println("CDE walking classes.");
e.printStackTrace(out);
}
}
long stopTime = System.currentTimeMillis();
if (found) {
out.println("Match found");
} else {
out.println("No match found");
if (closestAboveStack != null) {
out.print("Closest above was: ");
closestAboveStack.dump(out);
out.print(" at " + closestAbove.getHexValue());
out.println();
} else {
out.println("No values found above search value");
}
if (closestBelowStack != null) {
out.print("Closest below was: ");
closestBelowStack.dump(out);
out.print(" at " + closestBelow.getHexValue());
out.println();
} else {
out.println("No values found below search value");
}
if (shortestHammingDistanceStack != null) {
out.print("Value with shortest hamming distance (fewest single-bit changes required) was: ");
shortestHammingDistanceStack.dump(out);
out.print(" at " + shortestHammingDistance.getHexValue());
out.print(". Hamming distance = " + hammingDistance);
out.println();
}
/* Reset search value - so if someone reruns the same (unsuccessful) search again it won't set skipCount to 1 */
searchValue = null;
}
out.println("Searched " + fieldCount + " fields to a depth of " + maxDepth + " in " + (stopTime - startTime) + " ms");
resetFieldData();
}
Aggregations