Search in sources :

Example 26 with DataUnavailable

use of com.ibm.dtfj.image.DataUnavailable in project openj9 by eclipse.

the class InfoLockCommand method showJavaUtilConcurrentLocks.

private void showJavaUtilConcurrentLocks() {
    // A map of lock objects and their waiting threads.
    Map locksToThreads = new HashMap();
    JavaRuntime jr = ctx.getRuntime();
    Iterator itThread = jr.getThreads();
    while (itThread.hasNext()) {
        try {
            Object o = itThread.next();
            if (!(o instanceof JavaThread)) {
                continue;
            }
            JavaThread jt = (JavaThread) o;
            if ((jt.getState() & JavaThread.STATE_PARKED) != 0) {
                JavaObject lock = jt.getBlockingObject();
                if (lock != null) {
                    List parkedList = (List) locksToThreads.get(lock);
                    if (parkedList == null) {
                        parkedList = new LinkedList();
                        locksToThreads.put(lock, parkedList);
                    }
                    parkedList.add(jt);
                }
            }
        } catch (CorruptDataException cde) {
            out.println("\nwarning, corrupt data encountered during scan for java.util.concurrent locks...");
            logger.log(Level.FINE, Exceptions.getCorruptDataExceptionString(), cde);
        } catch (DataUnavailable du) {
            out.println("\nwarning, data unavailable encountered during scan for java.util.concurrent locks...");
            logger.log(Level.FINE, Exceptions.getDataUnavailableString(), du);
        }
    }
    out.println("\njava.util.concurrent locks in use...");
    if (locksToThreads.size() == 0) {
        out.println("\t...None.");
        out.println();
    }
    for (Object e : locksToThreads.entrySet()) {
        try {
            Map.Entry entry = (Map.Entry) e;
            JavaObject lock = (JavaObject) entry.getKey();
            List threads = (List) entry.getValue();
            String threadName = "<unowned>";
            JavaThread lockOwnerThread = Utils.getParkBlockerOwner(lock, ctx.getRuntime());
            if (lockOwnerThread != null) {
                threadName = lockOwnerThread.getName();
            } else {
                // If the owning thread has ended we won't find the JavaThread
                // We can still get the owning thread name from the java.lang.Thread object itself.
                JavaObject lockOwnerObj = Utils.getParkBlockerOwnerObject(lock, ctx.getRuntime());
                if (lockOwnerObj != null) {
                    threadName = Utils.getThreadNameFromObject(lockOwnerObj, ctx.getRuntime(), out);
                } else {
                    threadName = "<unknown>";
                }
            }
            if (threads != null && threads.size() > 0) {
                String lockID = Long.toHexString(lock.getID().getAddress());
                ImageThread imageThread = (lockOwnerThread != null ? lockOwnerThread.getImageThread() : null);
                out.println(lock.getJavaClass().getName() + "@0x" + lockID + "\n\tlocked by java thread id: " + ((imageThread != null) ? imageThread.getID() : "<null>") + " name: " + (threadName));
                for (Object t : threads) {
                    JavaThread waiter = (JavaThread) t;
                    out.println("\twaiting thread id: " + waiter.getImageThread().getID() + " name: " + waiter.getName());
                }
            }
        } catch (CorruptDataException cde) {
            out.println("\nwarning, corrupt data encountered during scan for java.util.concurrent locks...");
            logger.log(Level.FINE, Exceptions.getCorruptDataExceptionString(), cde);
        } catch (MemoryAccessException ma) {
            out.println("\nwarning, memory access error encountered during scan for java.util.concurrent locks...");
            logger.log(Level.FINE, Exceptions.getMemoryAccessExceptionString(), ma);
        } catch (DataUnavailable du) {
            out.println("\nwarning, data unavailable encountered during scan for java.util.concurrent locks...");
            logger.log(Level.FINE, Exceptions.getDataUnavailableString(), du);
        }
    }
}
Also used : JavaRuntime(com.ibm.dtfj.java.JavaRuntime) HashMap(java.util.HashMap) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) LinkedList(java.util.LinkedList) JavaObject(com.ibm.dtfj.java.JavaObject) Iterator(java.util.Iterator) JavaThread(com.ibm.dtfj.java.JavaThread) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) JavaObject(com.ibm.dtfj.java.JavaObject) LinkedList(java.util.LinkedList) List(java.util.List) ImageThread(com.ibm.dtfj.image.ImageThread) HashMap(java.util.HashMap) Map(java.util.Map) MemoryAccessException(com.ibm.dtfj.image.MemoryAccessException)

