use of com.ibm.j9ddr.corereaders.Platform 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.Platform in project openj9 by eclipse.
the class VMDataFactory method getBlobBasedirInArchive.
private static String getBlobBasedirInArchive(IProcess process) throws IOException {
ICore core = process.getAddressSpace().getCore();
Platform platform = core.getPlatform();
int bytesPerPointer = process.bytesPerPointer();
switch(platform) {
case AIX:
if (bytesPerPointer == 4) {
return "aix/ppc-32/";
} else {
return "aix/ppc-64/";
}
// break;
case LINUX:
String processorType = core.getProperties().getProperty(ICore.PROCESSOR_TYPE_PROPERTY);
// determine platform by processorType
if (bytesPerPointer == 4) {
if (processorType.equals("x86")) {
return "linux/ia32/";
} else if (processorType.equals("ppc")) {
return "linux/ppc-32/";
} else if (processorType.equals("s390")) {
return "linux/s390-31/";
}
} else {
if (processorType.equals("amd64")) {
return "linux/amd64/";
} else if (processorType.equals("ppc")) {
return "linux/ppc-64/";
} else if (processorType.equals("s390")) {
return "linux/s390-64/";
}
}
throw new UnknownArchitectureException(process, "Could not determine architecture for Linux core file.");
case WINDOWS:
if (bytesPerPointer == 4) {
return "win/ia32/";
} else {
return "win/amd64/";
}
// break;
case ZOS:
if (bytesPerPointer == 4) {
return "zos/s390-31/";
} else {
return "zos/s390-64/";
}
}
// shouldn't be here
throw new UnknownArchitectureException(process, "Could not determine platform of core file.");
}
use of com.ibm.j9ddr.corereaders.Platform in project openj9 by eclipse.
the class VMRegMapHelper method printRegisters.
/**
* This method find out which platform core file is generated
* and calls the method that prints that specific platforms registers.
* @param vm J9JavaVMPointer instance of vm from core file.
* @param level Level of registers to be printed.
* @param out PrintStream to print the output to the console.
* @throws UnknownArchitectureException In the case of unidentified platform of core file.
*/
public static void printRegisters(J9JavaVMPointer vm, int level, PrintStream out) throws UnknownArchitectureException {
IProcess process = vm.getProcess();
ICore core = process.getAddressSpace().getCore();
Platform platform = core.getPlatform();
boolean is64BitPlatform = (process.bytesPerPointer() == 8) ? true : false;
switch(platform) {
case AIX:
if (is64BitPlatform) {
printRegistersForAIX64BitPPC(level, out);
} else {
printRegistersForAIX32BitPPC(level, out);
}
break;
case LINUX:
String processorType = core.getProperties().getProperty(ICore.PROCESSOR_TYPE_PROPERTY);
if (is64BitPlatform) {
if (processorType.equals("amd64")) {
printRegistersForLinux64BitAMD64(level, out);
} else if (processorType.equals("ppc")) {
printRegistersForLinux64BitPPC(level, out);
} else if (processorType.equals("s390")) {
printRegistersForLinux64BitS390(level, out);
}
} else {
if (processorType.equals("x86")) {
printRegistersForLinux32BitX86(level, out);
} else if (processorType.equals("ppc")) {
printRegistersForLinux32BitPPC(level, out);
} else if (processorType.equals("s390")) {
printRegistersForLinux32BitS390(level, out);
}
}
break;
case WINDOWS:
if (is64BitPlatform) {
printRegistersForWindows64Bit(level, out);
} else {
printRegistersForWindows32Bit(level, out);
}
break;
case ZOS:
if (is64BitPlatform) {
printRegistersForZOS64BitS390(level, out);
} else {
printRegistersForZOS32BitS390(level, out);
}
break;
default:
throw new UnknownArchitectureException(process, "Could not determine platform of core file.");
}
}
Aggregations