Search in sources :

Example 41 with DataUnavailable

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

the class ImageProcess method getCommandLine.

/* (non-Javadoc)
	 * @see com.ibm.dtfj.image.ImageProcess#getCommandLine()
	 */
public String getCommandLine() throws DataUnavailable, CorruptDataException {
    // We can't get the command line from the core dump on zOS, or on recent Windows versions. On Linux
    // it may be truncated. The java launcher stores the command line in an environment variable, so for
    // all platforms we now try that first, with the core reader as a fallback.
    Properties environment = getEnvironment();
    String javaCommandLine = environment.getProperty(JAVA_COMMAND_LINE_ENVIRONMENT_VARIABLE);
    if (javaCommandLine != null) {
        return javaCommandLine;
    }
    if (_commandLine == null) {
        throw new DataUnavailable("Command line unavailable from core dump");
    }
    return _commandLine;
}
Also used : DataUnavailable(com.ibm.dtfj.image.DataUnavailable) Properties(java.util.Properties)

Example 42 with DataUnavailable

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

the class JavaObject method getPersistentHashcode.

/* (non-Javadoc)
	 * @see com.ibm.dtfj.java.JavaObject#getPersistentHashcode()
	 */
public long getPersistentHashcode() throws DataUnavailable, CorruptDataException {
    // this is a terrible way to do this since we know that it _will_ _break_ in the future.  It is, however, the best that we can do
    if (_javaVM.objectShouldInferHash()) {
        try {
            int flags = ((com.ibm.dtfj.java.j9.JavaAbstractClass) getJavaClass()).readFlagsFromInstance(this);
            // now mask out the non-hash bits, shift and return
            // high 15 bits, omitting most significant
            int twoBytes = flags & 0x7FFF0000;
            long hash = (twoBytes >> 16) | twoBytes;
            return hash;
        } catch (MemoryAccessException e) {
            // if we can't access the memory, the core must be corrupt
            throw new CorruptDataException(new CorruptData("Address in object header but unreadable", _basePointer));
        }
    } else {
        throw new DataUnavailable("Unknown hash strategy for this VM version");
    }
}
Also used : DataUnavailable(com.ibm.dtfj.image.DataUnavailable) CorruptData(com.ibm.dtfj.image.j9.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) MemoryAccessException(com.ibm.dtfj.image.MemoryAccessException)

Example 43 with DataUnavailable

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

the class PHDImage method getCreationTime.

/**
 * Use the filename if of the form heapdump.yyyyMMdd.HHmmss.pid.seq.phd
 * else the file date
 */
public long getCreationTime() throws DataUnavailable {
    if (file == null) {
        throw new DataUnavailable("File creation time not available.");
    }
    String name = file.getName();
    String prefix = "heapdump";
    // Allow extra stuff in front of "heapdump"
    int p = Math.max(0, name.indexOf(prefix));
    name = name.substring(p);
    if (name.startsWith(prefix)) {
        String dateTime = "yyyyMMdd.HHmmss";
        SimpleDateFormat sdf = new SimpleDateFormat(dateTime);
        ParsePosition pp = new ParsePosition(0);
        for (int i = prefix.length(); i < name.length(); ++i) {
            pp.setIndex(i);
            Date d = sdf.parse(name, pp);
            if (d != null && !d.before(PHDImageFactory.earliestDump) && d.before(PHDImageFactory.latestDump)) {
                return d.getTime();
            }
        }
    }
    // or for AIX 1.4.2 heapdumpPID.EPOCHTIME.phd
    // heapdump454808.1244656860.phd
    String[] s = name.split("\\.");
    prefix = "heapdump";
    if ((s.length == 3 || s.length == 4 && s[3].equals("gz")) && s[0].startsWith(prefix)) {
        try {
            // Check the first part is also a number (PID)
            Integer.parseInt(s[0].substring(prefix.length()));
            // Check the second part is also a number
            long l2 = Long.parseLong(s[1]);
            // The second number is the number of seconds since the epoch
            // Simple validation - since circa 2000 ?
            Date dF = new Date(l2 * 1000L);
            if (!dF.before(PHDImageFactory.earliestDump) && dF.before(PHDImageFactory.latestDump)) {
                return dF.getTime();
            }
        } catch (NumberFormatException e) {
        }
    }
    try {
        if (meta != null)
            return meta.getCreationTime();
    } catch (DataUnavailable e) {
    }
    return file.lastModified();
}
Also used : DataUnavailable(com.ibm.dtfj.image.DataUnavailable) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) ParsePosition(java.text.ParsePosition)

Example 44 with DataUnavailable

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

the class PHDJavaClass method referencesClass.

/**
 * Is there a reference from one class to another?
 * E.g. from an array class to the component type? This would be an indication that they
 * are truly related.
 * @param from
 * @param to
 * @return
 */
static boolean referencesClass(JavaClass from, JavaClass to) {
    for (Iterator i1 = from.getReferences(); i1.hasNext(); ) {
        Object o = i1.next();
        if (o instanceof CorruptData)
            continue;
        JavaReference jr = (JavaReference) o;
        try {
            if (jr.isClassReference() && jr.getTarget().equals(to)) {
                return true;
            }
            if (jr.isObjectReference() && jr.getTarget().equals(to.getObject())) {
                return true;
            }
        } catch (DataUnavailable e) {
        } catch (CorruptDataException e) {
        }
    }
    return false;
}
Also used : JavaReference(com.ibm.dtfj.java.JavaReference) Iterator(java.util.Iterator) 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 45 with DataUnavailable

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

the class PHDJavaLocation method toString.

/*
	 * Get a description of the frame in the same format as a stack trace 
	 */
public String toString() {
    StringBuilder sb = new StringBuilder();
    try {
        JavaMethod m = getMethod();
        sb.append(m.getDeclaringClass().getName().replace('/', '.'));
        sb.append('.');
        sb.append(m.getName());
    } catch (CorruptDataException e) {
        sb.append("corrupt");
    } catch (DataUnavailable e) {
        sb.append("data unavailable");
    }
    sb.append('(');
    boolean d = false;
    try {
        sb.append(getFilename());
        d = true;
        int line = getLineNumber();
        sb.append(':');
        sb.append(line);
    } catch (CorruptDataException e) {
        try {
            if (getCompilationLevel() > 0) {
                if (d)
                    sb.append('(');
                sb.append("Compiled Code");
                if (d)
                    sb.append(')');
            }
        } catch (CorruptDataException e2) {
        }
    } catch (DataUnavailable e) {
        try {
            if (getCompilationLevel() > 0) {
                if (d)
                    sb.append('(');
                sb.append("Compiled Code");
                if (d)
                    sb.append(')');
            }
        } catch (CorruptDataException e2) {
        }
    } finally {
        sb.append(')');
    }
    return sb.toString();
}
Also used : JavaMethod(com.ibm.dtfj.java.JavaMethod) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

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