use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer in project openj9 by eclipse.
the class ObjectRefsCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
if (args.length < 1) {
throw new DDRInteractiveCommandException("This debug extension takes an address argument \" !objectrefs <address> [ heapWalk ] [ rootWalk ]\"");
}
long addr = Long.decode(args[0]);
J9ObjectPointer targetObject = J9ObjectPointer.cast(addr);
boolean dumpHeap = false;
boolean dumpRoots = false;
if (1 == args.length) {
dumpHeap = true;
dumpRoots = true;
} else {
for (int i = 1; i < args.length; i++) {
if ("heapWalk".equals(args[i])) {
dumpHeap = true;
} else if ("rootWalk".equals(args[i])) {
dumpRoots = true;
}
}
}
if (dumpHeap) {
try {
dumpHeapReferences(vm, targetObject, out);
} catch (CorruptDataException cde) {
cde.printStackTrace();
}
}
if (dumpRoots) {
try {
dumpLiveReferences(vm, targetObject, out);
} catch (CorruptDataException cde) {
cde.printStackTrace();
}
}
} catch (DDRInteractiveCommandException e) {
throw e;
} catch (Throwable e) {
e.printStackTrace(out);
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer in project openj9 by eclipse.
the class ObjectRefsCommand method dumpHeapReferences.
/**
* Write the on heap references stanza to the output stream.
* @param vm
* @param targetObject
* @param out
* @throws CorruptDataException
*/
private void dumpHeapReferences(J9JavaVMPointer vm, J9ObjectPointer targetObject, PrintStream out) throws CorruptDataException {
if (GCExtensions.isVLHGC()) {
Table table = new Table("On Heap References");
table.row("object (!j9object)", "field (!j9object)", "!mm_heapregiondescriptorvlhgc", "AC (type)");
/* iterate over all heap regions */
GCHeapRegionIterator regionIterator = GCHeapRegionIterator.from();
while (regionIterator.hasNext()) {
GCHeapRegionDescriptor region = regionIterator.next();
if (region.containsObjects()) {
MM_HeapRegionDescriptorVLHGCPointer vlhgcRegion = MM_HeapRegionDescriptorVLHGCPointer.cast(region.getHeapRegionDescriptorPointer());
MM_AllocationContextTarokPointer currentAllocationContextTarok = vlhgcRegion._allocateData()._owningContext();
/* iterate over all objects in region */
GCObjectHeapIterator heapObjectIterator = region.objectIterator(true, false);
while (heapObjectIterator.hasNext()) {
J9ObjectPointer currentObject = heapObjectIterator.next();
/* Iterate over the object's fields and list any that point at @ref targetObject */
GCObjectIterator fieldIterator = GCObjectIterator.fromJ9Object(currentObject, false);
while (fieldIterator.hasNext()) {
J9ObjectPointer currentTargetObject = fieldIterator.next();
if (currentTargetObject.eq(targetObject)) {
/* found a reference to our targetObject, add it to the table */
J9ClassPointer objectClass = J9ObjectHelper.clazz(currentObject);
String objectClassString = J9ClassHelper.getJavaName(objectClass);
table.row(currentObject.getHexAddress() + " //" + objectClassString, currentTargetObject.getHexAddress(), vlhgcRegion.getHexAddress(), currentAllocationContextTarok.getHexAddress() + " (" + currentAllocationContextTarok._allocationContextType() + ")");
}
}
}
}
}
table.render(out);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer in project openj9 by eclipse.
the class RootPathCommand method run.
public void run(String command, String[] args, Context context, final PrintStream out) throws DDRInteractiveCommandException {
switch(args.length) {
case 0:
if (args.length == 0) {
if (command.equals("!rootpathverbose")) {
out.println("verbose output enabled for rootpath command. run !rootpathnoverbose to disable verbose output");
_verboseEnabled = true;
} else if (command.equals("!rootpathnoverbose")) {
out.println("verbose output disabled for rootpath command. run !rootpathverbose to enable verbose output");
_verboseEnabled = false;
} else {
throw new UnsupportedOperationException("Unrecognized command passed to RoothPathCommand");
}
}
break;
case 1:
long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
final J9ObjectPointer objectToFind = J9ObjectPointer.cast(address);
try {
J9ClassPointer clazz = J9ObjectHelper.clazz(objectToFind);
if (!J9ClassHelper.hasValidEyeCatcher(clazz)) {
throw new DDRInteractiveCommandException("object class is not valid (eyecatcher is not 0x99669966)");
}
} catch (CorruptDataException cde) {
throw new DDRInteractiveCommandException("memory fault de-referencing address argument", cde);
}
try {
/* Create a custom event listener so that CorruptDataExceptions that are found
* while iterating through the live set aren't all printed to the output stream
*/
RootPathCommandListener listener = new RootPathCommandListener();
EventManager.register(listener);
if (command.equals("!rootpathfindall") || command.equals("!strongrootpathfindall")) {
LiveSetWalker.walkLiveSet(new RootPathsFinder(objectToFind, out), RootSetType.STRONG_REACHABLE);
} else if (command.equals("!anyrootpathfindall")) {
LiveSetWalker.walkLiveSet(new RootPathsFinder(objectToFind, out), RootSetType.ALL);
} else if (command.equals("!weakrootpathfindall")) {
LiveSetWalker.walkLiveSet(new RootPathsFinder(objectToFind, out), RootSetType.WEAK_REACHABLE);
} else if (command.equals("!rootpathfind") || command.equals("!strongrootpathfind")) {
RootPathFinder pathFinder = new RootPathFinder(objectToFind, out);
LiveSetWalker.walkLiveSet(pathFinder, RootSetType.STRONG_REACHABLE);
if (!pathFinder._pathFound) {
out.println("No paths from roots found");
}
} else if (command.equals("!anyrootpathfind")) {
RootPathFinder pathFinder = new RootPathFinder(objectToFind, out);
LiveSetWalker.walkLiveSet(pathFinder, RootSetType.ALL);
if (!pathFinder._pathFound) {
out.println("No paths from roots found");
}
} else if (command.equals("!weakrootpathfindall")) {
RootPathFinder pathFinder = new RootPathFinder(objectToFind, out);
LiveSetWalker.walkLiveSet(pathFinder, RootSetType.WEAK_REACHABLE);
if (!pathFinder._pathFound) {
out.println("No paths from roots found");
}
} else if (command.equals("!isobjectalive")) {
ObjectFinderVisitor objectFinder = new ObjectFinderVisitor(objectToFind);
LiveSetWalker.walkLiveSet(objectFinder);
if (objectFinder._objectFound) {
out.println("Object is live");
} else {
out.println("Object is not live");
}
}
if (listener._corruptionFound) {
out.println("Corruption detected walking live set");
if (!_verboseEnabled) {
out.println("run !rootpathverbose and re-run command to see corruptions");
}
}
EventManager.unregister(listener);
} catch (CorruptDataException cde) {
throw new DDRInteractiveCommandException("Memory fault while walking live set", cde);
}
break;
default:
throw new DDRInteractiveCommandException("Invalid number of arguments");
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer in project openj9 by eclipse.
the class MarkMapCommand method findSource.
protected void findSource(String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
long address = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
J9ObjectPointer object = J9ObjectPointer.cast(address);
J9ObjectPointer scanPtr = J9ObjectPointer.cast(markMap.getHeapBase());
J9ObjectPointer heapTop = J9ObjectPointer.cast(markMap.getHeapTop());
if (object.gte(scanPtr) && object.lt(heapTop)) {
int count = 0;
while (scanPtr.lt(heapTop)) {
J9ObjectPointer base = scanPtr;
J9ObjectPointer top = base.addOffset(markMap.getPageSize(scanPtr));
MarkedObject[] results = markMap.queryRange(base, top);
for (int i = 0; i < results.length; i++) {
MarkedObject result = results[i];
if (result.wasRelocated()) {
if (result.relocatedObject.eq(object)) {
// A match!
out.format("Object %s was relocated to %s\n", result.object.getHexAddress(), result.relocatedObject.getHexAddress());
count += 1;
}
}
}
scanPtr = top;
}
if (count > 0) {
out.format("%1 relocation candidates found\n", count);
} else {
out.format("No relocation candidates found\n");
}
} else {
out.format("Object %s is not in the heap\n", object.getHexAddress());
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer in project openj9 by eclipse.
the class MarkMapCommand method near.
protected void near(String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
long address = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
J9ObjectPointer object = J9ObjectPointer.cast(address);
J9ObjectPointer base = object.untag(markMap.getPageSize(object) - 1);
J9ObjectPointer top = base.addOffset(markMap.getPageSize(object));
MarkedObject[] results = markMap.queryRange(base, top);
reportResults(base, top, results, out);
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
Aggregations