use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class ImageStackFrame method getProcedureName.
public String getProcedureName() throws CorruptDataException {
if (null == _procedureName) {
ImageModule bestModule = null;
ImageSymbol bestClosest = null;
long bestDelta = Long.MAX_VALUE;
for (Iterator i = this._space.getProcesses(); i.hasNext(); ) {
Object nexti = i.next();
if (nexti instanceof CorruptData)
continue;
ImageProcess process = (ImageProcess) nexti;
if ((_procedureAddress.getAddress() != ((1L << process.getPointerSize()) - 1))) {
try {
ImageModule module = process.getExecutable();
ImageSymbol closest = getClosestSymbolFrom(module);
long delta = getDelta(module, closest);
if (delta >= 0 && delta < bestDelta) {
bestModule = module;
bestClosest = closest;
bestDelta = delta;
}
} catch (DataUnavailable e) {
} catch (CorruptDataException e) {
}
try {
for (Iterator j = process.getLibraries(); j.hasNext(); ) {
Object next = j.next();
if (next instanceof CorruptData)
continue;
ImageModule module = (ImageModule) next;
ImageSymbol closest = getClosestSymbolFrom(module);
long delta = getDelta(module, closest);
if (delta >= 0 && delta < bestDelta) {
bestModule = module;
bestClosest = closest;
bestDelta = delta;
}
}
} catch (DataUnavailable e) {
} catch (CorruptDataException e) {
}
}
}
ImageSymbol closest = bestClosest;
ImageModule module = bestModule;
long delta = bestDelta;
if (null != module) {
String deltaString = "";
if (delta == Long.MAX_VALUE) {
deltaString = "<offset not available>";
} else {
if (delta >= 0) {
deltaString = "+0x" + Long.toHexString(delta);
} else {
deltaString = "-0x" + Long.toHexString(delta);
}
}
if (null != closest) {
_procedureName = module.getName() + "::" + closest.getName() + deltaString;
} else {
_procedureName = module.getName() + deltaString;
}
}
}
// If we haven't found the symbol, we might as well record that fact.
if (null == _procedureName) {
_procedureName = "<unknown location>";
}
return _procedureName;
}
use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class XMLIndexReader method setJ9DumpData.
public void setJ9DumpData(long environ, String osType, String osSubType, String cpuType, int cpuCount, long bytesMem, int pointerSize, Image[] imageRef, ImageAddressSpace[] addressSpaceRef, ImageProcess[] processRef) {
Builder builder = null;
if (_stream == null) {
// extract directly from the file
builder = new Builder(_coreFile, _reader, environ, _fileResolvingAgent);
} else {
// extract using the data stream
builder = new Builder(_coreFile, _stream, environ, _fileResolvingAgent);
}
_coreFile.extract(builder);
// Jazz 4961 : chamlain : NumberFormatException opening corrupt dump
if (cpuType == null)
cpuType = builder.getCPUType();
String cpuSubType = builder.getCPUSubType();
if (osType == null)
osType = builder.getOSType();
long creationTime = builder.getCreationTime();
_coreImage = new Image(osType, osSubType, cpuType, cpuSubType, cpuCount, bytesMem, creationTime);
ImageAddressSpace addressSpace = (ImageAddressSpace) builder.getAddressSpaces().next();
ImageProcess process = (ImageProcess) addressSpace.getCurrentProcess();
// If not sure, use the first address space/process pair found
for (Iterator it = builder.getAddressSpaces(); it.hasNext(); ) {
ImageAddressSpace addressSpace1 = (ImageAddressSpace) it.next();
final boolean vb = false;
if (vb)
System.out.println("address space " + addressSpace1);
_coreImage.addAddressSpace(addressSpace1);
for (Iterator it2 = addressSpace1.getProcesses(); it2.hasNext(); ) {
ImageProcess process1 = (ImageProcess) it2.next();
if (vb)
try {
System.out.println("process " + process1.getID());
} catch (DataUnavailable e) {
} catch (CorruptDataException e) {
}
if (process == null || isProcessForEnvironment(environ, addressSpace1, process1)) {
addressSpace = addressSpace1;
process = process1;
if (vb)
System.out.println("default process for Runtime");
}
}
}
if (null != process) {
// z/OS can have 64-bit or 31-bit processes, Java only reports 64-bit or 32-bit.
if (process.getPointerSize() != pointerSize && !(process.getPointerSize() == 31 && pointerSize == 32)) {
System.out.println("XML and core file pointer sizes differ " + process.getPointerSize() + "!=" + pointerSize);
}
} else {
throw new IllegalStateException("No process found in the dump.");
}
imageRef[0] = _coreImage;
addressSpaceRef[0] = addressSpace;
processRef[0] = process;
}
use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class NodeJavaVM method didFinishParsing.
public void didFinishParsing() {
Iterator classLoaders = _runtime.getJavaClassLoaders();
while (classLoaders.hasNext()) {
Object potentialClassLoader = classLoaders.next();
if (potentialClassLoader instanceof JavaClassLoader) {
JavaClassLoader loader = (JavaClassLoader) potentialClassLoader;
// sets the associated object
try {
Object potentialLoaderObject = loader.getObject();
if (null != potentialLoaderObject && potentialLoaderObject instanceof com.ibm.dtfj.java.j9.JavaObject) {
JavaObject loaderObject = (com.ibm.dtfj.java.j9.JavaObject) potentialLoaderObject;
loaderObject.setAssociatedClassLoader(loader);
_runtime.addSpecialObject(loaderObject);
Iterator classes = loader.getDefinedClasses();
while (classes.hasNext()) {
Object potentialClass = classes.next();
if (potentialClass instanceof JavaClass) {
JavaClass theClass = (JavaClass) potentialClass;
try {
Object potentialClassObject = theClass.getObject();
if (null != potentialClassObject && potentialClassObject instanceof com.ibm.dtfj.java.j9.JavaObject) {
JavaObject classObject = (com.ibm.dtfj.java.j9.JavaObject) potentialClassObject;
classObject.setAssociatedClass(theClass);
_runtime.addSpecialObject(classObject);
}
} catch (CorruptDataException e) {
// no reason to skip the other classloaders/classes just because an exception is thrown on one class
} catch (IllegalArgumentException e) {
// CMVC 173262 : JavaClass.getObject() uses JavaHeap.getObjectAtAddress() which can throw this exception
}
}
}
}
} catch (CorruptDataException e) {
// associated object not set
}
}
}
Iterator monitors = _runtime.getMonitors();
while (monitors.hasNext()) {
Object potentialMonitor = monitors.next();
if (potentialMonitor instanceof JavaMonitor) {
JavaMonitor monitor = (JavaMonitor) potentialMonitor;
// sets the associated object
Object potentialMonitorObject = monitor.getObject();
if (null != potentialMonitorObject && potentialMonitorObject instanceof com.ibm.dtfj.java.j9.JavaObject) {
JavaObject monitorObject = (com.ibm.dtfj.java.j9.JavaObject) potentialMonitorObject;
monitorObject.setAssociatedMonitor(monitor);
_runtime.addSpecialObject(monitorObject);
}
}
}
Iterator threads = _runtime.getThreads();
while (threads.hasNext()) {
Object potentialThread = threads.next();
if (potentialThread instanceof JavaThread) {
JavaThread thread = (JavaThread) potentialThread;
// sets the associated object
try {
Object potentialThreadObject = thread.getObject();
if (null != potentialThreadObject && potentialThreadObject instanceof com.ibm.dtfj.java.j9.JavaObject) {
JavaObject threadObject = (com.ibm.dtfj.java.j9.JavaObject) potentialThreadObject;
threadObject.setAssociatedThread(thread);
_runtime.addSpecialObject(threadObject);
}
} catch (CorruptDataException e) {
// associated object not set
}
}
}
}
use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class InfoThreadCommand method printJavaStackFrameInfo.
private void printJavaStackFrameInfo(JavaThread jt) {
Iterator itStackFrame;
JavaStackFrame jsf;
JavaLocation jl;
itStackFrame = jt.getStackFrames();
if (!itStackFrame.hasNext()) {
out.print("<no frames to print>\n");
return;
} else {
out.print("\n");
}
while (itStackFrame.hasNext()) {
// this iterator can contain JavaStackFrame or CorruptData objects
Object next = itStackFrame.next();
if (next instanceof CorruptData) {
out.print(" " + Exceptions.getCorruptDataExceptionString() + "\n");
return;
} else {
jsf = (JavaStackFrame) next;
}
try {
jl = jsf.getLocation();
} catch (CorruptDataException e) {
out.print(" " + Exceptions.getCorruptDataExceptionString() + "\n");
logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), e);
return;
}
out.print(" bp: ");
try {
out.print(toAdjustedHex(jsf.getBasePointer().getAddress()));
} catch (CorruptDataException e) {
// jsf.getBasePointer() can't throw DataUnavailable, so we don't know if this is really
// a corruption. Log the exception but revert to issuing a DataUnavailable message.
out.print(Exceptions.getDataUnavailableString());
logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), e);
}
out.print(" method: ");
try {
String signature = null;
try {
signature = jl.getMethod().getSignature();
} catch (CorruptDataException e) {
// jl.getMethod() can't throw DataUnavailable, so we don't know if this is really a
// corruption. I don't think we need to be pedantic and insert 'not available' where
// the return type and the parameter types would be. Just print class name and method.
logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), e);
}
if (signature == null) {
out.print(jl.getMethod().getDeclaringClass().getName() + "." + jl.getMethod().getName());
} else {
out.print(Utils.getReturnValueName(signature) + " " + jl.getMethod().getDeclaringClass().getName() + "." + jl.getMethod().getName() + Utils.getMethodSignatureName(signature));
}
} catch (CorruptDataException e) {
out.print(Exceptions.getCorruptDataExceptionString());
logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), e);
} catch (DataUnavailable e) {
out.print(Exceptions.getDataUnavailableString());
logger.log(Level.FINEST, Exceptions.getDataUnavailableString(), e);
}
// Assume the method is a java method in case of corrupt data.
boolean isNative = false;
try {
isNative = Modifier.isNative(jl.getMethod().getModifiers());
} catch (CorruptDataException e) {
logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), e);
}
if (!isNative) {
out.print(" source: ");
try {
out.print(jl.getFilename());
} catch (DataUnavailable d) {
out.print(Exceptions.getDataUnavailableString());
logger.log(Level.FINEST, Exceptions.getDataUnavailableString(), d);
} catch (CorruptDataException e) {
out.print(Exceptions.getCorruptDataExceptionString());
logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), e);
}
out.print(":");
try {
out.print(Integer.toString(jl.getLineNumber()));
} catch (DataUnavailable d) {
out.print(Exceptions.getDataUnavailableString());
logger.log(Level.FINE, Exceptions.getDataUnavailableString(), d);
} catch (CorruptDataException e) {
out.print(Exceptions.getCorruptDataExceptionString());
logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), e);
}
} else {
out.print(" (Native Method)");
}
out.print("\n objects:");
Iterator itObjectRefs = jsf.getHeapRoots();
if (!itObjectRefs.hasNext()) {
out.print(" <no objects in this frame>");
}
while (itObjectRefs.hasNext()) {
Object nextRef = itObjectRefs.next();
if (nextRef instanceof CorruptData) {
out.print(Exceptions.getCorruptDataExceptionString() + "\n");
// give up on this frame
break;
} else {
JavaReference jr = (JavaReference) nextRef;
try {
if (jr.isObjectReference()) {
JavaObject target = (JavaObject) (jr.getTarget());
out.print(" " + Utils.toHex(target.getID().getAddress()));
}
} catch (DataUnavailable d) {
out.print(Exceptions.getDataUnavailableString());
logger.log(Level.FINEST, Exceptions.getDataUnavailableString(), d);
} catch (CorruptDataException e) {
out.print(Exceptions.getCorruptDataExceptionString());
logger.log(Level.FINEST, Exceptions.getCorruptDataExceptionString(), e);
} catch (NullPointerException n) {
out.print(Exceptions.getDataUnavailableString());
logger.log(Level.FINEST, Exceptions.getDataUnavailableString(), n);
}
}
}
out.print("\n");
}
}
use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class XKCommand method printSymbol.
private boolean printSymbol(long pointer, long diff, int pointerSize) {
ImageProcess ip = ctx.getProcess();
Iterator itModule;
try {
itModule = ip.getLibraries();
} catch (CorruptDataException e) {
// FIXME
itModule = null;
} catch (DataUnavailable e) {
// FIXME
itModule = null;
}
while (null != itModule && itModule.hasNext()) {
ImageModule im = (ImageModule) itModule.next();
Iterator itImageSection = im.getSections();
while (itImageSection.hasNext()) {
ImageSection is = (ImageSection) itImageSection.next();
long startAddr = is.getBaseAddress().getAddress();
long endAddr = startAddr + is.getSize();
if (pointer >= startAddr && pointer < endAddr) {
/* can we find a matching symbol? */
long maxDifference = pointer - startAddr;
ImageSymbol bestSymbol = null;
for (Iterator iter = im.getSymbols(); iter.hasNext(); ) {
Object next = iter.next();
if (next instanceof CorruptData)
continue;
ImageSymbol symbol = (ImageSymbol) next;
long symbolAddress = symbol.getAddress().getAddress();
if (symbolAddress <= pointer && pointer - symbolAddress < maxDifference) {
maxDifference = pointer - symbolAddress;
bestSymbol = symbol;
}
}
try {
out.print(im.getName());
} catch (CorruptDataException e) {
out.print(Exceptions.getCorruptDataExceptionString());
}
out.print("::");
if (bestSymbol == null) {
out.print(is.getName());
} else {
out.print(bestSymbol.getName());
}
out.print("+");
out.print(Long.toString(maxDifference));
// trying to find it elsewhere in the address space
return true;
}
}
}
return false;
}
Aggregations