Example 27 with DataUnavailable

use of com.ibm.dtfj.image.DataUnavailable in project openj9 by eclipse.

the class InfoSystemCommand method doCommand.

public void doCommand() {
    try {
        out.println("\nMachine OS:\t" + ctx.getImage().getSystemType());
    } catch (DataUnavailable exc) {
        out.println("\nMachine OS:\t" + "data unavailable");
    } catch (CorruptDataException exc) {
        out.println("\nMachine OS:\t" + "data corrupted");
    }
    Properties imageProperties = ctx.getImage().getProperties();
    if (imageProperties.containsKey("Hypervisor")) {
        out.println("Hypervisor:\t" + imageProperties.getProperty("Hypervisor"));
    }
    try {
        out.println("Machine name:\t" + ctx.getImage().getHostName());
    } catch (DataUnavailable exc) {
        out.println("Machine name:\t" + "data unavailable");
    } catch (CorruptDataException exc) {
        out.println("Machine name:\t" + "data corrupted");
    }
    out.println("Machine IP address(es):");
    try {
        Iterator<?> itIPAddresses = ctx.getImage().getIPAddresses();
        while (itIPAddresses.hasNext()) {
            Object addr = itIPAddresses.next();
            if (addr instanceof InetAddress) {
                out.println("\t\t" + ((InetAddress) addr).getHostAddress());
            } else if (addr instanceof CorruptData) {
                out.println("\t\tdata corrupted");
            }
        }
    } catch (DataUnavailable du) {
        out.println("\t\tdata unavailable");
    }
    try {
        out.println("System memory:\t" + ctx.getImage().getInstalledMemory());
    } catch (DataUnavailable exc) {
        out.println("System memory:\t" + "data unavailable");
    }
    try {
        long createTimeMillis = ctx.getImage().getCreationTime();
        if (createTimeMillis != 0) {
            DateFormat fmt = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss:SSS");
            String createTimeStr = fmt.format(new Date(createTimeMillis));
            out.println("\nDump creation time: " + createTimeStr);
        } else {
            out.println("\nDump creation time: data unavailable");
        }
    } catch (DataUnavailable d) {
        out.println("\nDump creation time: data unavailable");
    }
    // Dump creation time - nanotime - added in DTFJ 1.12
    try {
        long createTimeNanos = ctx.getImage().getCreationTimeNanos();
        if (createTimeNanos != 0) {
            out.println("Dump creation time (nanoseconds): " + createTimeNanos);
        } else {
            out.println("Dump creation time (nanoseconds): data unavailable");
        }
    } catch (DataUnavailable du) {
        out.println("Dump creation time (nanoseconds): data unavailable");
    } catch (CorruptDataException cde) {
        out.println("Dump creation time (nanoseconds): data corrupted");
    }
    out.println("\nJava version:");
    if (ctx.getRuntime() != null) {
        try {
            out.println(ctx.getRuntime().getVersion());
        } catch (CorruptDataException e) {
            out.println("version data corrupted");
        }
    } else {
        out.println("\tmissing, unknown or unsupported JRE");
    }
    // JVM start time - millisecond wall clock - added in DTFJ 1.12
    try {
        long startTimeMillis = ctx.getRuntime().getStartTime();
        if (startTimeMillis != 0) {
            DateFormat fmt = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss:SSS");
            String createTimeStr = fmt.format(new Date(startTimeMillis));
            out.println("\nJVM start time: " + createTimeStr);
        } else {
            out.println("\nJVM start time: data unavailable");
        }
    } catch (DataUnavailable d) {
        out.println("\nJVM start time: data unavailable");
    } catch (CorruptDataException cde) {
        out.println("\nJVM start time (nanoseconds): data corrupted");
    }
    // JVM start time - nanotime - added in DTFJ 1.12
    try {
        long startTimeNanos = ctx.getRuntime().getStartTimeNanos();
        if (startTimeNanos != 0) {
            out.println("JVM start time (nanoseconds): " + startTimeNanos);
        } else {
            out.println("JVM start time (nanoseconds): data unavailable");
        }
    } catch (DataUnavailable du) {
        out.println("JVM start time (nanoseconds): data unavailable");
    } catch (CorruptDataException cde) {
        out.println("JVM start time (nanoseconds): data corrupted");
    }
    boolean kernelSettingPrinted = false;
    for (String name : new String[] { "/proc/sys/kernel/sched_compat_yield", "/proc/sys/kernel/core_pattern", "/proc/sys/kernel/core_uses_pid" }) {
        if (imageProperties.containsKey(name)) {
            if (!kernelSettingPrinted) {
                out.println("\nLinux Kernel Settings:");
            }
            out.println(name + " = " + imageProperties.getProperty(name));
            kernelSettingPrinted = true;
        }
    }
    out.println();
}
Also used : CorruptDataException(com.ibm.dtfj.image.CorruptDataException) Properties(java.util.Properties) Date(java.util.Date) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) CorruptData(com.ibm.dtfj.image.CorruptData) InetAddress(java.net.InetAddress) SimpleDateFormat(java.text.SimpleDateFormat)

