Search in sources :

Example 6 with CorruptDataException

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));
    }
}
Also used : CorruptDataException(com.ibm.j9ddr.CorruptDataException) Properties(java.util.Properties) IProcess(com.ibm.j9ddr.corereaders.memory.IProcess)

Example 7 with CorruptDataException

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);
    }
}
Also used : MemoryFault(com.ibm.j9ddr.corereaders.memory.MemoryFault) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 8 with CorruptDataException

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");
        }
    }
}
Also used : FooterLibraryEntry(com.ibm.j9ddr.libraries.FooterLibraryEntry) IModule(com.ibm.j9ddr.corereaders.memory.IModule) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 9 with CorruptDataException

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!
                }
            }
        }
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) IOException(java.io.IOException) File(java.io.File)

Example 10 with CorruptDataException

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);
}
Also used : J9DDRCorruptData(com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData) CorruptData(com.ibm.dtfj.image.CorruptData) CorruptDataException(com.ibm.j9ddr.CorruptDataException) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Aggregations

CorruptDataException (com.ibm.j9ddr.CorruptDataException)221 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)81 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)46 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)41 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)33 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)30 NoSuchElementException (java.util.NoSuchElementException)28 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)25 UDATA (com.ibm.j9ddr.vm29.types.UDATA)20 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)17 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)15 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)11 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)9 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)9 ClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassWalker)8 LinearDumper (com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper)8 PatternString (com.ibm.j9ddr.util.PatternString)7 GCVMThreadListIterator (com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator)7 ClassSegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator)7 J9PoolPointer (com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer)7