use of com.ibm.j9ddr.vm29.pointer.U8Pointer in project openj9 by eclipse.
the class CheckVMThreadStacks method dumpStackTrace.
/* TODO : this is an implementation of the internal VM function dumpStackTrace
* and really should be somewhere global and public */
private void dumpStackTrace(J9VMThreadPointer walkThread) {
WalkState walkState = new WalkState();
walkState.walkThread = walkThread;
walkState.flags = J9_STACKWALK_VISIBLE_ONLY | J9_STACKWALK_INCLUDE_NATIVES | J9_STACKWALK_ITERATE_FRAMES;
walkState.callBacks = new BaseStackWalkerCallbacks() {
public FrameCallbackResult frameWalkFunction(J9VMThreadPointer walkThread, WalkState walkState) {
String className = "(unknown class)";
if (walkState.constantPool.notNull()) {
try {
className = J9ClassHelper.getName(walkState.constantPool.ramClass());
} catch (CorruptDataException e) {
// TODO Auto-generated catch block
}
}
if (walkState.method.isNull()) {
getReporter().println(String.format("0x%08X %s (unknown method)", walkState.pc.getAddress(), className));
} else {
if (walkState.jitInfo.isNull()) {
boolean isNative = false;
U8Pointer bytecodes = U8Pointer.NULL;
String name = "(corrupt)";
String sig = "(corrupt)";
try {
J9ROMMethodPointer romMethod = J9MethodHelper.romMethod(walkState.method);
isNative = romMethod.modifiers().allBitsIn(J9_JAVA_NATIVE);
if (!isNative) {
bytecodes = J9ROMMethodHelper.bytecodes(romMethod);
}
name = J9ROMMethodHelper.getName(romMethod);
sig = J9ROMMethodHelper.getSignature(romMethod);
} catch (CorruptDataException e) {
// This should never happen
}
if (isNative) {
getReporter().println(String.format(" NATIVE %s.%s%s", className, name, sig));
} else {
getReporter().println(String.format(" %08X %s.%s%s", walkState.pc.sub(bytecodes).longValue(), className, name, sig));
}
} else {
boolean isInlined = walkState.inlineDepth != 0;
U8Pointer jitPC = walkState.pc;
String name = "(corrupt)";
String sig = "(corrupt)";
try {
J9ROMMethodPointer romMethod = J9MethodHelper.romMethod(walkState.method);
name = J9UTF8Helper.stringValue(romMethod.nameAndSignature().name());
sig = J9UTF8Helper.stringValue(romMethod.nameAndSignature().signature());
if (!isInlined) {
jitPC = U8Pointer.cast(jitPC.sub(U8Pointer.cast(walkState.method.extra())).longValue());
}
} catch (CorruptDataException e) {
// This should never happen
}
if (isInlined) {
getReporter().println(String.format(" INLINED %s.%s%s (@%s)", className, name, sig, formatPointer(walkState.pc)));
} else {
getReporter().println(String.format(" %08X %s.%s%s (@%s)", jitPC.getAddress(), className, name, sig, formatPointer(walkState.pc)));
}
}
}
return FrameCallbackResult.KEEP_ITERATING;
}
};
StackWalker.walkStackFrames(walkState);
}
use of com.ibm.j9ddr.vm29.pointer.U8Pointer in project openj9 by eclipse.
the class J9ObjectStructureFormatter method format.
@Override
public FormatWalkResult format(String type, long address, PrintStream out, Context context, List<IFieldFormatter> fieldFormatters, String[] extraArgs) {
if (type.equalsIgnoreCase("j9object") || type.equalsIgnoreCase("j9indexableobject")) {
J9ClassPointer clazz = null;
J9ObjectPointer object = null;
try {
boolean isArray;
String className;
object = J9ObjectPointer.cast(address);
clazz = J9ObjectHelper.clazz(object);
if (clazz.isNull()) {
out.println("<can not read RAM class address>");
return FormatWalkResult.STOP_WALKING;
}
isArray = J9ClassHelper.isArrayClass(clazz);
className = J9UTF8Helper.stringValue(clazz.romClass().className());
U8Pointer dataStart = U8Pointer.cast(object).add(ObjectModel.getHeaderSize(object));
if (className.equals("java/lang/String")) {
formatStringObject(out, 0, clazz, dataStart, object);
} else if (isArray) {
int begin = DEFAULT_ARRAY_FORMAT_BEGIN;
int end = DEFAULT_ARRAY_FORMAT_END;
if (extraArgs.length > 0) {
begin = Integer.parseInt(extraArgs[0]);
}
if (extraArgs.length > 1) {
end = Integer.parseInt(extraArgs[1]);
}
formatArrayObject(out, clazz, dataStart, J9IndexableObjectPointer.cast(object), begin, end);
} else {
formatObject(out, clazz, dataStart, object);
}
} catch (MemoryFault ex2) {
out.println("Unable to read object clazz at " + object.getHexAddress() + " (clazz = " + clazz.getHexAddress() + ")");
} catch (CorruptDataException ex) {
out.println("Error for ");
ex.printStackTrace(out);
}
return FormatWalkResult.STOP_WALKING;
} else {
return FormatWalkResult.KEEP_WALKING;
}
}
use of com.ibm.j9ddr.vm29.pointer.U8Pointer in project openj9 by eclipse.
the class J9ObjectStructureFormatter method printJ9ObjectFields.
private void printJ9ObjectFields(PrintStream out, int tabLevel, J9ClassPointer localClazz, U8Pointer dataStart, J9ObjectPointer localObject) throws CorruptDataException {
J9ClassPointer instanceClass = localClazz;
long superclassIndex;
long depth;
J9ClassPointer previousSuperclass = J9ClassPointer.NULL;
boolean lockwordPrinted = false;
if (J9BuildFlags.thr_lockNursery) {
lockwordPrinted = false;
}
/* print individual fields */
J9UTF8Pointer classNameUTF = instanceClass.romClass().className();
padding(out, tabLevel);
out.println(String.format("struct J9Class* clazz = !j9class 0x%X // %s", localClazz.getAddress(), J9UTF8Helper.stringValue(classNameUTF)));
padding(out, tabLevel);
out.println(String.format("Object flags = %s;", J9ObjectHelper.flags(localObject).getHexValue()));
if (!J9BuildFlags.thr_lockNursery) {
UDATA lockword = J9ObjectHelper.monitor(localObject);
if (lockword != null) {
padding(out, tabLevel);
out.println(String.format("j9objectmonitor_t monitor = %s;", lockword.getHexValue()));
}
}
depth = J9ClassHelper.classDepth(instanceClass).longValue();
for (superclassIndex = 0; superclassIndex <= depth; superclassIndex++) {
J9ClassPointer superclass;
if (superclassIndex == depth) {
superclass = instanceClass;
} else {
superclass = J9ClassPointer.cast(instanceClass.superclasses().at(superclassIndex));
}
U32 flags = new U32(J9VM_FIELD_OFFSET_WALK_INCLUDE_INSTANCE | J9VM_FIELD_OFFSET_WALK_INCLUDE_HIDDEN);
Iterator<J9ObjectFieldOffset> iterator = J9ObjectFieldOffsetIterator.J9ObjectFieldOffsetIteratorFor(superclass.romClass(), instanceClass, previousSuperclass, flags);
while (iterator.hasNext()) {
J9ObjectFieldOffset result = iterator.next();
boolean printField = true;
boolean isHiddenField = result.isHidden();
if (J9BuildFlags.thr_lockNursery) {
boolean isLockword = (isHiddenField && ((result.getOffsetOrAddress().add(J9Object.SIZEOF).eq(superclass.lockOffset()))));
if (isLockword) {
/* Print the lockword field if it is indeed the lockword for this instanceClass and we haven't printed it yet. */
printField = (!lockwordPrinted && (instanceClass.lockOffset().eq(superclass.lockOffset())));
if (printField) {
lockwordPrinted = true;
}
}
}
if (printField) {
printObjectField(out, tabLevel, localClazz, dataStart, superclass, result);
out.println();
}
}
previousSuperclass = superclass;
}
}
use of com.ibm.j9ddr.vm29.pointer.U8Pointer in project openj9 by eclipse.
the class DTFJJavaHeap method toString.
@Override
public String toString() {
if (description == null) {
try {
U8Pointer minBase = U8Pointer.cast(-1);
U8Pointer maxTop = U8Pointer.cast(0);
String name = space._name().getCStringAtOffset(0);
Iterator<GCHeapRegionDescriptor> it = regions.iterator();
while (it.hasNext()) {
GCHeapRegionDescriptor region = it.next();
U8Pointer base = U8Pointer.cast(region.getLowAddress());
U8Pointer top = U8Pointer.cast(region.getHighAddress());
if (base.lt(minBase)) {
minBase = base;
}
if (top.gt(maxTop)) {
maxTop = top;
}
}
description = String.format("%s [%s, Span: 0x%08x->0x%08x, Regions: %d]", getName(), name, minBase.getAddress(), maxTop.getAddress(), regions.size());
} catch (Throwable t) {
J9DDRDTFJUtils.handleAsCorruptDataException(DTFJContext.getProcess(), t);
description = super.toString();
}
}
return description;
}
use of com.ibm.j9ddr.vm29.pointer.U8Pointer in project openj9 by eclipse.
the class DTFJJavaRuntime method getHeaps.
@SuppressWarnings("rawtypes")
public Iterator getHeaps() throws UnsupportedOperationException {
try {
LinkedList<Object> heaps = new LinkedList<Object>();
VoidPointer memorySpace = DTFJContext.getVm().defaultMemorySpace();
MM_MemorySpacePointer defaultMemorySpace = MM_MemorySpacePointer.cast(memorySpace);
U8Pointer namePtr = defaultMemorySpace._name();
// MEMORY_SPACE_NAME_UNDEFINED
String name = "No name";
if (namePtr != null && namePtr != U8Pointer.NULL) {
try {
name = namePtr.getCStringAtOffset(0);
} catch (com.ibm.j9ddr.CorruptDataException e) {
name = "<<corrupt heap name>>";
}
}
heaps.add(new DTFJJavaHeap(defaultMemorySpace, name, DTFJContext.getImagePointer(memorySpace.getAddress())));
return heaps.iterator();
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
return corruptIterator(cd);
}
}
Aggregations