Example 28 with DataUnavailable

use of com.ibm.dtfj.image.DataUnavailable in project openj9 by eclipse.

the class HeapdumpCommand method dumpHeap.

/**
 * Walks the supplied heap and passes the artifacts through the formatter
 */
private void dumpHeap(HeapDumpFormatter formatter, JavaHeap thisHeap) throws IOException {
    Iterator objectIterator = thisHeap.getObjects();
    while (objectIterator.hasNext()) {
        Object next = objectIterator.next();
        _numberOfObjects++;
        if (next instanceof CorruptData) {
            _numberOfErrors++;
            reportError("Corrupt object data found at " + ((CorruptData) next).getAddress() + " while walking heap " + thisHeap.getName(), null);
            continue;
        }
        try {
            JavaObject thisObject = (JavaObject) next;
            if (thisObject.getJavaClass().getName().equals("java/lang/Class")) {
                // heap classes are handled separately, in dumpClasses()
                continue;
            }
            JavaClass thisClass = thisObject.getJavaClass();
            JavaObject thisClassObject = thisClass.getObject();
            int hashcode = 0;
            if (_is32BitHash) {
                // JVMs from 2.6 on, optional 32-bit hashcodes, if object was hashed
                try {
                    hashcode = (int) thisObject.getPersistentHashcode();
                } catch (DataUnavailable ex) {
                // no persistent hashcode for this object, pass hashcode=0 to the heapdump formatter
                }
            } else {
                // JVMs prior to 2.6, all objects should have a 16-bit hashcode
                try {
                    hashcode = (int) thisObject.getHashcode();
                } catch (DataUnavailable ex) {
                    _numberOfErrors++;
                    reportError("Failed to get hashcode for object: " + thisObject.getID(), ex);
                }
            }
            if (thisObject.isArray()) {
                if (isPrimitive(thisClass.getComponentType())) {
                    formatter.addPrimitiveArray(thisObject.getID().getAddress(), thisClassObject.getID().getAddress(), getPrimitiveTypeCode(thisClass.getComponentType()), thisObject.getSize(), hashcode, thisObject.getArraySize());
                } else {
                    formatter.addObjectArray(thisObject.getID().getAddress(), thisClassObject.getID().getAddress(), thisClass.getName(), thisClass.getComponentType().getObject().getID().getAddress(), thisClass.getComponentType().getName(), thisObject.getSize(), thisObject.getArraySize(), hashcode, getObjectReferences(thisObject));
                }
            } else {
                formatter.addObject(thisObject.getID().getAddress(), thisClassObject.getID().getAddress(), thisClass.getName(), (int) thisObject.getSize(), hashcode, getObjectReferences(thisObject));
            }
        } catch (CorruptDataException ex) {
            _numberOfErrors++;
            reportError(null, ex);
            continue;
        }
    }
}
Also used : JavaObject(com.ibm.dtfj.java.JavaObject) JavaClass(com.ibm.dtfj.java.JavaClass) ReferenceIterator(com.ibm.jvm.dtfjview.heapdump.ReferenceIterator) Iterator(java.util.Iterator) LongListReferenceIterator(com.ibm.jvm.dtfjview.heapdump.LongListReferenceIterator) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Example 29 with DataUnavailable

