use of com.ibm.j9ddr.corereaders.memory.IProcess in project openj9 by eclipse.
the class J9DDRImageAddressSpace method getPointerProcess.
private IProcess getPointerProcess() {
// The implementation of J9DDRImagePointer is tied to an IProcess. On Windows, Linux and AIX there is only one process
// in an address space, but on z/OS an address space can contain more than one process, and even a mix of 31 bit and 64
// bit processes. In practice it does not matter which process we use when constructing and using an J9DDRImagePointer,
// the compromise here is to take the first 64-bit process we find, else any process, else null.
Iterator<? extends IProcess> procs = as.getProcesses().iterator();
IProcess process = null;
while (procs.hasNext()) {
process = procs.next();
if (process.bytesPerPointer() == 8) {
// Found a 64-bit process, return it
return process;
}
}
// Return any 31/32 bit process we found, or null if no process in this address space
return process;
}
use of com.ibm.j9ddr.corereaders.memory.IProcess in project openj9 by eclipse.
the class J9DDRImageAddressSpace method getProcesses.
public Iterator<J9DDRImageProcess> getProcesses() {
Collection<? extends IProcess> processes = as.getProcesses();
List<J9DDRImageProcess> dtfjList = new LinkedList<J9DDRImageProcess>();
for (IProcess thisProcess : processes) {
dtfjList.add(new J9DDRImageProcess(thisProcess));
}
return dtfjList.iterator();
}
use of com.ibm.j9ddr.corereaders.memory.IProcess 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.memory.IProcess in project openj9 by eclipse.
the class RuntimeSettingsCommand method run.
/**
* Run method for !runtimesettings extension.
*
* @param command !runtimesettings
* @param args args passed by !runtimesettings 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("!runtimesettings expects no args. Usage :");
printUsage(out);
return;
}
try {
Long currentSoftmx;
String qualifiedCurrentSoftmx = "";
String initialSoftmx = "not set";
J9RASPointer ras = DataType.getJ9RASPointer();
J9JavaVMPointer vm = J9RASHelper.getVM(ras);
IProcess process = vm.getProcess();
J9DDRImageProcess ddrProcess = new J9DDRImageProcess(process);
String cmdline;
/* Parse the command line of a running program that generated core
* file to get the original -Xsoftmx setting
*/
cmdline = ddrProcess.getCommandLine();
int start = cmdline.indexOf("-Xsoftmx");
int length = "-Xsoftmx".length();
int end = cmdline.indexOf(" ", start);
if (-1 != start) {
/* extract the value from the end of the option */
initialSoftmx = cmdline.substring(start + length, end);
initialSoftmx = initialSoftmx.toUpperCase();
}
currentSoftmx = new Long(GCExtensions.softMx().longValue());
qualifiedCurrentSoftmx = currentSoftmx.toString();
Matcher m = p.matcher(initialSoftmx);
/* if initial softmx value is set on the command line as qualified
* value, print current softmx value in qualified form, otherwise
* print current in byte value
*/
if (m.matches()) {
/* User may add multiple letters after the number on the command
* line, currently GC parser accepts this and simply ignores
* extra letters, so we need to do the same, set initialSoftmx
* to the first match of the pattern
*/
initialSoftmx = m.group(1);
/* convert size in bytes held in currentSoftmx to canonical form */
qualifiedCurrentSoftmx = qualifiedSize(currentSoftmx);
/* If qualifiedSize() returns size in bytes, it could not
* convert the value, so print the initialSoftmx variable in
* bytes
*/
m = p.matcher(qualifiedCurrentSoftmx);
if (!m.matches()) {
initialSoftmx = sizeInBytes(initialSoftmx);
}
} else {
/* InitialSoftmx value has either not been set or is in byte
* form, so print current value as byte form
*/
qualifiedCurrentSoftmx = currentSoftmx.toString();
}
printTableOfEqualSpacedColumns(out, new String[] { "name", "initial value", "current value" }, new String[][] { { "-Xsoftmx", initialSoftmx, qualifiedCurrentSoftmx } });
} catch (DataUnavailable e) {
/* For Z/OS core files, command line 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");
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.corereaders.memory.IProcess 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());
}
}
Aggregations