use of com.ibm.dtfj.image.ImageSection in project openj9 by eclipse.
the class InfoHeapCommand method printSectionInfo.
private void printSectionInfo(JavaHeap theHeap, PrintStream out) {
Iterator itSections = theHeap.getSections();
int countSections = 1;
while (itSections.hasNext()) {
ImageSection theSection = (ImageSection) itSections.next();
out.print("\t Section #" + countSections + ": " + theSection.getName() + "\n");
out.print("\t Size: " + theSection.getSize() + " bytes\n");
try {
out.print("\t Shared: " + theSection.isShared() + "\n");
out.print("\t Executable: " + theSection.isExecutable() + "\n");
out.print("\t Read Only: " + theSection.isReadOnly() + "\n");
} catch (DataUnavailable e) {
out.print("\t Shared: <unknown>\n");
out.print("\t Executable: <unknown>\n");
out.print("\t Read Only: <unknown>\n");
}
countSections++;
}
}
use of com.ibm.dtfj.image.ImageSection in project openj9 by eclipse.
the class InfoHeapCommand method printOccupancyInfo.
private void printOccupancyInfo(JavaHeap theHeap, PrintStream out) {
/*
* This method takes a lot of time and hence this information is only included
* when using "info heap <heapname>". If this method was run for every heap
* when using "info heap *" the amount of time it would take would be astronomical.
*/
long size = 0;
long totalObjectSize = 0;
// total number of objects on the heap
long totalObjects = 0;
// total number of corrupt objects
long totalCorruptObjects = 0;
Iterator itSections = theHeap.getSections();
// object returned from various iterators
Object obj = null;
// corrupt data
CorruptData cdata = null;
while (itSections.hasNext()) {
obj = itSections.next();
if (obj instanceof CorruptData) {
// returned section is corrupt
cdata = (CorruptData) obj;
out.print("\t\t Warning - corrupt image section found");
if (cdata.getAddress() != null) {
out.print(" at 0x" + cdata.getAddress().toString());
}
out.print("\n");
} else {
// returned section is valid, so process it
ImageSection theSection = (ImageSection) obj;
size = size + theSection.getSize();
}
}
out.print("\t Size of heap: " + size + " bytes\n");
Iterator itObjects = theHeap.getObjects();
try {
while (itObjects.hasNext()) {
obj = itObjects.next();
totalObjects++;
if (obj instanceof CorruptData) {
totalCorruptObjects++;
cdata = (CorruptData) obj;
out.print("\t\t Warning - corrupt heap object found at position " + totalObjects);
if (cdata.getAddress() != null) {
out.print(" address 0x" + cdata.getAddress().toString());
}
out.print("\n");
} else {
JavaObject theObject = (JavaObject) obj;
totalObjectSize = totalObjectSize + theObject.getSize();
}
}
float percentage = ((float) totalObjectSize / (float) size) * 10000;
// Sending this float through an int gets it down to 2 decimal places.
int trimmedPercent = ((int) percentage);
percentage = ((float) trimmedPercent) / 100;
out.print("\t Occupancy : " + totalObjectSize + " bytes (" + percentage + "%)\n");
out.print("\t Total objects : " + totalObjects + "\n");
out.print("\t Total corrupted objects : " + totalCorruptObjects + "\n");
} catch (CorruptDataException e) {
out.print("\t Occupancy : <unknown>\n");
}
}
use of com.ibm.dtfj.image.ImageSection in project openj9 by eclipse.
the class WhatisCommand method isWithinImageSections.
private boolean isWithinImageSections(Iterator heapImageSections, Object memType, boolean isMethodCompiled, long address) {
while (heapImageSections.hasNext()) {
ImageSection imageSection = (ImageSection) heapImageSections.next();
long baseAddress = imageSection.getBaseAddress().getAddress();
long size = imageSection.getSize();
long endAddress = baseAddress + size;
if (address <= endAddress && address >= baseAddress) {
if (null == memType) {
out.print("\t\t0x" + Long.toHexString(address) + " is within heap segment: " + Long.toHexString(baseAddress) + " -- " + Long.toHexString(endAddress) + "\n");
return true;
}
if (memType instanceof JavaMethod) {
String methodName = "N/A", methodSig = "N/A", className = "N/A";
try {
methodName = ((JavaMethod) memType).getName();
methodSig = ((JavaMethod) memType).getSignature();
className = ((JavaMethod) memType).getDeclaringClass().getName();
} catch (CorruptDataException cde) {
} catch (DataUnavailable du) {
}
String codeType = isMethodCompiled ? "compiled code" : "byte code";
out.print("\t0x" + Long.toHexString(address) + " is within the " + codeType + " range: " + Long.toHexString(baseAddress) + " -- " + Long.toHexString(endAddress) + "\n\t" + "...of method " + methodName + " with signature " + methodSig + "\n\t" + "...in class " + className + "\n");
return true;
}
}
}
return false;
}
use of com.ibm.dtfj.image.ImageSection in project openj9 by eclipse.
the class InfoSymCommand method printModule.
private void printModule(ImageModule imageModule, boolean printSymbols) {
try {
out.print("\t " + imageModule.getName());
} catch (CorruptDataException cde) {
out.print("\t " + Exceptions.getCorruptDataExceptionString());
}
try {
String addressInHex = String.format("0x%x", imageModule.getLoadAddress());
out.print(" @ " + addressInHex);
} catch (DataUnavailable e) {
// if we do not have the load address, simply omit it
} catch (CorruptDataException e) {
// if we do not have the load address, simply omit it
}
Iterator itSection = imageModule.getSections();
if (itSection.hasNext()) {
out.print(", sections:\n");
} else {
out.print(", <no section information>\n");
}
// iterate through the library sections
while (itSection.hasNext()) {
Object next = itSection.next();
if (next instanceof ImageSection) {
ImageSection is = (ImageSection) next;
out.print("\t 0x" + Long.toHexString(is.getBaseAddress().getAddress()) + " - 0x" + Long.toHexString(is.getBaseAddress().getAddress() + is.getSize()));
out.print(", name: \"");
out.print(is.getName());
out.print("\", size: 0x");
out.print(Long.toHexString(is.getSize()));
out.print("\n");
} else if (next instanceof CorruptData) {
// warn the user that this image section is corrupt
out.print("\t <corrupt section encountered>\n");
} else {
// unexpected type in iterator
out.print("\t <corrupt section encountered>\n");
}
}
if (printSymbols) {
out.print("\t " + "symbols:\n");
Iterator itSymbols = imageModule.getSymbols();
while (itSymbols.hasNext()) {
Object next = itSymbols.next();
if (next instanceof ImageSymbol) {
ImageSymbol is = (ImageSymbol) next;
out.print("\t 0x" + Long.toHexString(is.getAddress().getAddress()));
out.print(", name: \"");
out.print(is.getName());
out.print("\"\n");
} else if (next instanceof CorruptData) {
// warn the user that this image section is corrupt
out.print("\t <corrupt symbol encountered>\n");
} else {
// unexpected type in iterator
out.print("\t <corrupt symbol encountered>\n");
}
}
}
out.print("\n");
}
use of com.ibm.dtfj.image.ImageSection in project openj9 by eclipse.
the class InfoJitmCommand method showJITdMethods.
private void showJITdMethods() {
JavaRuntime jr = ctx.getRuntime();
Iterator itJavaClassLoader = jr.getJavaClassLoaders();
while (itJavaClassLoader.hasNext()) {
JavaClassLoader jcl = (JavaClassLoader) itJavaClassLoader.next();
Iterator itJavaClass = jcl.getDefinedClasses();
while (itJavaClass.hasNext()) {
JavaClass jc = (JavaClass) itJavaClass.next();
Iterator itJavaMethod = jc.getDeclaredMethods();
String jcName;
try {
jcName = jc.getName();
} catch (CorruptDataException e) {
jcName = Exceptions.getCorruptDataExceptionString();
}
while (itJavaMethod.hasNext()) {
JavaMethod jm = (JavaMethod) itJavaMethod.next();
String name;
String sig;
try {
name = jm.getName();
} catch (CorruptDataException e) {
name = Exceptions.getCorruptDataExceptionString();
}
try {
sig = jm.getSignature();
} catch (CorruptDataException e) {
sig = Exceptions.getCorruptDataExceptionString();
}
if (jm.getCompiledSections().hasNext()) {
Iterator itImageSection = jm.getCompiledSections();
while (itImageSection.hasNext()) {
ImageSection is = (ImageSection) itImageSection.next();
long startAddr = is.getBaseAddress().getAddress();
long size = is.getSize();
long endAddr = startAddr + size;
out.print("\n\t" + "start=" + Utils.toHex(startAddr) + " " + "end=" + Utils.toHex(endAddr) + " " + jcName + "::" + name + sig);
}
}
}
}
}
out.print("\n");
}
Aggregations