use of com.ibm.dtfj.image.DataUnavailable in project openj9 by eclipse.

the class HexdumpCommand method doCommand.

public void doCommand(String[] args) {
    StringBuffer stringBuffer = new StringBuffer();
    ImageAddressSpace imageAddressSpace = ctx.getAddressSpace();
    if (null == imageAddressSpace) {
        out.println("Could not find an address space which contains a process in this core file");
        return;
    }
    long addressInDecimal = 0;
    // dump 256 bytes by default
    int numBytesToPrint = 16 * 16;
    int asciiIndex = 0;
    if (args.length != 0) {
        Long address = Utils.longFromString(args[0]);
        if (null == address) {
            out.println("Specified address is invalid");
            return;
        }
        addressInDecimal = address.longValue();
    } else {
        out.println("\"hexdump\" requires at least an address parameter");
        return;
    }
    if (args.length > 1) {
        try {
            numBytesToPrint = Integer.parseInt(args[1]);
        } catch (NumberFormatException nfe) {
            out.println("Specified length is invalid");
            return;
        }
    }
    ImagePointer imagePointerBase = imageAddressSpace.getPointer(addressInDecimal);
    boolean is_zOSdump = false;
    try {
        is_zOSdump = ctx.getImage().getSystemType().toLowerCase().indexOf("z/os") >= 0;
    } catch (DataUnavailable e1) {
    // unable to get the dump OS type, continue without the additional zOS EBCDIC option
    } catch (CorruptDataException e1) {
    // unable to get the dump OS type, continue without the additional zOS EBCDIC option
    }
    String asciiChars = "";
    String ebcdicChars = "";
    long i;
    for (i = 0; i < numBytesToPrint; i++) {
        ImagePointer imagePointer = imagePointerBase.add(i);
        // stringBuffer.append(Long.toHexString(imagePointer.getAddress())+":\t");
        try {
            Byte byteValue = new Byte(imagePointer.getByteAt(0));
            asciiIndex = (int) byteValue.byteValue();
            if (asciiIndex < 0) {
                asciiIndex += 256;
            }
            String rawHexString = Integer.toHexString(byteValue.intValue());
            String fixedHexString = fixHexStringLength(rawHexString);
            String hexText = fixedHexString;
            if (0 == i % 4) {
                hexText = " " + hexText;
            }
            if (0 == i % 16) {
                hexText = "\n" + Long.toHexString(imagePointer.getAddress()) + ":" + hexText;
                asciiChars = "  |";
                ebcdicChars = " |";
            }
            stringBuffer.append(hexText);
            asciiChars += Utils.byteToAscii.substring(asciiIndex, asciiIndex + 1);
            if (15 == i % 16 && i != 0) {
                asciiChars += "|";
                stringBuffer.append(asciiChars);
            }
            if (is_zOSdump) {
                // for zOS dumps, output additional EBCDIC interpretation of the memory byes
                ebcdicChars += Utils.byteToEbcdic.substring(asciiIndex, asciiIndex + 1);
                if (15 == i % 16 && i != 0) {
                    ebcdicChars += "|";
                    stringBuffer.append(ebcdicChars);
                }
            }
        } catch (MemoryAccessException e) {
            out.println("Address not in memory - 0x" + Long.toHexString(imagePointer.getAddress()));
            return;
        } catch (CorruptDataException e) {
            out.println("Dump data is corrupted");
            return;
        }
    }
    long undisplayedBytes = 16 - i % 16;
    if (16 != undisplayedBytes) {
        stringBuffer.append(padSpace(undisplayedBytes, asciiChars));
        if (is_zOSdump) {
            // Add padding and output the remaining EBCDIC characters
            for (int j = 0; j < undisplayedBytes; j++) {
                ebcdicChars = " " + ebcdicChars;
            }
            stringBuffer.append(" " + ebcdicChars);
        }
    }
    stringBuffer.append("\n");
    out.println(new String(stringBuffer));
    /*properties.put(Utils.CURRENT_MEM_ADDRESS, 
				Long.toHexString(addressInDecimal+numBytesToPrint));*/
    ctx.getProperties().put(Utils.CURRENT_MEM_ADDRESS, new Long(addressInDecimal));
    ctx.getProperties().put(Utils.CURRENT_NUM_BYTES_TO_PRINT, new Integer(numBytesToPrint));
}
Also used : CorruptDataException(com.ibm.dtfj.image.CorruptDataException) ImageAddressSpace(com.ibm.dtfj.image.ImageAddressSpace) ImagePointer(com.ibm.dtfj.image.ImagePointer) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) MemoryAccessException(com.ibm.dtfj.image.MemoryAccessException)

