use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class HeapdumpCommand method getVersionString.
/**
* DTFJ for dumps prior to JVM 2.6 provides multi-line version information. This method extracts the second line, eg:
* "IBM J9 VM(JRE 1.6.0 IBM J9 2.4 Windows 7 amd64-64 jvmwa6460sr17-20140620_203740 (JIT enabled, AOT enabled)"
* DTFJ for dumps from JVM 2.6 and later provide just a single-line version, for example:
* "JRE 1.6.0 Windows 7 amd64-64 build 20111101_93964 (pwa6460_26sr1-20111103_01(SR1))"
*/
private String getVersionString(JavaRuntime runtime) {
try {
String rawVersion = runtime.getVersion();
Matcher matcher = J9_VERSION_PATTERN.matcher(rawVersion);
if (matcher.find()) {
// dump prior to JVM 2.6, extract single line version string
String minimalVersion = matcher.group(1);
return minimalVersion;
} else {
// dump from JVM 2.6 or later, return unchanged version string
return rawVersion;
}
} catch (CorruptDataException e) {
_numberOfErrors++;
out.println("Could not read version string from dump: data corrupted at " + e.getCorruptData().getAddress());
return "*Corrupt*";
}
}
use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class HeapdumpCommand method dumpHeap.
/**
* Walks the supplied heap and passes the artifacts through the formatter
*/
private void dumpHeap(HeapDumpFormatter formatter, JavaHeap thisHeap) throws IOException {
Iterator objectIterator = thisHeap.getObjects();
while (objectIterator.hasNext()) {
Object next = objectIterator.next();
_numberOfObjects++;
if (next instanceof CorruptData) {
_numberOfErrors++;
reportError("Corrupt object data found at " + ((CorruptData) next).getAddress() + " while walking heap " + thisHeap.getName(), null);
continue;
}
try {
JavaObject thisObject = (JavaObject) next;
if (thisObject.getJavaClass().getName().equals("java/lang/Class")) {
// heap classes are handled separately, in dumpClasses()
continue;
}
JavaClass thisClass = thisObject.getJavaClass();
JavaObject thisClassObject = thisClass.getObject();
int hashcode = 0;
if (_is32BitHash) {
// JVMs from 2.6 on, optional 32-bit hashcodes, if object was hashed
try {
hashcode = (int) thisObject.getPersistentHashcode();
} catch (DataUnavailable ex) {
// no persistent hashcode for this object, pass hashcode=0 to the heapdump formatter
}
} else {
// JVMs prior to 2.6, all objects should have a 16-bit hashcode
try {
hashcode = (int) thisObject.getHashcode();
} catch (DataUnavailable ex) {
_numberOfErrors++;
reportError("Failed to get hashcode for object: " + thisObject.getID(), ex);
}
}
if (thisObject.isArray()) {
if (isPrimitive(thisClass.getComponentType())) {
formatter.addPrimitiveArray(thisObject.getID().getAddress(), thisClassObject.getID().getAddress(), getPrimitiveTypeCode(thisClass.getComponentType()), thisObject.getSize(), hashcode, thisObject.getArraySize());
} else {
formatter.addObjectArray(thisObject.getID().getAddress(), thisClassObject.getID().getAddress(), thisClass.getName(), thisClass.getComponentType().getObject().getID().getAddress(), thisClass.getComponentType().getName(), thisObject.getSize(), thisObject.getArraySize(), hashcode, getObjectReferences(thisObject));
}
} else {
formatter.addObject(thisObject.getID().getAddress(), thisClassObject.getID().getAddress(), thisClass.getName(), (int) thisObject.getSize(), hashcode, getObjectReferences(thisObject));
}
} catch (CorruptDataException ex) {
_numberOfErrors++;
reportError(null, ex);
continue;
}
}
}
use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class HexdumpCommand method doCommand.
public void doCommand(String[] args) {
StringBuffer stringBuffer = new StringBuffer();
ImageAddressSpace imageAddressSpace = ctx.getAddressSpace();
if (null == imageAddressSpace) {
out.println("Could not find an address space which contains a process in this core file");
return;
}
long addressInDecimal = 0;
// dump 256 bytes by default
int numBytesToPrint = 16 * 16;
int asciiIndex = 0;
if (args.length != 0) {
Long address = Utils.longFromString(args[0]);
if (null == address) {
out.println("Specified address is invalid");
return;
}
addressInDecimal = address.longValue();
} else {
out.println("\"hexdump\" requires at least an address parameter");
return;
}
if (args.length > 1) {
try {
numBytesToPrint = Integer.parseInt(args[1]);
} catch (NumberFormatException nfe) {
out.println("Specified length is invalid");
return;
}
}
ImagePointer imagePointerBase = imageAddressSpace.getPointer(addressInDecimal);
boolean is_zOSdump = false;
try {
is_zOSdump = ctx.getImage().getSystemType().toLowerCase().indexOf("z/os") >= 0;
} catch (DataUnavailable e1) {
// unable to get the dump OS type, continue without the additional zOS EBCDIC option
} catch (CorruptDataException e1) {
// unable to get the dump OS type, continue without the additional zOS EBCDIC option
}
String asciiChars = "";
String ebcdicChars = "";
long i;
for (i = 0; i < numBytesToPrint; i++) {
ImagePointer imagePointer = imagePointerBase.add(i);
// stringBuffer.append(Long.toHexString(imagePointer.getAddress())+":\t");
try {
Byte byteValue = new Byte(imagePointer.getByteAt(0));
asciiIndex = (int) byteValue.byteValue();
if (asciiIndex < 0) {
asciiIndex += 256;
}
String rawHexString = Integer.toHexString(byteValue.intValue());
String fixedHexString = fixHexStringLength(rawHexString);
String hexText = fixedHexString;
if (0 == i % 4) {
hexText = " " + hexText;
}
if (0 == i % 16) {
hexText = "\n" + Long.toHexString(imagePointer.getAddress()) + ":" + hexText;
asciiChars = " |";
ebcdicChars = " |";
}
stringBuffer.append(hexText);
asciiChars += Utils.byteToAscii.substring(asciiIndex, asciiIndex + 1);
if (15 == i % 16 && i != 0) {
asciiChars += "|";
stringBuffer.append(asciiChars);
}
if (is_zOSdump) {
// for zOS dumps, output additional EBCDIC interpretation of the memory byes
ebcdicChars += Utils.byteToEbcdic.substring(asciiIndex, asciiIndex + 1);
if (15 == i % 16 && i != 0) {
ebcdicChars += "|";
stringBuffer.append(ebcdicChars);
}
}
} catch (MemoryAccessException e) {
out.println("Address not in memory - 0x" + Long.toHexString(imagePointer.getAddress()));
return;
} catch (CorruptDataException e) {
out.println("Dump data is corrupted");
return;
}
}
long undisplayedBytes = 16 - i % 16;
if (16 != undisplayedBytes) {
stringBuffer.append(padSpace(undisplayedBytes, asciiChars));
if (is_zOSdump) {
// Add padding and output the remaining EBCDIC characters
for (int j = 0; j < undisplayedBytes; j++) {
ebcdicChars = " " + ebcdicChars;
}
stringBuffer.append(" " + ebcdicChars);
}
}
stringBuffer.append("\n");
out.println(new String(stringBuffer));
/*properties.put(Utils.CURRENT_MEM_ADDRESS,
Long.toHexString(addressInDecimal+numBytesToPrint));*/
ctx.getProperties().put(Utils.CURRENT_MEM_ADDRESS, new Long(addressInDecimal));
ctx.getProperties().put(Utils.CURRENT_NUM_BYTES_TO_PRINT, new Integer(numBytesToPrint));
}
use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class NodeList method toString.
// Print this list of monitor nodes (ie the owning threads and there object addresses)
public String toString() {
String retval = "";
MonitorNode currNode = tail;
MonitorNode lastNode = null;
boolean firstTime = true;
boolean done = false;
do {
String name = "";
String objAddr = "";
JavaObject object = null;
JavaThread owner = null;
try {
owner = currNode.getOwner();
name = owner.getName();
ImageThread nativeThread = owner.getImageThread();
if (nativeThread != null) {
name = name + " id: " + nativeThread.getID();
}
} catch (CorruptDataException e) {
name = Exceptions.getCorruptDataExceptionString();
} catch (DataUnavailable e) {
name = Exceptions.getDataUnavailableString();
} catch (MemoryAccessException e) {
name = Exceptions.getMemoryAccessExceptionString();
}
object = currNode.getObject();
if (null == object) {
objAddr = " at : " + Utils.toHex(currNode.getMonitorAddress());
} else {
objAddr = " object : " + Utils.toHex(object.getID().getAddress());
}
String lockName = currNode.getType();
retval += "thread: " + name + " (owns " + lockName + objAddr + ") waiting for =>\n\t ";
lastNode = currNode;
currNode = currNode.waitingOn;
if (head == lastNode) {
if (firstTime && head == tail)
done = false;
else
done = true;
}
firstTime = false;
} while (!done);
// removes the tail of the last entry
retval = retval.substring(0, retval.length() - 18);
return retval;
}
use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class WhatisCommand method isStartOfObj.
private boolean isStartOfObj(Iterator objects, long address) {
String className;
long corruptObjectCount = 0;
while (objects.hasNext()) {
Object obj = objects.next();
if (obj instanceof CorruptData) {
corruptObjectCount++;
continue;
}
JavaObject jObject = (JavaObject) obj;
if (address == jObject.getID().getAddress()) {
try {
className = jObject.getJavaClass().getName();
} catch (CorruptDataException cde) {
className = "<corrupt class name>";
}
out.print("\t\t0x" + Long.toHexString(address) + " is the start of an object of type " + className);
return true;
}
}
if (corruptObjectCount > 0) {
out.println("\t\t[skipped " + corruptObjectCount + " corrupt object(s) in heap]");
}
return false;
}
Aggregations