use of com.ibm.dtfj.image.DataUnavailable in project openj9 by eclipse.
the class JavaThreadTest method getImageThreadTest.
@Test
public // JEXTRACT: only EVER throws DataUnavailableException with TCK core. We do better.
void getImageThreadTest() {
for (int i = 0; i < jextractTestObjects.size(); i++) {
JavaThread t1 = (JavaThread) jextractTestObjects.get(i);
ImageThread i1;
try {
i1 = (ImageThread) t1.getImageThread();
// System.out.println(i1.getID());
} catch (CorruptDataException e) {
System.out.println("CDE on thread: " + i);
} catch (DataUnavailable e) {
System.out.println("DUA on thread: " + i);
}
}
imageThreadComparator.testComparatorEquals(ddrTestObjects, jextractTestObjects, "getImageThread");
}
use of com.ibm.dtfj.image.DataUnavailable 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.DataUnavailable 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.DataUnavailable 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.DataUnavailable 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