use of com.ibm.j9ddr.vm29.types.U32 in project openj9 by eclipse.
the class NativeMemInfoCommand method computeSize.
private ComponentSizeAllocation computeSize(OMRMemCategoryPointer mcp) throws CorruptDataException {
ComponentSizeAllocation csa = new ComponentSizeAllocation();
csa.size += mcp.liveBytes().longValue();
csa.allocations += mcp.liveAllocations().longValue();
final int numberOfChildren = mcp.numberOfChildren().intValue();
for (int i = 0; i < numberOfChildren; i++) {
U32 childCode = mcp.children().at(i);
OMRMemCategoryPointer child = OMRMemCategoryHelper.getMemoryCategory(childCode);
csa.add(computeSize(child));
}
return csa;
}
use of com.ibm.j9ddr.vm29.types.U32 in project openj9 by eclipse.
the class VmCheckCommand method verifyUTF8.
private boolean verifyUTF8(J9UTF8Pointer utf8) throws CorruptDataException {
if (utf8.isNull()) {
return false;
}
UDATA length = new UDATA(utf8.length());
U8Pointer utf8Data = utf8.dataEA();
while (length.longValue() > 0) {
// not used
U16 temp = new U16(0);
U32 lengthRead = decodeUTF8CharN(utf8Data, temp, length);
if (lengthRead.eq(0)) {
return false;
}
length = length.sub(lengthRead);
utf8Data = utf8Data.addOffset(lengthRead);
}
return true;
}
use of com.ibm.j9ddr.vm29.types.U32 in project openj9 by eclipse.
the class VmCheckCommand method verifyJ9ROMClass.
private void verifyJ9ROMClass(PrintStream out, J9JavaVMPointer vm, J9ClassPointer clazz) throws CorruptDataException {
J9ROMClassPointer romClass = clazz.romClass();
J9ClassLoaderPointer classLoader = clazz.classLoader();
J9MemorySegmentPointer segment = findSegmentInClassLoaderForAddress(classLoader, romClass);
if (!segment.isNull()) {
long address;
if (romClass.interfaceCount().longValue() != 0) {
address = romClass.interfaces().getAddress();
verifyAddressInSegment(out, vm, segment, address, "romClass->interfaces");
}
if (romClass.romMethodCount().longValue() != 0) {
address = romClass.romMethods().longValue();
verifyAddressInSegment(out, vm, segment, address, "romClass->romMethods");
}
if (romClass.romFieldCount().longValue() != 0) {
address = romClass.romFields().longValue();
verifyAddressInSegment(out, vm, segment, address, "romClass->romFields");
}
if (romClass.innerClassCount().longValue() != 0) {
address = romClass.innerClasses().longValue();
verifyAddressInSegment(out, vm, segment, address, "romClass->innerClasses");
}
U32Pointer cpShapeDescription = romClass.cpShapeDescription();
/* TODO: is !isNull() check required or not? */
if (!cpShapeDescription.isNull()) {
address = cpShapeDescription.getAddress();
verifyAddressInSegment(out, vm, segment, address, "romClass->cpShapeDescription");
}
}
{
J9UTF8Pointer className = romClass.className();
J9UTF8Pointer superclassName = romClass.superclassName();
J9UTF8Pointer outerClassName = romClass.outerClassName();
if (className.isNull() || !verifyUTF8(className)) {
reportError(out, "invalid className=0x%s utf8 for romClass=0x%s", Long.toHexString(className.getAddress()), Long.toHexString(romClass.getAddress()));
}
if (!superclassName.isNull() && !verifyUTF8(superclassName)) {
reportError(out, "invalid superclassName=0x%s utf8 for romClass=0x%s", Long.toHexString(superclassName.getAddress()), Long.toHexString(romClass.getAddress()));
}
if (!outerClassName.isNull() && !verifyUTF8(outerClassName)) {
reportError(out, "invalid outerclassName=0x%s utf8 for romClass=0x%s", Long.toHexString(outerClassName.getAddress()), Long.toHexString(romClass.getAddress()));
}
}
U32 ramConstantPoolCount = romClass.ramConstantPoolCount();
U32 romConstantPoolCount = romClass.romConstantPoolCount();
if (ramConstantPoolCount.gt(romConstantPoolCount)) {
reportError(out, "ramConstantPoolCount=%d > romConstantPoolCount=%d for romClass=0x%s", ramConstantPoolCount.longValue(), romConstantPoolCount.longValue(), Long.toHexString(romClass.getAddress()));
}
}
use of com.ibm.j9ddr.vm29.types.U32 in project openj9 by eclipse.
the class VmCheckCommand method decodeUTF8CharN.
/**
* Decode the UTF8 character.
*
* Decode the input UTF8 character and stores it into result.
*
* @param[in] input The UTF8 character
* @param[out] result buffer for unicode characters
* @param[in] bytesRemaining number of bytes remaining in input
*
* @return The number of UTF8 characters consumed (1,2,3) on success, 0 on
* failure
* @throws CorruptDataException
* @note Don't read more than bytesRemaining characters.
* @note If morecharacters are required to fully decode the character,
* return failure
*/
U32 decodeUTF8CharN(U8Pointer input, /**
* not used *
*/
U16 result, UDATA bytesRemaining) throws CorruptDataException {
U8 c;
U8Pointer cursor = input;
if (bytesRemaining.longValue() < 1) {
return new U32(0);
}
c = cursor.at(0);
cursor = cursor.add(1);
if (c.eq(0x0)) {
/* illegal NUL encoding */
return new U32(0);
} else if ((c.bitAnd(0x80)).eq(0x0)) {
// *result = (U_16)c;
return new U32(1);
} else if (c.bitAnd(0xE0).eq(0xC0)) {
/* two byte encoding */
U16 unicodeC;
if (bytesRemaining.lt(2)) {
return new U32(0);
}
unicodeC = new U16(c.bitAnd(0x1F).leftShift(6));
c = cursor.at(0);
cursor = cursor.add(1);
unicodeC = unicodeC.add(new U16(unicodeC.add(c.bitAnd(0x3F))));
if (!c.bitAnd(0xC0).eq(0x80)) {
return new U32(0);
}
// *result = unicodeC;
return new U32(2);
} else if (c.bitAnd(0xF0).eq(0xE0)) {
/* three byte encoding */
U16 unicodeC;
if (bytesRemaining.lt(3)) {
return new U32(0);
}
unicodeC = new U16(c.bitAnd(0x0F).leftShift(12));
c = cursor.at(0);
cursor = cursor.add(1);
unicodeC = unicodeC.add(new U16(c.bitAnd(0x3F).leftShift(6)));
if (!c.bitAnd(0xC0).eq(0x80)) {
return new U32(0);
}
c = cursor.at(0);
cursor = cursor.add(1);
unicodeC = unicodeC.add(new U16(c.bitAnd(0x3F)));
if (!c.bitAnd(0xC0).eq(0x80)) {
return new U32(0);
}
// *result = unicodeC;
return new U32(3);
} else {
return new U32(0);
}
}
use of com.ibm.j9ddr.vm29.types.U32 in project openj9 by eclipse.
the class DTFJJavaClass method getDeclaredFields.
@SuppressWarnings("rawtypes")
public Iterator getDeclaredFields() {
List<Object> list = declaredFieldsCache.get(j9class);
if (list == null) {
list = new LinkedList<Object>();
final List<Object> fieldList = list;
IEventListener corruptDataListener = new IEventListener() {
public void corruptData(String message, com.ibm.j9ddr.CorruptDataException e, boolean fatal) {
J9DDRCorruptData cd = J9DDRDTFJUtils.newCorruptData(DTFJContext.getProcess(), e);
fieldList.add(cd);
}
};
try {
register(corruptDataListener);
J9ClassPointer superclass = J9ClassPointer.NULL;
try {
superclass = getSuperClassPointer();
} catch (com.ibm.j9ddr.CorruptDataException e1) {
// pass null for the superclass to just list this classes fields as cannot determine superclass
fieldList.add(J9DDRDTFJUtils.newCorruptData(DTFJContext.getProcess(), "Unable to determine superclass"));
}
U32 flags = new U32(J9ROMFieldOffsetWalkState.J9VM_FIELD_OFFSET_WALK_INCLUDE_STATIC | J9ROMFieldOffsetWalkState.J9VM_FIELD_OFFSET_WALK_INCLUDE_INSTANCE);
long fieldCount = j9class.romClass().romFieldCount().longValue();
Iterator<J9ObjectFieldOffset> fields = null;
if (fieldCount > MAX_CLASS_FIELDS) {
fieldList.add(J9DDRDTFJUtils.newCorruptData(DTFJContext.getProcess(), "Corrupt field count"));
} else {
fields = J9ObjectFieldOffsetIterator.J9ObjectFieldOffsetIteratorFor(j9class, superclass, flags);
}
while (fields != null && fields.hasNext()) {
try {
J9ObjectFieldOffset field = fields.next();
log.fine(String.format("Declared field : %s", field.getName()));
if (field.isStatic()) {
fieldList.add(new DTFJJavaFieldStatic(this, field));
} else {
fieldList.add(new DTFJJavaFieldInstance(this, field));
}
} catch (com.ibm.j9ddr.CorruptDataException e) {
// add the corrupted field to the iterator
fieldList.add(J9DDRDTFJUtils.newCorruptData(DTFJContext.getProcess(), e));
}
if (fieldList.size() > fieldCount) {
// The class has returned more fields than it said it contained, it is corrupt.
// add the corrupted field to the iterator
fieldList.add(J9DDRDTFJUtils.newCorruptData(DTFJContext.getProcess(), "Corrupt class returned more fields than it declared"));
break;
}
}
/* Large lists of fields are likely to be corrupt data so
* don't cache them.
*/
if (fieldList.size() < 1024) {
declaredFieldsCache.put(j9class, fieldList);
}
} catch (Throwable t) {
fieldList.add(J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t));
} finally {
unregister(corruptDataListener);
}
}
return list.iterator();
}
Aggregations