use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class ThreadStream method readFrom.
@Override
public void readFrom(MiniDumpReader dump, IAddressSpace addressSpace, boolean is64Bit) throws CorruptDataException, IOException {
dump.seek(getLocation());
int numberOfThreads = dump.readInt();
if (numberOfThreads > 100000) {
throw new CorruptDataException("Unlikely number of threads found in dump: " + numberOfThreads + ". Suspect data corruption");
}
for (int i = 0; i < numberOfThreads; i++) {
dump.seek(getLocation() + 4 + i * 48);
int threadId = dump.readInt();
// Ignore suspendCount
dump.readInt();
int priorityClass = dump.readInt();
int priority = dump.readInt();
// Ignore teb
dump.readLong();
long stackStart = dump.readLong();
long stackSize = 0xFFFFFFFFL & dump.readInt();
long stackRva = 0xFFFFFFFFL & dump.readInt();
// contextDataSize
dump.readInt();
long contextRva = 0xFFFFFFFFL & dump.readInt();
Properties properties = new Properties();
properties.setProperty("priorityClass", String.valueOf(priorityClass));
properties.setProperty("priority", String.valueOf(priority));
dump.addThread(new WindowsOSThread(threadId, stackStart, stackSize, stackRva, contextRva, properties, dump, (IProcess) addressSpace));
}
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class GpInfoCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
long vmAddress = context.vmAddress;
try {
long j9rasAddress = CommandUtils.followPointerFromStructure(context, "J9JavaVM", vmAddress, "j9ras");
long crashInfoAddress = CommandUtils.followPointerFromStructure(context, "J9RAS", j9rasAddress, "crashInfo");
if (crashInfoAddress != 0l) {
long failingThread = CommandUtils.followPointerFromStructure(context, "J9RASCrashInfo", crashInfoAddress, "failingThread");
long failingThreadID = CommandUtils.followPointerFromStructure(context, "J9RASCrashInfo", crashInfoAddress, "failingThreadID");
long gpinfo = CommandUtils.followPointerFromStructure(context, "J9RASCrashInfo", crashInfoAddress, "gpInfo");
out.println("Failing Thread: !j9vmthread 0x" + Long.toHexString(failingThread));
out.println("Failing Thread ID: 0x" + Long.toHexString(failingThreadID) + " (" + failingThreadID + ")");
out.println("gpInfo:");
out.println(CommandUtils.getCStringAtAddress(context.process, gpinfo));
} else {
out.println("Core does not appear to have been triggered by a gpf. No J9RASCrashInfo found.");
}
} catch (MemoryFault e) {
throw new DDRInteractiveCommandException(e);
} catch (com.ibm.j9ddr.NoSuchFieldException e) {
throw new DDRInteractiveCommandException(e);
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class NativeLibrariesCommand method showLibList.
// list the libraries from the core file and report whether or not they have been collected
private void showLibList(Context ctx, PrintStream out) {
LibReader reader = new LibReader();
out.println("Showing library list for " + DDRInteractive.getPath());
Collection<? extends IModule> libs = null;
try {
libs = ctx.process.getModules();
} catch (CorruptDataException e) {
out.println("Corrupt data exception when retrieving list of libraries : " + e.getMessage());
return;
}
getExeFromDDR(ctx, out);
for (IModule lib : libs) {
try {
out.println("Lib : " + lib.getName());
FooterLibraryEntry entry = reader.getEntry(lib.getName());
if (entry == null) {
out.println("\tLibrary is not appended to the core file, it may be present on the local disk");
} else {
out.println("\tLibrary has been collected");
out.println("\tPath : " + entry.getPath());
out.println("\tName : " + entry.getName());
out.println("\tSize : " + entry.getSize());
}
} catch (CorruptDataException e) {
out.println("Library name is corrupt");
}
}
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class SnapTraceCommand method writeBytesToTrace.
protected void writeBytesToTrace(Context context, long address, int bufferSize, PrintStream out) {
if (fileName != null) {
File snapfile = new File(fileName);
byte[] data = new byte[bufferSize];
try {
context.process.getBytesAt(address, data);
} catch (CorruptDataException e) {
// Although we got a CDE some data may have been copied to the buffer.
// This appears to happen on z/OS when some of the buffer space is in a page of
// uninitialised memory. (See defect 185780.) In that case the missing data is
// all 0's anyway.
out.println("Problem reading " + bufferSize + " bytes from 0x" + Long.toHexString(address) + ". Trace file may contain partial or damaged data.");
}
FileOutputStream fOut = null;
try {
fOut = new FileOutputStream(snapfile, true);
fOut.write(data);
} catch (FileNotFoundException e) {
out.println("FileNotFound " + fileName);
} catch (IOException e) {
out.println("IO Error writing to file " + fileName);
} finally {
if (fOut != null) {
try {
fOut.close();
} catch (IOException e) {
// Close failed, can't do much!
}
}
}
}
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class J9DDRDTFJUtils method handleAsCorruptDataException.
/**
* Convert the supplied error condition into a corrupt data exception
* or re-throw it if it is an instance of Error that we do not want to
* intercept.
*
* @param p the process from the DTFJ context
* @param t error condition to convert
* @return CorruptDataException
*/
public static com.ibm.dtfj.image.CorruptDataException handleAsCorruptDataException(IProcess p, Throwable t) {
if (t instanceof com.ibm.dtfj.image.CorruptDataException) {
// prevent repeated logging of this error by ignoring DTFJ CorruptDataExceptions
return (com.ibm.dtfj.image.CorruptDataException) t;
}
if (isErrorNotToBeIntercepted(t)) {
if (t instanceof Error) {
// re-throw unhandled errors
throw (Error) t;
}
// should not hit this as we handle run time exceptions
throw new RuntimeException(t);
}
if (t instanceof com.ibm.j9ddr.CorruptDataException) {
com.ibm.j9ddr.CorruptDataException cde = (com.ibm.j9ddr.CorruptDataException) t;
logger.log(Level.FINE, "Corrupt data encountered", t);
return newCorruptDataException(p, cde);
}
String message = logError(t);
CorruptData cd = newCorruptData(p, message);
return new DTFJCorruptDataException(cd, t);
}
Aggregations