use of com.ibm.dtfj.image.ImageSymbol in project openj9 by eclipse.
the class DTFJKickTyres method main.
/**
* @param args
*/
public static void main(String[] args) throws Exception {
boolean useJExtract = false;
if (args.length > 1) {
if (args[1].toLowerCase().trim().equals("jextract")) {
useJExtract = true;
}
}
ImageFactory factory = null;
if (useJExtract) {
try {
Class<?> jxfactoryclass = Class.forName("com.ibm.dtfj.image.j9.ImageFactory");
factory = (ImageFactory) jxfactoryclass.newInstance();
} catch (Exception e) {
System.out.println("Could not create a jextract based implementation of ImageFactory");
e.printStackTrace();
System.exit(1);
}
} else {
factory = new J9DDRImageFactory();
}
Image img = factory.getImage(new File(args[0]));
Iterator<?> addressSpaceIt = img.getAddressSpaces();
while (addressSpaceIt.hasNext()) {
ImageAddressSpace as = (ImageAddressSpace) addressSpaceIt.next();
Iterator<?> processIt = as.getProcesses();
while (processIt.hasNext()) {
ImageProcess process = (ImageProcess) processIt.next();
System.err.println("Got process " + process);
try {
System.err.println("Command line was " + process.getCommandLine());
} catch (Throwable t) {
t.printStackTrace();
}
try {
System.err.println("Executable was: " + process.getExecutable());
} catch (Throwable t) {
t.printStackTrace();
}
try {
System.err.println("Modules were:");
Iterator<?> it = process.getLibraries();
if (!it.hasNext()) {
System.err.println("No modules!");
}
while (it.hasNext()) {
ImageModule module = (ImageModule) it.next();
System.err.println("* " + module.getName());
Iterator<?> symIt = module.getSymbols();
while (symIt.hasNext()) {
Object symObj = symIt.next();
if (symObj instanceof ImageSymbol) {
ImageSymbol sym = (ImageSymbol) symObj;
if (sym.getName().toLowerCase().contains("environ")) {
System.err.println("X sym " + sym.getName() + " = " + sym.getAddress());
}
}
}
}
} catch (Throwable t) {
t.printStackTrace();
}
try {
Properties env = process.getEnvironment();
System.err.println("Environment");
for (Object key : env.keySet()) {
System.err.println(key + " = " + env.getProperty((String) key));
}
} catch (Throwable t) {
t.printStackTrace();
}
Iterator<?> runtimeIt = process.getRuntimes();
while (runtimeIt.hasNext()) {
JavaRuntime runtime = (JavaRuntime) runtimeIt.next();
System.err.println("Got runtime: " + runtime);
JavaVMInitArgs initArgs = runtime.getJavaVMInitArgs();
Iterator<?> optionsIt = initArgs.getOptions();
System.err.println("Options:");
while (optionsIt.hasNext()) {
Object optionObj = optionsIt.next();
if (optionObj instanceof JavaVMOption) {
JavaVMOption option = (JavaVMOption) optionObj;
System.err.println("* " + option.getOptionString());
}
}
}
}
}
}
use of com.ibm.dtfj.image.ImageSymbol in project openj9 by eclipse.
the class ImageSymbolComparator method testEquals.
// getAddress()
// getName()
public void testEquals(Object ddrObject, Object jextractObject, int members) {
ImageSymbol ddrImageSymbol = (ImageSymbol) ddrObject;
ImageSymbol jextractImageSymbol = (ImageSymbol) jextractObject;
// getAddress()
if ((ADDRESS & members) != 0)
new ImagePointerComparator().testComparatorEquals(ddrImageSymbol, jextractImageSymbol, "getAddress");
// getName()
if ((NAME & members) != 0)
testJavaEquals(ddrImageSymbol, jextractImageSymbol, "getName");
}
use of com.ibm.dtfj.image.ImageSymbol 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");
}
Aggregations