use of com.ibm.j9ddr.vm29.pointer.VoidPointer 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);
}
}
use of com.ibm.j9ddr.vm29.pointer.VoidPointer in project openj9 by eclipse.
the class WalkJ9PoolCommand method walkJ9Pool.
/**
* This method walks through each element in the pool and prints each elements' address.
* Elements can be in the same puddle or different, and this method do not print puddle information.
*
* @param address address of the pool
* @param out print stream
* @throws DDRInteractiveCommandException
*/
private void walkJ9Pool(long address, PrintStream out) throws DDRInteractiveCommandException {
try {
J9PoolPointer j9pool = J9PoolPointer.cast(address);
Pool pool = Pool.fromJ9Pool(j9pool, VoidPointer.class);
SlotIterator<VoidPointer> poolIterator = pool.iterator();
VoidPointer currentElement;
int i = 0;
while (poolIterator.hasNext()) {
currentElement = poolIterator.next();
out.println(String.format("\t[%d]\t=\t%s", i++, currentElement.getHexAddress()));
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException("Either address is not a valid pool address or pool itself is corrupted.");
}
}
use of com.ibm.j9ddr.vm29.pointer.VoidPointer in project openj9 by eclipse.
the class CheckEngine method checkObjectHeap.
public int checkObjectHeap(J9ObjectPointer object, GCHeapRegionDescriptor regionDesc) {
int result = J9MODRON_SLOT_ITERATOR_OK;
boolean isDead = false;
boolean isIndexable = false;
J9ClassPointer clazz = null;
try {
if (ObjectModel.isDeadObject(object)) {
/* this is a hole */
result = checkJ9LinkedFreeHeader(GCHeapLinkedFreeHeader.fromJ9Object(object), regionDesc, _cycle.getCheckFlags());
if (J9MODRON_GCCHK_RC_OK != result) {
CheckError error = new CheckError(object, _cycle, _currentCheck, "Object", result, _cycle.nextErrorCount());
_reporter.report(error);
/* There are some error cases would not prevent further iteration */
if (!((J9MODRON_GCCHK_RC_DEAD_OBJECT_NEXT_IS_NOT_HOLE == result) || (J9MODRON_GCCHK_RC_DEAD_OBJECT_NEXT_IS_NOT_IN_REGION == result) || (J9MODRON_GCCHK_RC_DEAD_OBJECT_NEXT_IS_POINTED_INSIDE == result))) {
_reporter.reportHeapWalkError(error, _lastHeapObject1, _lastHeapObject2, _lastHeapObject3);
return J9MODRON_SLOT_ITERATOR_UNRECOVERABLE_ERROR;
}
}
return J9MODRON_SLOT_ITERATOR_OK;
}
} catch (CorruptDataException e) {
// TODO : cde should be part of the error
CheckError error = new CheckError(object, _cycle, _currentCheck, "Object ", J9MODRON_GCCHK_RC_CORRUPT_DATA_EXCEPTION, _cycle.nextErrorCount());
_reporter.report(error);
return J9MODRON_SLOT_ITERATOR_UNRECOVERABLE_ERROR;
}
try {
// Prefetch this data to make CDE handling easy
isIndexable = ObjectModel.isIndexable(object);
clazz = J9ObjectHelper.clazz(object);
result = checkJ9Object(object, regionDesc, _cycle.getCheckFlags());
} catch (CorruptDataException cde) {
// TODO : cde should be part of the error
CheckError error = new CheckError(object, _cycle, _currentCheck, "Object ", J9MODRON_GCCHK_RC_CORRUPT_DATA_EXCEPTION, _cycle.nextErrorCount());
_reporter.report(error);
return J9MODRON_SLOT_ITERATOR_UNRECOVERABLE_ERROR;
}
if (J9MODRON_GCCHK_RC_OK != result) {
String elementName = isIndexable ? "IObject " : "Object ";
CheckError error = new CheckError(object, _cycle, _currentCheck, elementName, result, _cycle.nextErrorCount());
_reporter.report(error);
/* There are some error cases would not prevent further iteration */
if (!(J9MODRON_GCCHK_RC_CLASS_IS_UNLOADED == result)) {
_reporter.reportHeapWalkError(error, _lastHeapObject1, _lastHeapObject2, _lastHeapObject3);
return J9MODRON_SLOT_ITERATOR_UNRECOVERABLE_ERROR;
} else {
return J9MODRON_SLOT_ITERATOR_OK;
}
}
try {
/* check Ownable Synchronizer Object consistency */
if (needVerifyOwnableSynchronizerConsistency()) {
if (J9Object.OBJECT_HEADER_SHAPE_MIXED == ObjectModel.getClassShape(clazz).intValue() && !J9ClassHelper.classFlags(clazz).bitAnd(J9AccClassOwnableSynchronizer).eq(0)) {
if (ObjectAccessBarrier.isObjectInOwnableSynchronizerList(object).isNull()) {
CheckError error = new CheckError(object, _cycle, _currentCheck, "Object ", J9MODRON_GCCHK_OWNABLE_SYNCHRONIZER_OBJECT_IS_NOT_ATTACHED_TO_THE_LIST, _cycle.nextErrorCount());
_reporter.report(error);
} else {
_ownableSynchronizerObjectCountOnHeap += 1;
}
}
}
} catch (CorruptDataException cde) {
// TODO : cde should be part of the error
CheckError error = new CheckError(object, _cycle, _currentCheck, "Object ", J9MODRON_GCCHK_RC_CORRUPT_DATA_EXCEPTION, _cycle.nextErrorCount());
_reporter.report(error);
return J9MODRON_SLOT_ITERATOR_UNRECOVERABLE_ERROR;
}
if (J9MODRON_GCCHK_RC_OK == result) {
GCObjectIterator fieldIterator;
GCObjectIterator addressIterator;
try {
fieldIterator = GCObjectIterator.fromJ9Object(object, true);
addressIterator = GCObjectIterator.fromJ9Object(object, true);
} catch (CorruptDataException e) {
// TODO : cde should be part of the error
CheckError error = new CheckError(object, _cycle, _currentCheck, "Object ", J9MODRON_GCCHK_RC_CORRUPT_DATA_EXCEPTION, _cycle.nextErrorCount());
_reporter.report(error);
return J9MODRON_SLOT_ITERATOR_UNRECOVERABLE_ERROR;
}
while (fieldIterator.hasNext()) {
J9ObjectPointer field = fieldIterator.next();
VoidPointer address = addressIterator.nextAddress();
result = checkSlotObjectHeap(field, ObjectReferencePointer.cast(address), regionDesc, object);
if (J9MODRON_SLOT_ITERATOR_OK != result) {
break;
}
}
}
if (J9MODRON_GCCHK_RC_OK == result) {
/* this heap object is OK. Record it in the cache in case we find a pointer to it soon */
int cacheIndex = (int) (object.getAddress() % OBJECT_CACHE_SIZE);
_checkedObjectCache[cacheIndex] = object;
}
return result;
}
use of com.ibm.j9ddr.vm29.pointer.VoidPointer in project openj9 by eclipse.
the class CheckMonitorTable method print.
@Override
public void print() {
try {
VoidPointer monitorTableList = VoidPointer.cast(getJavaVM().monitorTableList());
GCMonitorReferenceIterator monitorReferenceIterator = GCMonitorReferenceIterator.from();
MonitorTable previousMonitorTable = null;
ScanFormatter formatter = new ScanFormatter(this, "MonitorTableList", monitorTableList);
while (monitorReferenceIterator.hasNext()) {
J9ObjectMonitorPointer objectMonitor = monitorReferenceIterator.next();
MonitorTable currentMonitorTable = monitorReferenceIterator.currentMonitorTable();
if (!currentMonitorTable.equals(previousMonitorTable)) {
if (null != previousMonitorTable) {
formatter.endSection();
}
formatter.section("MonitorTable", currentMonitorTable.getMonitorTableListEntryPointer());
}
J9ThreadAbstractMonitorPointer monitor = J9ThreadAbstractMonitorPointer.cast(objectMonitor.monitor());
formatter.entry(VoidPointer.cast(monitor.userData()));
previousMonitorTable = currentMonitorTable;
}
if (null != previousMonitorTable) {
formatter.endSection();
}
formatter.end("MonitorTableList", monitorTableList);
} catch (CorruptDataException e) {
// TODO: handle exception
}
}
use of com.ibm.j9ddr.vm29.pointer.VoidPointer in project openj9 by eclipse.
the class CheckEngine method checkSlot.
public int checkSlot(PointerPointer objectIndirect, VoidPointer objectIndirectBase, int objectType) {
J9ObjectPointer object;
try {
object = J9ObjectPointer.cast(objectIndirect.at(0));
int result = checkObjectIndirect(object);
if (J9MODRON_GCCHK_RC_OK != result) {
CheckError error = new CheckError(objectIndirectBase, objectIndirect, _cycle, _currentCheck, result, _cycle.nextErrorCount(), objectType);
_reporter.report(error);
}
} catch (CorruptDataException e) {
// TODO : cde should be part of the error
CheckError error = new CheckError(objectIndirectBase, objectIndirect, _cycle, _currentCheck, J9MODRON_GCCHK_RC_CORRUPT_DATA_EXCEPTION, _cycle.nextErrorCount(), objectType);
_reporter.report(error);
}
return J9MODRON_SLOT_ITERATOR_OK;
}
Aggregations