use of com.ibm.j9ddr.vm29.pointer.AbstractPointer in project openj9 by eclipse.
the class LinearDumper method getRegionDetailString.
private static Object getRegionDetailString(J9ClassRegion region) throws CorruptDataException {
VoidPointer srp;
long slotAddress;
String returnValue = "";
switch(region.getType()) {
case J9_SECTION_START:
returnValue = String.format(" %5d bytes", region.getLength());
break;
case J9_RAM_UTF8:
UDATAPointer slotPtr = UDATAPointer.cast(region.getSlotPtr());
if (slotPtr.at(0).longValue() != 0) {
returnValue = J9ObjectHelper.stringValue(J9ObjectPointer.cast(slotPtr.at(0)));
}
break;
case J9_UTF8:
case J9_ROM_UTF8:
returnValue = J9UTF8Helper.stringValue(J9UTF8Pointer.cast(region.getSlotPtr()));
break;
case J9_iTableMethod:
/*
* This case is special for the iTableMethod, because their pointers
* are related to the beginning of the class and are not absolute
*/
AbstractPointer classOffset = region.getSlotPtr().subOffset(region.offset);
slotAddress = region.getSlotPtr().at(0).longValue();
classOffset = classOffset.addOffset(slotAddress);
returnValue = region.additionalInfo + " " + classOffset.getHexAddress();
break;
case J9_SRP:
srp = SelfRelativePointer.cast(region.getSlotPtr()).get();
if (srp.notNull()) {
returnValue = " -> " + srp.getHexAddress();
}
break;
case J9_WSRP:
srp = WideSelfRelativePointer.cast(region.getSlotPtr()).get();
if (srp.notNull()) {
returnValue = " -> " + srp.getHexAddress();
}
break;
case J9_SRP_TO_STRING:
srp = SelfRelativePointer.cast(region.getSlotPtr()).get();
if (srp.notNull()) {
returnValue = " -> " + srp.getHexAddress();
returnValue += " " + J9UTF8Helper.stringValue(J9UTF8Pointer.cast(srp));
}
break;
case J9_Padding:
returnValue = region.length + " byte(s)";
break;
case J9_IntermediateClassData:
returnValue = region.length + " byte(s) " + region.additionalInfo;
break;
default:
String detail = "";
slotAddress = region.getSlotPtr().at(0).longValue();
long slotAddressOriginal = slotAddress;
if ((null != region.additionalInfo) && (region.additionalInfo.length() != 0)) {
if ("classAndFlags".equals(region.name) && (UDATA.MASK != slotAddress)) {
slotAddress = slotAddress & ~J9JavaAccessFlags.J9StaticFieldRefFlagBits;
}
detail += region.additionalInfo + (String.format(" 0x%08X", slotAddress));
/* For special debug extension, more information is shown */
if ((0 != slotAddress) && (region.additionalInfo.equals("!j9class"))) {
try {
detail += " - " + J9UTF8Helper.stringValue(J9ClassPointer.cast(slotAddress).romClass().className());
if ("classAndFlags".equals(region.name)) {
String flags = "";
if (0 != (J9JavaAccessFlags.J9StaticFieldRefBaseType & slotAddressOriginal)) {
flags += "J9StaticFieldRefBaseType, ";
}
if (0 != (J9JavaAccessFlags.J9StaticFieldRefDouble & slotAddressOriginal)) {
flags += "J9StaticFieldRefDouble, ";
}
if (0 != (J9JavaAccessFlags.J9StaticFieldRefVolatile & slotAddressOriginal)) {
flags += "J9StaticFieldRefVolatile, ";
}
/* Check there is any flag or not */
if (0 < flags.length()) {
/*remove last two chars = ", " */
flags = flags.substring(0, flags.length() - 2);
detail += "\t Flag(s) = " + flags;
}
}
} catch (Exception e) {
/* This is only for information purpose, it is ok if an exception was thrown */
}
}
}
returnValue = detail;
}
return returnValue;
}
use of com.ibm.j9ddr.vm29.pointer.AbstractPointer in project openj9 by eclipse.
the class VMConstantPoolCommand method run.
/**
* Run method for !vmconstantpool extension.
*
* @param command !vmconstantpool
* @param args args passed by !vmconstantpool extension.
* @param context Context
* @param out PrintStream
* @throws DDRInteractiveCommandException
*/
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
J9JavaVMPointer javaVM;
javaVM = J9RASHelper.getVM(DataType.getJ9RASPointer());
if (args.length == 1) {
long vmaddress = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
if (vmaddress != javaVM.getAddress()) {
out.println(args[0] + " is not a valid j9javavm address. Run !findvm to find out the j9javavm address of the current context");
return;
}
} else if (args.length > 1) {
printUsage(out);
}
J9ConstantPoolPointer jclConstantPool = J9ConstantPoolPointer.cast(javaVM.jclConstantPoolEA());
J9ROMClassPointer romClass = jclConstantPool.ramClass().romClass();
int index;
U32Pointer cpShapeDescription;
int constPoolCount;
cpShapeDescription = romClass.cpShapeDescription();
long cpDescription = cpShapeDescription.at(0).longValue();
constPoolCount = romClass.romConstantPoolCount().intValue();
PointerPointer cpEntry = PointerPointer.cast(J9ROMClassHelper.constantPool(romClass));
long cpDescriptionIndex = 0;
for (index = 0; index < constPoolCount; index++) {
if (0 == cpDescriptionIndex) {
// Load a new description word
cpDescription = cpShapeDescription.at(0).longValue();
cpShapeDescription = cpShapeDescription.add(1);
cpDescriptionIndex = J9_CP_DESCRIPTIONS_PER_U32;
}
long shapeDesc = cpDescription & J9_CP_DESCRIPTION_MASK;
AbstractPointer ref = PointerPointer.NULL;
if (shapeDesc == J9CPTYPE_CLASS) {
ref = J9ROMClassRefPointer.cast(cpEntry);
} else if (shapeDesc == J9CPTYPE_STRING) {
ref = J9ROMStringRefPointer.cast(cpEntry);
} else if ((shapeDesc == J9CPTYPE_INT) || (shapeDesc == J9CPTYPE_FLOAT)) {
ref = J9ROMConstantPoolItemPointer.cast(cpEntry);
} else if (shapeDesc == J9CPTYPE_LONG) {
U64Pointer longPointer = U64Pointer.cast(cpEntry);
out.println("Long at " + longPointer.getHexAddress() + " {\n\t0x0: U64:" + longPointer.getHexValue() + "\n}");
} else if (shapeDesc == J9CPTYPE_DOUBLE) {
U64Pointer longPointer = U64Pointer.cast(cpEntry);
out.println("Double at " + longPointer.getHexAddress() + " {\n\t0x0: U64:" + longPointer.at(0).longValue() + "\n}");
} else if ((shapeDesc == J9CPTYPE_INSTANCE_METHOD) || (shapeDesc == J9CPTYPE_STATIC_METHOD) || (shapeDesc == J9CPTYPE_INTERFACE_METHOD) || (shapeDesc == J9CPTYPE_HANDLE_METHOD) || (shapeDesc == J9CPTYPE_FIELD)) {
long classRefCPIndex;
if (shapeDesc == J9CPTYPE_FIELD) {
ref = J9ROMFieldRefPointer.cast(cpEntry);
/* gets the classRefCPIndex to obtain a pointer to the j9romclassref */
classRefCPIndex = J9ROMFieldRefPointer.cast(ref).classRefCPIndex().longValue();
} else {
ref = J9ROMFieldRefPointer.cast(cpEntry);
classRefCPIndex = J9ROMMethodRefPointer.cast(ref).classRefCPIndex().longValue();
}
PointerPointer classRefCPEntry = PointerPointer.cast(J9ROMClassHelper.constantPool(romClass)).addOffset(J9ROMConstantPoolItem.SIZEOF * classRefCPIndex);
/* gets the DDR output of the item */
String outString = ref.formatFullInteractive();
String[] parts = outString.split(nl);
/* add a debug extension(!j9romclassref) on the second line of the output */
parts[1] += "(!j9romclassref " + classRefCPEntry.getHexAddress() + ")";
out.print(join(nl, parts));
} else if ((shapeDesc == J9CPTYPE_UNUSED) || (shapeDesc == J9CPTYPE_UNUSED8)) {
U64Pointer longPointer = U64Pointer.cast(cpEntry);
out.println("Unused at " + longPointer.getHexAddress() + " {\n\t0x0: U64:" + longPointer.at(0).longValue() + "\n}");
} else if (ref.notNull()) {
out.println(ref.formatFullInteractive());
}
cpEntry = cpEntry.addOffset(J9ROMConstantPoolItem.SIZEOF);
cpDescription >>= J9_CP_BITS_PER_DESCRIPTION;
cpDescriptionIndex -= 1;
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.AbstractPointer in project openj9 by eclipse.
the class CheckEngine method regionForAddress.
// TODO kmt : this doesn't belong here
private GCHeapRegionDescriptor regionForAddress(AbstractPointer pointer) {
try {
if (null == _hrm) {
MM_HeapRegionManagerPointer hrm = MM_GCExtensionsPointer.cast(_javaVM.gcExtensions()).heapRegionManager();
_hrm = GCHeapRegionManager.fromHeapRegionManager(hrm);
}
return _hrm.regionDescriptorForAddress(pointer);
} catch (CorruptDataException cde) {
}
return null;
}
use of com.ibm.j9ddr.vm29.pointer.AbstractPointer in project openj9 by eclipse.
the class SegmentTree method findSegment.
private J9MemorySegmentPointer findSegment(int start, int end, AbstractPointer key) throws CorruptDataException {
if ((end - start) < 4) {
// Linear search small ranges
return linearSearch(start, end, key);
} else {
// Binary search
int mid = (start + end) / 2;
J9MemorySegmentPointer segment = cache[mid];
if (key.gte(segment.heapBase())) {
if (key.lt(segment.heapAlloc())) {
return segment;
} else {
return findSegment(mid, end, key);
}
} else {
return findSegment(start, mid, key);
}
}
}
Aggregations