use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class InfoSymCommand method listModules.
private void listModules(String moduleName) {
ImageProcess ip = ctx.getProcess();
try {
Object e = ip.getExecutable();
if (e instanceof ImageModule) {
ImageModule exe = (ImageModule) e;
if (moduleName != null) {
if (checkModuleName(exe.getName(), moduleName)) {
printModule(exe, true);
}
} else {
printModule(exe, false);
}
} else if (e instanceof CorruptData) {
CorruptData corruptObj = (CorruptData) e;
// warn the user that this image library is corrupt
out.print("\t <corrupt executable encountered: " + corruptObj.toString() + ">\n\n");
}
} catch (DataUnavailable e) {
out.println(Exceptions.getDataUnavailableString());
} catch (CorruptDataException e) {
out.println(Exceptions.getCorruptDataExceptionString());
}
Iterator iLibs;
try {
iLibs = ip.getLibraries();
} catch (DataUnavailable du) {
iLibs = null;
out.println(Exceptions.getDataUnavailableString());
} catch (CorruptDataException cde) {
iLibs = null;
out.println(Exceptions.getCorruptDataExceptionString());
}
// iterate through the libraries
while (null != iLibs && iLibs.hasNext()) {
Object next = iLibs.next();
if (next instanceof ImageModule) {
ImageModule mod = (ImageModule) next;
String currentName = null;
try {
currentName = mod.getName();
} catch (CorruptDataException e) {
out.print("\t <corrupt library name: " + mod.toString() + ">\n\n");
}
if (moduleName != null) {
if (checkModuleName(currentName, moduleName)) {
printModule(mod, true);
}
} else {
printModule(mod, false);
}
} else if (next instanceof CorruptData) {
CorruptData corruptObj = (CorruptData) next;
// warn the user that this image library is corrupt
out.print("\t <corrupt library encountered: " + corruptObj.toString() + ">\n\n");
} else {
// unexpected type in iterator
out.print("\t <corrupt library encountered>\n\n");
}
}
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class InfoClassCommand method countClassInstances.
private void countClassInstances() {
JavaRuntime runtime = ctx.getRuntime();
Map<JavaClass, ClassStatistics> thisRuntimeClasses = classInstanceCounts.get(runtime);
final Collection<JavaClass> javaClasses = getRuntimeClasses(runtime);
long corruptObjectCount = 0;
long corruptClassCount = 0;
long corruptClassNameCount = 0;
Iterator itHeap = runtime.getHeaps();
while (itHeap.hasNext()) {
Object heap = itHeap.next();
if (heap instanceof CorruptData) {
out.println("[skipping corrupt heap]");
continue;
}
JavaHeap jh = (JavaHeap) heap;
Iterator itObject = jh.getObjects();
// Walk through all objects in this heap, accumulating counts and total memory size by class
while (itObject.hasNext()) {
Object next = itObject.next();
// JavaHeap, we don't attempt to count these as instances of known classes).
if (next instanceof JavaObject) {
JavaObject jo = (JavaObject) next;
ClassStatistics stats = null;
try {
// Check whether we found this class in the classloaders walk earlier
JavaClass jc = jo.getJavaClass();
if (javaClasses.contains(jc)) {
stats = thisRuntimeClasses.get(jc);
} else {
// Class not found in the classloaders, create a statistic for it now, and issue a warning message
stats = new ClassStatistics();
thisRuntimeClasses.put(jc, stats);
String classname;
try {
classname = jc.getName();
out.println("Warning, class: " + classname + " found when walking the heap was missing from classloader walk");
} catch (CorruptDataException cde) {
corruptClassNameCount++;
}
}
// Increment the statistic for objects of this class (accumulated count and size)
stats.incrementCount();
try {
stats.addToSize(jo.getSize());
} catch (CorruptDataException cde) {
// bad size, count object as corrupt
corruptObjectCount++;
}
} catch (CorruptDataException cde) {
corruptClassCount++;
}
} else {
corruptObjectCount++;
}
}
}
if (corruptObjectCount != 0) {
out.println("Warning, found " + corruptObjectCount + " corrupt objects during heap walk");
}
if (corruptClassCount != 0) {
out.println("Warning, found " + corruptClassCount + " corrupt class references during heap walk");
}
if (corruptClassNameCount != 0) {
out.println("Warning, found " + corruptClassNameCount + " corrupt class names during heap walk");
}
}
use of com.ibm.dtfj.image.CorruptData 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();
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class InfoHeapCommand method printHeapInfo.
private void printHeapInfo(String param, JavaRuntime runtime, PrintStream out) {
Iterator itHeaps = runtime.getHeaps();
int countheaps = 1;
while (itHeaps.hasNext()) {
Object heap = itHeaps.next();
if (heap instanceof CorruptData) {
out.println("[skipping corrupt heap");
continue;
}
JavaHeap theHeap = (JavaHeap) heap;
out.print("\t Heap #" + countheaps + ": " + theHeap.getName() + "\n");
if (param != null) {
printSectionInfo(theHeap, out);
}
countheaps++;
}
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class PHDJavaRuntime method prepClassLoaders.
/**
* Remember objects associated with class loaders
* Performance optimization - we can then find these objects on a scan through the heap
* and remember them, saving a fruitless search of the heap if they only exist in a javacore.
*/
private void prepClassLoaders() {
if (metaJavaRuntime != null) {
final PHDJavaClassLoader boot = loaders.get(null);
for (Iterator it = metaJavaRuntime.getJavaClassLoaders(); it.hasNext(); ) {
Object next = it.next();
if (next instanceof CorruptData)
continue;
JavaClassLoader load = (JavaClassLoader) next;
try {
JavaObject jo = load.getObject();
saveExtraObject(boot, jo);
} catch (CorruptDataException e) {
}
}
}
}
Aggregations