use of com.ibm.j9ddr.vm29.pointer.AbstractPointer in project openj9 by eclipse.
the class CheckEngine method findRegionForPointer.
private GCHeapRegionDescriptor findRegionForPointer(AbstractPointer pointer, GCHeapRegionDescriptor region) {
GCHeapRegionDescriptor regionDesc = null;
if (region != null && region.isAddressInRegion(pointer)) {
return region;
}
regionDesc = regionForAddress(pointer);
if (null != regionDesc) {
return regionDesc;
}
// TODO kmt : this is tragically slow
try {
GCHeapRegionIterator iterator = GCHeapRegionIterator.from();
while (iterator.hasNext()) {
regionDesc = GCHeapRegionDescriptor.fromHeapRegionDescriptor(iterator.next());
if (isPointerInRegion(pointer, regionDesc)) {
return regionDesc;
}
}
} catch (CorruptDataException e) {
}
return null;
}
use of com.ibm.j9ddr.vm29.pointer.AbstractPointer in project openj9 by eclipse.
the class J9ObjectStructureFormatter method printObjectField.
public void printObjectField(PrintStream out, int tabLevel, J9ClassPointer localClazz, U8Pointer dataStart, J9ClassPointer fromClass, J9ObjectFieldOffset objectFieldOffset) throws CorruptDataException {
J9ROMFieldShapePointer fieldShape = objectFieldOffset.getField();
UDATA fieldOffset = objectFieldOffset.getOffsetOrAddress();
boolean isHiddenField = objectFieldOffset.isHidden();
String className = J9UTF8Helper.stringValue(fromClass.romClass().className());
String fieldName = J9UTF8Helper.stringValue(fieldShape.nameAndSignature().name());
String fieldSignature = J9UTF8Helper.stringValue(fieldShape.nameAndSignature().signature());
U8Pointer valuePtr = dataStart;
valuePtr = valuePtr.add(fieldOffset);
padding(out, tabLevel);
out.print(String.format("%s %s = ", fieldSignature, fieldName));
if (fieldShape.modifiers().anyBitsIn(J9FieldSizeDouble)) {
out.print(U64Pointer.cast(valuePtr).at(0).getHexValue());
} else if (fieldShape.modifiers().anyBitsIn(J9FieldFlagObject)) {
AbstractPointer ptr = J9BuildFlags.gc_compressedPointers ? U32Pointer.cast(valuePtr) : UDATAPointer.cast(valuePtr);
out.print(String.format("!fj9object 0x%x", ptr.at(0).longValue()));
} else {
out.print(I32Pointer.cast(valuePtr).at(0).getHexValue());
}
out.print(String.format(" (offset=%d) (%s)", fieldOffset.longValue(), className));
if (isHiddenField) {
out.print(" <hidden>");
}
}
use of com.ibm.j9ddr.vm29.pointer.AbstractPointer in project openj9 by eclipse.
the class MMSublistSlotIterator method next.
public AbstractPointer next() {
if (hasNext()) {
VoidPointer currentScanPtr = VoidPointer.cast(scanPtr);
scanPtr = scanPtr.add(1);
return currentScanPtr;
} else {
throw new NoSuchElementException("There are no more items available through this iterator");
}
}
use of com.ibm.j9ddr.vm29.pointer.AbstractPointer in project openj9 by eclipse.
the class ClassWalker method addObjectsAsSlot.
/**
* It walks through each field in this structure that is represented by methodClass and
* registers each field as a slot into ClassWalkerCallBack
*
* It uses the StructureDescriptor of J9DDR to get the FieldDescriptor of a structure.
* The name, type and address are found in the FieldDescriptor. The name, type and address
* are guaranteed to match the current core file, since they are taken from it.
*
* @param methodClass pointer class that is generated for the VM structure
* @param renameFields list of names to rename the original field names in the structure
* @throws CorruptDataException
*/
protected void addObjectsAsSlot(StructurePointer methodClass, HashMap<String, String> renameFields) throws CorruptDataException {
/* Get the structure name by removing "Pointer" suffix from the DDR generated class name*/
String structureName = methodClass.getClass().getSimpleName().substring(0, methodClass.getClass().getSimpleName().indexOf("Pointer"));
/* Get structure descriptor by using structure name */
StructureDescriptor sd = StructureCommandUtil.getStructureDescriptor(structureName, getContext());
/* Structure descriptor can not be null in normal circumstances,
* because StructurePointer "methodClass" is generated for an existing structure in the VM,
* so it should exist. If not, throw an exception.
*/
if (sd == null) {
throw new CorruptDataException("Structure \"" + structureName + "\" can not be found.");
}
for (FieldDescriptor fd : sd.getFields()) {
/* Get the name of the field from field descriptor */
String outName = fd.getName();
/* Get SlotType by using field type name */
SlotType type = getTypeByFieldTypeName(fd.getType());
/* Get the address of the field by adding the offset to the methodClass'address */
AbstractPointer address = U8Pointer.cast(methodClass).addOffset(fd.getOffset());
/* Rename fields if any defined. */
if (null != renameFields) {
if (renameFields.containsKey(outName)) {
outName = renameFields.get(outName);
}
}
/*add the field into classWalkerCallback by its name, type, address and debug extension method name */
classWalkerCallback.addSlot(clazz, type, address, outName, getDebugExtForMethodName(outName));
}
}
use of com.ibm.j9ddr.vm29.pointer.AbstractPointer in project openj9 by eclipse.
the class LinearDumper method groupSectionByName.
/**
* Find the first and the last section and group them in another section with the same name ending with a "s".
* For example, it will group all of the methodDebugInfo in a section named methodDebugInfos
* It is important to note that the function does not check if the sections grouped are contiguous, it will
* group all sections between the first and the last section even if their names doesn't match.
*
* @param clazz
* @param name name of sections to group
* @param computePadding
* @throws CorruptDataException
*/
private void groupSectionByName(final StructurePointer clazz, String name, boolean computePadding) throws CorruptDataException {
AbstractPointer firstMethodDebugInfo = null;
AbstractPointer lastMethodDebugInfo = null;
for (J9ClassRegion region : classRegions) {
if (SlotType.J9_SECTION_START == region.getType() && region.getName().equals(name)) {
if (firstMethodDebugInfo == null || region.getSlotPtr().lt(firstMethodDebugInfo)) {
firstMethodDebugInfo = region.getSlotPtr();
}
if (lastMethodDebugInfo == null || region.getSlotPtr().add(region.getLength()).gt(lastMethodDebugInfo)) {
lastMethodDebugInfo = region.getSlotPtr().addOffset(region.getLength());
}
}
}
if (firstMethodDebugInfo != null && lastMethodDebugInfo != null) {
UDATA length = UDATA.cast(lastMethodDebugInfo).sub(UDATA.cast(firstMethodDebugInfo));
addSection(clazz, PointerPointer.cast(firstMethodDebugInfo), length.longValue(), name + "s", computePadding);
}
}
Aggregations