use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class JavaClassLoader method getDefinedClasses.
/* (non-Javadoc)
* @see com.ibm.dtfj.java.JavaClassLoader#getDefinedClasses()
*/
public Iterator getDefinedClasses() {
if (null == _defined) {
// Loop through the list of all classes building a list of this loader's defined classes.
// A defined class is a class whose class loader is this loader
Iterator cached = _javaVM.getClasses();
long thisID = _id.getAddress();
_defined = new ArrayList();
while (cached.hasNext()) {
Object next = cached.next();
// corrupt entries by looking at the cached classes via getCachedClasses()
if (next instanceof CorruptData) {
continue;
}
// Extract the current class
JavaClass currentClass = (JavaClass) next;
try {
// Extract the current class's class loader
JavaClassLoader currentClassLoader = (JavaClassLoader) currentClass.getClassLoader();
// old versions of jextract
if ((currentClassLoader != null) && (currentClassLoader._id.getAddress() == thisID)) {
_defined.add(currentClass);
}
} catch (CorruptDataException e) {
// Ignore this one
}
}
}
return _defined.iterator();
}
use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class JavaAbstractClass method addClassObjectReference.
protected void addClassObjectReference(Collection coll) {
JavaReference jRef = null;
try {
com.ibm.dtfj.java.JavaObject classObject = this.getObject();
if (null != classObject) {
jRef = new JavaReference(_javaVM, this, classObject, "Class object", JavaReference.REFERENCE_CLASS_OBJECT, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
coll.add(jRef);
}
} catch (CorruptDataException e) {
coll.add(e.getCorruptData());
}
}
use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class PHDCorruptData method newCorruptDataException.
static CorruptDataException newCorruptDataException(PHDCorruptData cd) {
CorruptDataException e = new CorruptDataException(cd);
cd.initCause(e);
return e;
}
use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class DTFJMethod method handleException.
/**
* Handle an exception thrown by the DTFJ API.
*
* @param cmd the command current executing the API. This is required to provide access to context information.
* @param cause exception to be handled
* @return textual data to be written out
*/
public static String handleException(BaseJdmpviewCommand cmd, Throwable cause) {
ctx = cmd.ctx;
StringBuffer sb = new StringBuffer();
// Try and determine the artifact type
StackTraceElement[] myStack = cause.getStackTrace();
ArtifactType artifactType = cmd.getArtifactType();
String artifactTypeName = null;
switch(artifactType) {
case core:
artifactTypeName = "core";
break;
case javacore:
artifactTypeName = "javacore";
break;
case phd:
artifactTypeName = "phd";
break;
default:
artifactTypeName = "Unknown artifact type";
break;
}
// Let's find out which DTFJ Class/Method was being used
DTFJMethod dMethod = getDTFJMethod(myStack, cmd);
if (cause instanceof DataUnavailable) {
if (dMethod == null) {
sb.append("Could not determine DTFJ class/method that caused this exception: ");
sb.append(cause.getLocalizedMessage());
} else if (dMethod.isSupported(artifactType) == WORKS) {
sb.append(dMethod.getClassName());
sb.append(".");
sb.append(dMethod.getMethodname());
sb.append(" should have worked for a ");
sb.append(artifactTypeName);
sb.append(" but returned: ");
sb.append(cause.getLocalizedMessage());
} else if (dMethod.isSupported(artifactType) == CAN_FAIL) {
sb.append(dMethod.getClassName());
sb.append(".");
sb.append(dMethod.getMethodname());
sb.append(" can fail for a ");
sb.append(artifactTypeName);
sb.append(" which is why it returned: ");
sb.append(cause.getLocalizedMessage());
} else if (dMethod.isSupported(artifactType) == FAILS) {
sb.append(dMethod.getClassName());
sb.append(".");
sb.append(dMethod.getMethodname());
sb.append(" is not supported for a ");
sb.append(artifactTypeName);
String s = cause.getLocalizedMessage();
if (s != null) {
sb.append(" causing: ");
sb.append(s);
}
}
} else if (cause instanceof CorruptDataException) {
CorruptData corruptData = ((CorruptDataException) cause).getCorruptData();
ImagePointer ip = corruptData.getAddress();
if (ip == null) {
sb.append("CorruptData found in dump at unknown address executing ");
if (dMethod == null) {
sb.append("an unknown class/method that caused this exception: ");
sb.append(cause.getLocalizedMessage());
} else {
sb.append(dMethod.getClassName());
sb.append(".");
sb.append(dMethod.getMethodname());
}
} else {
String addr = cmd.toHexStringAddr(ip.getAddress());
sb.append("CorruptData found in dump at address: ");
sb.append(addr);
sb.append(" causing: ");
sb.append(cause.getLocalizedMessage());
if (dMethod != null) {
sb.append(" executing ");
sb.append(dMethod.getClassName());
sb.append(".");
sb.append(dMethod.getMethodname());
}
}
} else if (cause instanceof MemoryAccessException) {
sb.append(cause.getLocalizedMessage());
} else if (cause instanceof IllegalArgumentException) {
sb.append(cause.getLocalizedMessage());
} else {
// If we are here then something bad has really happened
// This is just debug code to help determine other problems this
// method has to deal with
sb.append("==========> Unexpected exception " + cause.getClass().getName() + " thrown: " + cause.getLocalizedMessage());
StringWriter st = new StringWriter();
cause.printStackTrace(new PrintWriter(st));
sb.append(st.toString());
}
return sb.toString();
}
use of com.ibm.dtfj.image.CorruptDataException in project openj9 by eclipse.
the class DDRLibraryAdapter method constructLibraryList.
/**
* Constructs the list of libraries required using the DDR implementation of the DTFJ Image* API.
* This ensures that the correct classloading is used for determining which libraries to collect.
* @param coreFile core file to process
*/
@SuppressWarnings({ "unchecked" })
private void constructLibraryList(final File coreFile) {
moduleNames = new ArrayList<String>();
ImageFactory factory = new J9DDRImageFactory();
final Image image;
final boolean isAIX;
try {
image = factory.getImage(coreFile);
isAIX = image.getSystemType().toLowerCase().startsWith("aix");
} catch (IOException e) {
logger.log(SEVERE, "Could not open core file", e);
errorMessages.add(e.getMessage());
return;
} catch (CorruptDataException e) {
logger.log(SEVERE, "Could not determine system type", e);
errorMessages.add(e.getMessage());
return;
} catch (DataUnavailable e) {
logger.log(SEVERE, "Could not determine system type", e);
errorMessages.add(e.getMessage());
return;
}
for (Iterator spaces = image.getAddressSpaces(); spaces.hasNext(); ) {
ImageAddressSpace space = (ImageAddressSpace) spaces.next();
for (Iterator procs = space.getProcesses(); procs.hasNext(); ) {
ImageProcess proc = (ImageProcess) procs.next();
try {
// add the executable to the list of libraries to be collected
ImageModule exe = proc.getExecutable();
moduleNames.add(exe.getName());
for (Iterator libraries = proc.getLibraries(); libraries.hasNext(); ) {
ImageModule module = (ImageModule) libraries.next();
String key = null;
try {
// handle CDE thrown by getName(), as this is required further on this call needs to succeed
if (isAIX) {
key = module.getName();
// check on AIX if module is the .a file or library
int pos = key.indexOf(".a(");
if ((pos != -1) && (key.lastIndexOf(')') == key.length() - 1)) {
key = key.substring(0, pos + 2);
}
} else {
key = module.getName();
}
logger.fine("Module : " + key);
if (!moduleNames.contains(key)) {
// don't store duplicate libraries
moduleNames.add(key);
}
} catch (Exception e) {
logger.log(WARNING, "Error getting module name", e);
}
}
} catch (DataUnavailable e) {
logger.log(WARNING, "Error getting library list", e);
errorMessages.add(e.getMessage());
} catch (com.ibm.dtfj.image.CorruptDataException e) {
logger.log(WARNING, "Error getting library list", e);
errorMessages.add(e.getMessage());
}
}
}
}
Aggregations