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;
}
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");
}
}
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();
}
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;
}
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();
}
Aggregations