use of com.ibm.j9ddr.vm29.pointer.Pointer in project openj9 by eclipse.
the class LinearDumper method getAllRegions.
/**
* Returns a tree of regions and slots. Each slot is under a region. The
* root element is always null.
* @param classWalker
*
* @return J9ClassRegionNode tree of J9ClassRegion
* @throws CorruptDataException
*/
public J9ClassRegionNode getAllRegions(ClassWalker classWalker) throws CorruptDataException {
classWalker.allSlotsInObjectDo(this);
final StructurePointer clazz = classWalker.getClazz();
/* Add the UTF8 region */
if (firstJ9_ROM_UTF8 != Long.MAX_VALUE) {
addSection(clazz, PointerPointer.cast(firstJ9_ROM_UTF8), lastJ9_ROM_UTF8 - firstJ9_ROM_UTF8, "UTF8", true);
}
groupSectionByName(clazz, "methodDebugInfo", false);
groupSectionByName(clazz, "variableInfo", false);
/*
* the offset is a pointer which points at the end of the current
* region, in the case of a region which have no real size, it points at
* the beginning of the region
*/
AbstractPointer offset = PointerPointer.NULL;
J9ClassRegionNode currentNode = new J9ClassRegionNode(null);
Stack<J9ClassRegionNode> parentStack = new Stack<J9ClassRegionNode>();
J9ClassRegion previousRegion = null;
Collections.sort(classRegions);
for (J9ClassRegion region : classRegions) {
if (isSameRegion(previousRegion, region)) {
previousRegion = region;
continue;
}
previousRegion = region;
if (SlotType.J9_SECTION_START == region.getType()) {
if (region.getComputePadding() && offset.notNull() && !offset.eq(region.getSlotPtr())) {
currentNode.addChild(new J9ClassRegionNode(new J9ClassRegion(offset, SlotType.J9_Padding, "Padding", "", region.getSlotPtr().getAddress() - offset.getAddress(), 0, true)));
}
if (region.getComputePadding()) {
offset = region.getSlotPtr();
}
parentStack.push(currentNode);
J9ClassRegionNode newChild = new J9ClassRegionNode(region);
currentNode.addChild(newChild);
currentNode = newChild;
} else if (SlotType.J9_SECTION_END == region.getType()) {
if (region.getComputePadding()) {
long paddingSize = (region.getSlotPtr().getAddress() - offset.getAddress());
if (paddingSize != 0) {
currentNode.addChild(new J9ClassRegionNode(new J9ClassRegion(offset, SlotType.J9_Padding, "Padding", "", paddingSize, 0, true)));
}
offset = region.getSlotPtr();
}
currentNode = parentStack.pop();
} else {
boolean computePadding = false;
if (currentNode.getNodeValue() != null) {
computePadding = currentNode.getNodeValue().getComputePadding();
}
if (computePadding && offset.notNull() && !offset.eq(region.getSlotPtr())) {
currentNode.addChild(new J9ClassRegionNode(new J9ClassRegion(offset, SlotType.J9_Padding, "Padding", "", region.getSlotPtr().getAddress() - offset.getAddress(), 0, true)));
}
if (computePadding) {
offset = region.getSlotPtr().addOffset(region.length);
}
currentNode.addChild(new J9ClassRegionNode(region));
}
}
// Padding after the class and inside the romSize.
if (clazz instanceof J9ROMClassPointer) {
long size = J9ROMClassPointer.cast(clazz).romSize().longValue();
long paddingSize = (clazz.longValue() + size) - offset.longValue();
if (paddingSize != 0) {
currentNode.addChild(new J9ClassRegionNode(new J9ClassRegion(offset, SlotType.J9_Padding, "Padding", "", paddingSize, 0, true)));
// The class padding might be inserted out of order
Collections.sort(currentNode.getChildren());
}
}
return currentNode;
}
use of com.ibm.j9ddr.vm29.pointer.Pointer in project openj9 by eclipse.
the class RamClassWalker method allSlotsInJitVTablesDo.
private void allSlotsInJitVTablesDo() throws CorruptDataException {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
if (!vm.jitConfig().isNull()) {
final long jitvTableSlots = J9ClassHelper.vTable(ramClass).at(0).longValue();
final long jitvTableSlotsLength = jitvTableSlots * UDATA.SIZEOF;
for (int i = 0; i < jitvTableSlots; i++) {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, UDATAPointer.cast(ramClass.subOffset(jitvTableSlotsLength)).add(i), "send target", "");
}
/*
* The vTable is before the RAMClass, to get the starting address,
* the length of the vTable is subtracted from the pointer of the
* class
*/
classWalkerCallback.addSection(clazz, ramClass.subOffset(jitvTableSlotsLength), jitvTableSlotsLength, "jitVTables", true);
}
}
use of com.ibm.j9ddr.vm29.pointer.Pointer in project openj9 by eclipse.
the class DumpAllSegmentsCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
out.append(String.format("memorySegments - !j9memorysegmentlist 0x%s\n", Long.toHexString(vm.memorySegments().getAddress())));
SegmentsUtil.dbgDumpSegmentList(out, vm.memorySegments());
out.append(String.format("classMemorySegments - !j9memorysegmentlist 0x%s\n", Long.toHexString(vm.classMemorySegments().getAddress())));
SegmentsUtil.dbgDumpSegmentList(out, vm.classMemorySegments());
if (J9BuildFlags.interp_nativeSupport) {
/* readJavaVM also reads converts the JITConfig pointer. */
if (!vm.jitConfig().isNull()) {
out.append(String.format("jit code segments - !j9memorysegmentlist 0x%s\n", Long.toHexString(vm.jitConfig().codeCacheList().getAddress())));
SegmentsUtil.dbgDumpJITCodeSegmentList(out, vm.jitConfig().codeCacheList());
out.append(String.format("jit data segments - !j9memorysegmentlist 0x%s\n", Long.toHexString(vm.jitConfig().dataCacheList().getAddress())));
SegmentsUtil.dbgDumpSegmentList(out, vm.jitConfig().dataCacheList());
} else {
out.append("JIT not enabled\n");
}
}
out.append(nl);
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.Pointer in project openj9 by eclipse.
the class TraceConfigCommand method walkTraceComponents.
/**
* Walk the trace components and use the visitor pattern to save us writing this
* loop several times.
*
* @param visitor the visitor object to run on each UtModuleInfo.
* @param head the pointer to the first item in the list of UtComponentData
* @param context
* @param out
*/
private static void walkTraceComponents(final ModuleVisitor visitor, final UtComponentDataPointer head, Context context, PrintStream out) {
UtComponentDataPointer current = head;
try {
while (current != null && current.notNull()) {
UtModuleInfoPointer modInfo = current.moduleInfo();
visitor.visit(modInfo);
current = current.next();
}
} catch (CorruptDataException e) {
e.printStackTrace();
}
}
use of com.ibm.j9ddr.vm29.pointer.Pointer in project openj9 by eclipse.
the class WalkInternTableCommand method getRomClassBuilderPtr.
/**
* This method is used to get the pointer to the RomClassBuilder
* @param out PrintStream
* @return void
* @throws CorruptDataException
*/
private J9DbgStringInternTablePointer getRomClassBuilderPtr(PrintStream out) throws CorruptDataException {
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
if (vm.isNull()) {
out.append("VM can not be found " + nl);
return null;
}
J9TranslationBufferSetPointer translationBufferSetPtr = vm.dynamicLoadBuffers();
if (translationBufferSetPtr.isNull()) {
out.append("J9TranslationBufferSet can not be found " + nl);
return null;
}
J9DbgROMClassBuilderPointer romClassBuilderPtr = J9DbgROMClassBuilderPointer.cast(translationBufferSetPtr.romClassBuilder());
if (romClassBuilderPtr.isNull()) {
out.append("romClassBuilderPtr can not be found " + nl);
return null;
}
return romClassBuilderPtr.stringInternTable();
} catch (CorruptDataException e) {
throw e;
}
}
Aggregations