use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer in project openj9 by eclipse.
the class ACCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
if (command.equalsIgnoreCase("!acforobject")) {
if (null == heapRegionManager) {
MM_HeapRegionManagerPointer hrmPointer;
hrmPointer = MM_GCExtensionsPointer.cast(vm.gcExtensions()).heapRegionManager();
heapRegionManager = GCHeapRegionManager.fromHeapRegionManager(hrmPointer);
}
if (args.length < 1) {
throw new DDRInteractiveCommandException("Invalid number of arguments specified.");
}
long addr = Long.decode(args[0]);
J9ObjectPointer objectPointer = J9ObjectPointer.cast(addr);
dumpACForObject(vm, objectPointer, out);
} else {
MM_GCExtensionsPointer gcExtensions = MM_GCExtensionsPointer.cast(vm.gcExtensions());
if (args.length < 1) {
throw new DDRInteractiveCommandException("Invalid number of arguments specified.");
}
boolean dumpACExternalReferences = false;
boolean dumpOwnedRegions = false;
for (int i = 1; i < args.length; i++) {
String arg = args[i];
if (arg.equalsIgnoreCase("xrefs")) {
dumpACExternalReferences = true;
} else if (arg.equalsIgnoreCase("ownedRegions")) {
dumpOwnedRegions = true;
} else {
throw new DDRInteractiveCommandException("Unrecognized acforobject subcommand -->" + arg);
}
}
long addr = Long.decode(args[0]);
MM_AllocationContextPointer ac = MM_AllocationContextPointer.cast(addr);
if (dumpACExternalReferences) {
// TODO: handle other AC types
if (GCExtensions.isVLHGC()) {
context.execute("!mm_allocationcontexttarok", new String[] { args[0] }, out);
}
dumpLiveReferences(vm, ac, out);
}
if (dumpOwnedRegions) {
dumpOwnedRegions(vm, ac, out);
}
}
} catch (DDRInteractiveCommandException e) {
throw e;
} catch (Throwable e) {
e.printStackTrace(out);
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer in project openj9 by eclipse.
the class ACCommand method dumpLiveReferences.
private void dumpLiveReferences(J9JavaVMPointer vm, MM_AllocationContextPointer allocationContext, PrintStream out) throws CorruptDataException {
if (GCExtensions.isVLHGC()) {
MM_AllocationContextTarokPointer act = MM_AllocationContextTarokPointer.cast(allocationContext);
MM_HeapRegionManagerPointer hrmPointer = MM_GCExtensionsPointer.cast(vm.gcExtensions()).heapRegionManager();
GCHeapRegionManager heapRegionManager = GCHeapRegionManager.fromHeapRegionManager(hrmPointer);
Table table = new Table("Live References into AC " + allocationContext.getHexAddress());
table.row("Object", "Field");
out.println("Walking live set in search of external references into ac: " + allocationContext.getHexAddress());
long totalMillis = System.currentTimeMillis();
LiveReferenceVisitor visitor = new LiveReferenceVisitor(heapRegionManager, act, table);
LiveSetWalker.walkLiveSet(visitor, RootSetType.ALL);
totalMillis = System.currentTimeMillis() - totalMillis;
table.render(out);
out.println("\nFinished live reference walk in " + totalMillis + "ms");
out.println("Found " + visitor.getNumExternalReferencesFound() + " external references.");
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer in project openj9 by eclipse.
the class AllClassesCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
init();
if (args != null) {
if (!parseArgs(out, args)) {
return;
}
}
boolean useRange = (rangeStart != null && rangeEnd != null);
/* If none of "rom" or "ram" is specified, then list both type of classes */
if (!dumpROMClasses && !dumpRAMClasses) {
dumpROMClasses = dumpRAMClasses = true;
}
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
if (dumpRAMClasses) {
out.append("RAM classes (ram size loader rom replacement name)" + nl);
out.append("Class addr\tsize\t\tClassLoader\tROM class addr\tArray\tClass name" + nl);
out.append(nl);
ClassSegmentIterator classSegmentIterator = new ClassSegmentIterator(vm.classMemorySegments());
while (classSegmentIterator.hasNext()) {
J9ClassPointer classPointer = J9ClassPointer.NULL;
try {
classPointer = (J9ClassPointer) classSegmentIterator.next();
if (useRange) {
if (classPointer.getAddress() < rangeStart.getAddress() || classPointer.getAddress() >= rangeEnd.getAddress()) {
/* J9Class is outside of specified range; skip it. */
continue;
}
}
// 0x02713400 0x00000148 0x001210cc 0x02da2f20 0x00000000
// java/util/regex/Pattern$Begin
out.append(classPointer.getHexAddress());
out.append('\t');
out.append(J9ClassHelper.size(classPointer, vm).getHexValue());
out.append('\t');
out.append(classPointer.classLoader().getHexAddress());
out.append('\t');
out.append(classPointer.romClass().getHexAddress());
out.append('\t');
if (J9ClassHelper.isSwappedOut(classPointer)) {
out.append(classPointer.arrayClass().getHexAddress());
} else {
out.append('0');
}
out.append('\t');
out.append(J9ClassHelper.getJavaName(classPointer));
out.append(nl);
} catch (CorruptDataException e) {
if (useRange) {
if (classPointer.getAddress() < rangeStart.getAddress() || classPointer.getAddress() >= rangeEnd.getAddress()) {
/* J9Class that caused CorruptDataException is outside of specified range; skip it. */
continue;
}
}
}
}
}
if (dumpROMClasses) {
ROMClassesIterator iterator = null;
out.append(nl);
if (useRange) {
iterator = new ROMClassesRangeIterator(out, rangeStart, rangeEnd);
/* Classloader is not available when using ROMClassesRangeIterator */
out.append("ROM classes (rom size modifiers name)" + nl);
out.append("Class addr\tROM size\tModifiers\tExtra\t\tClass name" + nl);
} else {
iterator = new ROMClassesIterator(out, vm.classMemorySegments());
out.append("ROM classes (rom size loader modifiers name)" + nl);
out.append("Class addr\tROM size\tClassLoader\tModifiers\tExtra\t\tClass name" + nl);
}
out.append(nl);
while (iterator.hasNext()) {
J9ROMClassPointer classPointer = iterator.next();
out.append(classPointer.getHexAddress());
out.append('\t');
out.append(classPointer.romSize().getHexValue());
/* MemorySegment is not available when using ROMClassesRangeIterator */
if (iterator.getMemorySegmentPointer() != J9MemorySegmentPointer.NULL) {
out.append('\t');
out.append(iterator.getMemorySegmentPointer().classLoader().getHexAddress());
}
out.append('\t');
out.append(classPointer.modifiers().getHexValue());
out.append('\t');
out.append(classPointer.extraModifiers().getHexValue());
out.append('\t');
out.append(J9UTF8Helper.stringValue(classPointer.className()));
out.append(nl);
}
out.append(nl);
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer in project openj9 by eclipse.
the class AnalyseRomClassUTF8Command method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
boolean printUTF8WeightList = false;
int maxDistributionPercent = 85;
if ((args.length >= 1) && (args[0].equals("UTF8WeightList"))) {
printUTF8WeightList = true;
}
for (int i = 0; i < args.length; i++) {
if (args[i].endsWith("%")) {
try {
// Parses the maxDistribution string such as 85%
maxDistributionPercent = DecimalFormat.getInstance().parse(args[i]).intValue();
} catch (ParseException e) {
out.println("Usage: !analyseromClassutf8 [UTF8WeightList] [maxDistribution%] maxDistribution defaults to 85%");
}
}
}
Statistics statistics = new Statistics();
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
ROMClassesIterator classSegmentIterator = new ROMClassesIterator(out, vm.classMemorySegments());
J9ObjectPointer bootstraploader = vm.systemClassLoader().classLoaderObject();
while (classSegmentIterator.hasNext()) {
J9ROMClassPointer classPointer = (J9ROMClassPointer) classSegmentIterator.next();
ClassWalker classWalker = new RomClassWalker(classPointer, context);
LinearDumper linearDumper = new LinearDumper();
J9ClassRegionNode allRegionsNode = linearDumper.getAllRegions(classWalker);
statistics.add(allRegionsNode, classSegmentIterator, bootstraploader);
}
statistics.getResult(printUTF8WeightList, maxDistributionPercent, out);
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer 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