Example 30 with DataUnavailable

use of com.ibm.dtfj.image.DataUnavailable in project openj9 by eclipse.

the class NodeList method toString.

// Print this list of monitor nodes (ie the owning threads and there object addresses)
public String toString() {
    String retval = "";
    MonitorNode currNode = tail;
    MonitorNode lastNode = null;
    boolean firstTime = true;
    boolean done = false;
    do {
        String name = "";
        String objAddr = "";
        JavaObject object = null;
        JavaThread owner = null;
        try {
            owner = currNode.getOwner();
            name = owner.getName();
            ImageThread nativeThread = owner.getImageThread();
            if (nativeThread != null) {
                name = name + " id: " + nativeThread.getID();
            }
        } catch (CorruptDataException e) {
            name = Exceptions.getCorruptDataExceptionString();
        } catch (DataUnavailable e) {
            name = Exceptions.getDataUnavailableString();
        } catch (MemoryAccessException e) {
            name = Exceptions.getMemoryAccessExceptionString();
        }
        object = currNode.getObject();
        if (null == object) {
            objAddr = " at : " + Utils.toHex(currNode.getMonitorAddress());
        } else {
            objAddr = " object : " + Utils.toHex(object.getID().getAddress());
        }
        String lockName = currNode.getType();
        retval += "thread: " + name + " (owns " + lockName + objAddr + ") waiting for =>\n\t  ";
        lastNode = currNode;
        currNode = currNode.waitingOn;
        if (head == lastNode) {
            if (firstTime && head == tail)
                done = false;
            else
                done = true;
        }
        firstTime = false;
    } while (!done);
    // removes the tail of the last entry
    retval = retval.substring(0, retval.length() - 18);
    return retval;
}
Also used : JavaObject(com.ibm.dtfj.java.JavaObject) JavaThread(com.ibm.dtfj.java.JavaThread) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) ImageThread(com.ibm.dtfj.image.ImageThread) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) MemoryAccessException(com.ibm.dtfj.image.MemoryAccessException)

Aggregations

DataUnavailable (com.ibm.dtfj.image.DataUnavailable)62 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)39 Iterator (java.util.Iterator)25 JavaObject (com.ibm.dtfj.java.JavaObject)20 CorruptData (com.ibm.dtfj.image.CorruptData)15 Properties (java.util.Properties)13 JavaClass (com.ibm.dtfj.java.JavaClass)9 JavaThread (com.ibm.dtfj.java.JavaThread)9 ImageProcess (com.ibm.dtfj.image.ImageProcess)8 MemoryAccessException (com.ibm.dtfj.image.MemoryAccessException)8 ImageThread (com.ibm.dtfj.image.ImageThread)7 ImageModule (com.ibm.dtfj.image.ImageModule)6 JavaReference (com.ibm.dtfj.java.JavaReference)6 JavaRuntime (com.ibm.dtfj.java.JavaRuntime)5 ImageSection (com.ibm.dtfj.image.ImageSection)4 DTFJCorruptDataException (com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException)4 ImagePointer (com.ibm.dtfj.image.ImagePointer)3 JavaMethod (com.ibm.dtfj.java.JavaMethod)3 JavaMonitor (com.ibm.dtfj.java.JavaMonitor)3 StateToString (com.ibm.jvm.dtfjview.commands.helpers.StateToString)3