use of com.ibm.j9ddr.corereaders.ICore in project openj9 by eclipse.
the class NativeLibrariesCommand method getExeFromDDR.
// we can use the hint mechanism in DTFJ to work out the exe location for elf cores with very long path names
private void getExeFromDDR(Context ctx, PrintStream out) {
try {
ICore core = ctx.process.getAddressSpace().getCore();
if (ILibraryDependentCore.class.isAssignableFrom(core.getClass())) {
ILibraryDependentCore ldcore = (ILibraryDependentCore) core;
J9DDRImageProcess proc = new J9DDRImageProcess(ctx.process);
ImageModule exe = proc.getExecutable();
out.println("exe = " + exe.getName());
ldcore.executablePathHint(exe.getName());
}
} catch (Exception e) {
out.println("Could not determine EXE name using DDR : " + e.getMessage());
}
}
use of com.ibm.j9ddr.corereaders.ICore in project openj9 by eclipse.
the class DDRInteractive method locateRuntimes.
private void locateRuntimes(String path) throws Exception {
ICore reader = CoreReader.readCoreFile(path);
if (null == reader) {
throw new RuntimeException("Cannot find Core Reader for file: " + path);
}
locateRuntimes(reader);
}
use of com.ibm.j9ddr.corereaders.ICore in project openj9 by eclipse.
the class CoreInfoCommand method run.
/**
* Run method for !coreinfo extension.
*
* @param command !coreinfo
* @param args args passed by !coreinfo extension.
* @param context Context of current core file.
* @param out PrintStream to print the output to the console.
* @throws DDRInteractiveCommandException
*/
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (0 < args.length) {
out.println("!coreinfo expects no args. Usage :");
printUsage(out);
return;
}
J9JavaVMPointer vm;
try {
J9RASPointer ras = DataType.getJ9RASPointer();
vm = J9RASHelper.getVM(ras);
IProcess process = vm.getProcess();
J9DDRImageProcess ddrProcess = new J9DDRImageProcess(process);
try {
/* Print the command line of a running program that generated core file */
out.println("COMMANDLINE\n" + ddrProcess.getCommandLine() + "\n");
} catch (DataUnavailable e) {
/*For Zos core files, commandline is not available */
out.println("COMMANDLINE is not available\n");
} catch (com.ibm.dtfj.image.CorruptDataException e) {
throw new DDRInteractiveCommandException("CorruptDataException occured while getting the commandline from process");
}
Properties properties = J9JavaVMHelper.getSystemProperties(vm);
/* Print VM service level info */
out.println("JAVA SERVICE LEVEL INFO\n" + ras.serviceLevel().getCStringAtOffset(0));
/* Print Java Version Info */
out.println("JAVA VERSION INFO\n" + properties.get("java.fullversion"));
/* Print Java VM Version Info */
out.println("JAVA VM VERSION\t- " + properties.get("java.vm.version") + "\n");
/* Print Platform Info */
boolean is64BitPlatform = (process.bytesPerPointer() == 8) ? true : false;
ICore core = vm.getProcess().getAddressSpace().getCore();
Platform platform = core.getPlatform();
out.println("PLATFORM INFO");
out.print("Platform Name :\t" + platform.name());
if (is64BitPlatform) {
out.println(" 64Bit");
} else {
out.println(" 32Bit");
}
out.println("OS Level\t: " + ras.osnameEA().getCStringAtOffset(0) + " " + ras.osversionEA().getCStringAtOffset(0));
out.println("Processors -");
out.println(" Architecture\t: " + ras.osarchEA().getCStringAtOffset(0));
out.println(" How Many\t: " + ras.cpus().longValue());
try {
properties = ddrProcess.getEnvironment();
Enumeration processPropEnum = properties.keys();
out.println("\nENVIRONMENT VARIABLES");
while (processPropEnum.hasMoreElements()) {
String key = (String) processPropEnum.nextElement();
out.println(key + "=" + properties.get(key));
}
} catch (com.ibm.dtfj.image.CorruptDataException e) {
throw new DDRInteractiveCommandException("CorruptDataException occured while getting the environment variables from process");
} catch (DataUnavailable e) {
out.println("Environment variables are not available\n");
}
} catch (CorruptDataException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of com.ibm.j9ddr.corereaders.ICore in project openj9 by eclipse.
the class BootstrapJUnitTest method beforeClass.
@BeforeClass
public static void beforeClass() {
try {
String coreFileName = System.getProperty("ddr.core.file.name");
if (coreFileName == null) {
fail("Did not specify core file name with -Dddr.core.file.name");
}
ICore core = CoreReader.readCoreFile(coreFileName);
List<IAddressSpace> addressSpaces = new ArrayList<IAddressSpace>(core.getAddressSpaces());
for (IAddressSpace thisAS : addressSpaces) {
for (IProcess thisProc : thisAS.getProcesses()) {
try {
vmData = VMDataFactory.getVMData(thisProc);
return;
} catch (IOException ex) {
// This happens if we can't find a JVM or a blob. Keep looking
}
}
}
fail("Couldn't initialize VMData");
} catch (FileNotFoundException e) {
fail("Could not initialize VMData: " + e.getMessage());
} catch (IOException e) {
fail("Could not initialize VMData: " + e.getMessage());
}
}
use of com.ibm.j9ddr.corereaders.ICore in project openj9 by eclipse.
the class DumpSegments method main.
/**
* @param args
*/
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.err.println("Expected 1 argument, got " + args.length);
}
String filename = args[0];
ICore core = CoreReader.readCoreFile(filename);
Collection<? extends IAddressSpace> addressSpaces = core.getAddressSpaces();
for (IAddressSpace as : addressSpaces) {
System.err.println("Address space: " + as.getAddressSpaceId());
List<? extends IMemoryRange> ranges = new ArrayList<IMemoryRange>(as.getMemoryRanges());
Collections.sort(ranges);
// System.err.println("Raw mappings");
// for(IMemoryRange thisRange : ranges) {
// System.err.println("Base: " +
// Long.toHexString(thisRange.getBaseAddress()) + " - size: " +
// Long.toHexString(thisRange.getSize()));
// if (thisRange.getBaseAddress() == 0xf95f000) {
// System.err.println("Found!");
// }
// }
List<Range> localRanges = new LinkedList<Range>();
for (IMemoryRange range : ranges) {
Range newRange = new Range();
newRange.base = range.getBaseAddress();
newRange.size = range.getSize();
localRanges.add(newRange);
}
localRanges = mergeRanges(localRanges);
for (Range range : localRanges) {
System.err.println("Base: " + Long.toHexString(range.base) + " - size: " + Long.toHexString(range.size));
try {
if (range.size > 7) {
/*
* Pick three addresses and read integers from them -
* proves that endian conversion is working
*/
long address1 = range.base;
long address2 = range.base + range.size - 5;
long address3 = (address1 + address2) / 2;
System.err.print(Long.toHexString(address1) + " - ");
System.err.println(Integer.toHexString(as.getIntAt(address1)));
System.err.print(Long.toHexString(address2) + " - ");
System.err.println(Integer.toHexString(as.getIntAt(address2)));
System.err.print(Long.toHexString(address3) + " - ");
if (0xf971ffd == address3) {
System.err.println("Found!");
}
System.err.println(Integer.toHexString(as.getIntAt(address3)));
}
} catch (MemoryFault ex) {
ex.printStackTrace();
}
}
}
}
Aggregations