use of com.ibm.j9ddr.exceptions.JVMNotDDREnabledException in project openj9 by eclipse.
the class VMDataFactory method getBlobFromArchive.
private static ImageInputStream getBlobFromArchive(String path, IProcess process) throws IOException {
InputStream blobFile = VMDataFactory.class.getResourceAsStream('/' + path);
if (blobFile != null) {
ImageInputStream iis = new InputStreamImageWrapper(blobFile);
iis.setByteOrder(process.getByteOrder());
return iis;
} else {
throw new JVMNotDDREnabledException(process, "DDR could not find VM structure data file " + path);
}
}
use of com.ibm.j9ddr.exceptions.JVMNotDDREnabledException in project openj9 by eclipse.
the class VMDataFactory method locateInServiceVMStructure.
// Locate InServiceStructure data for core with old J9RAS
private static ImageInputStream locateInServiceVMStructure(IProcess process) throws IOException {
// we find the platform/architecture from the process, and look for J9VM build id
// in process. Appropriate IOException thrown if any problem here.
String path = getBlobBasedirInArchive(process);
String j9vmid = getJ9VMBuildInCore(process);
try {
return getBlobFromArchive(path + j9vmid, process);
} catch (IOException e) {
// we can't find blob file for this build, try to give user enough info to make manual override
// using (colon separated) blob index.
InputStream indexIS = VMDataFactory.class.getResourceAsStream("/ddr.structurefiles.index");
if (indexIS == null) {
throw new JVMNotDDREnabledException(process, "DDR could not find VM structure data archive index. J9VM build ID: " + j9vmid + ". Platform: " + path + ". You can specify a structure file to use manually with the " + STRUCTUREFILE_PROPERTY + " system property.");
}
BufferedReader reader = new BufferedReader(new InputStreamReader(indexIS));
String allBlobs = reader.readLine();
String[] blobs = allBlobs.split(":");
StringBuffer candidates = new StringBuffer();
for (int i = 0; i < blobs.length; i++) {
if (blobs[i].startsWith(path)) {
if (candidates.length() != 0) {
candidates.append(", ");
}
candidates.append(blobs[i]);
}
}
throw new JVMNotDDREnabledException(process, "DDR could not find VM structure data file. J9VM build ID: " + j9vmid + ". Platform: " + path + ". You can specify a structure file to use manually with the " + STRUCTUREFILE_PROPERTY + " system property." + (candidates.length() > 0 ? " Possible structure file matches: " + candidates.toString() + "." : ""));
}
}
use of com.ibm.j9ddr.exceptions.JVMNotDDREnabledException in project openj9 by eclipse.
the class DDRInteractive method locateRuntimes.
private void locateRuntimes(ICore reader) {
currentCore = reader;
Collection<? extends IAddressSpace> spaces = reader.getAddressSpaces();
for (IAddressSpace thisSpace : spaces) {
// indicates if a context has been allocated for the address space
boolean hasCtxBeenAddedForAS = false;
Collection<? extends IProcess> processes = thisSpace.getProcesses();
for (IProcess thisProcess : processes) {
hasCtxBeenAddedForAS = true;
try {
IVMData vmData = VMDataFactory.getVMData(thisProcess);
if (vmData != null) {
contexts.add(new Context(thisProcess, vmData, nonVMCommands));
} else {
addMissingJVMToContexts(thisProcess);
}
} catch (JVMNotDDREnabledException e) {
addMissingJVMToContexts(thisProcess);
} catch (JVMNotFoundException e) {
addMissingJVMToContexts(thisProcess);
} catch (MissingDDRStructuresException e) {
addMissingJVMToContexts(thisProcess);
} catch (IOException e) {
System.err.println("Problem searching for VMData in process " + thisProcess);
e.printStackTrace();
// put the stack trace to the log
Logger logger = Logger.getLogger(LoggerNames.LOGGER_INTERACTIVE_CONTEXT);
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
logger.logp(FINE, null, null, sw.toString());
}
}
if (!hasCtxBeenAddedForAS) {
ASNoProcess as = new ASNoProcess(thisSpace);
addMissingJVMToContexts(as);
}
}
if (contexts.size() == 0) {
throw new RuntimeException("Couldn't find any address spaces in this dump");
} else {
// default to the first address space
currentContext = contexts.get(0);
for (Context ctx : contexts) {
// but if there is one with a JVM in it, set it to that
if (!(ctx.vmData instanceof MissingVMData)) {
currentContext = ctx;
break;
}
}
}
}
use of com.ibm.j9ddr.exceptions.JVMNotDDREnabledException in project openj9 by eclipse.
the class VMDataFactory method getJ9VMBuildInCore.
private static String getJ9VMBuildInCore(IProcess process) throws IOException {
try {
// Find J9VM build ID
byte[] pattern = null;
try {
// "J9VM - YYYYMMDD_BUILD_FLAGS"
pattern = "J9VM - ".getBytes("ASCII");
} catch (UnsupportedEncodingException e) {
// This shouldn't happen
throw new Error(e);
}
long addr = process.findPattern(pattern, 1, 0);
if (addr != -1) {
// get string between first and second underscores
// we can't hard-code offset as z/OS processes may contain extra bit
long startBuildIDAddr = -1;
for (long i = 0; i < 30; i++) {
// search max of 30 bytes
if (process.getByteAt(addr + i) == (byte) '_') {
if (startBuildIDAddr == -1) {
startBuildIDAddr = addr + i + 1;
} else {
// we've found second underscore
byte[] buildID = new byte[(int) (addr + i - startBuildIDAddr)];
for (int j = 0; j < addr + i - startBuildIDAddr; j++) {
buildID[j] = process.getByteAt(startBuildIDAddr + j);
}
return new String(buildID, "UTF-8");
}
}
}
}
} catch (MemoryFault e) {
throw new IOException(e.getMessage());
}
throw new JVMNotDDREnabledException(process, "No J9VM build ID found in process");
}
use of com.ibm.j9ddr.exceptions.JVMNotDDREnabledException in project openj9 by eclipse.
the class VMDataFactory method getAllVMData.
// TODO - fix this for z/OS which will require noting which RAS symbols have already been found in the core
/**
* Finds all of the blobs in a given process and wraps them in a IVMData structure.
*
* @param process process to scan
* @return all located blobs
* @throws IOException re-throws IOExceptions
*/
public static synchronized List<IVMData> getAllVMData(IProcess process) throws IOException {
List<IVMData> cachedVMData = vmDataCache.get(process);
if (cachedVMData != null) {
return cachedVMData;
}
// nothing in the cache for this process, so need to scan
// Get an ImageInputStream on the Structure Offset Data. This may or may not be in the core file itself.
List<IVMData> data = new ArrayList<IVMData>();
ImageInputStream in = null;
// End Of Memory
boolean EOM = false;
long address = 0;
j9RASAddress = 0;
while (!EOM) {
try {
address = j9RASAddress + 1;
in = getStructureDataFile(process, address);
if (in != null) {
EOM = !(in instanceof IMemoryImageInputStream);
IVMData vmdata = getVMData(process, in);
data.add(vmdata);
if (vmdata.getClassLoader().getHeader().getCoreVersion() == 1) {
// version 1 does not support multiple blobs
EOM = true;
break;
}
} else {
EOM = true;
}
} catch (JVMNotFoundException e) {
// no more JVMs were found
EOM = true;
} catch (JVMNotDDREnabledException e) {
// an older JVM was found, so ignore that and carry on looking
// on z/OS a failure with the j9ras symbol resolution aborts the scan
EOM = EOM | (process.getPlatform() == Platform.ZOS);
continue;
} catch (MissingDDRStructuresException e) {
// cannot process as the structures are missing
// on z/OS a failure with the j9ras symbol resolution aborts the scan
EOM = EOM | (process.getPlatform() == Platform.ZOS);
continue;
} catch (CorruptStructuresException e) {
// cannot process as the structures are corrupt and cannot be read
// on z/OS a failure with the j9ras symbol resolution aborts the scan
EOM = EOM | (process.getPlatform() == Platform.ZOS);
continue;
} catch (IOException e) {
continue;
}
}
// scan is switched off for Java-only applications (specifically jdmpview) via a system property.
if ((System.getProperty(NOEXTRASEARCHFORNODE_PROPERTY) == null) && (data.size() == 0)) {
StructureHeader header = null;
try {
header = findNodeVersion(process);
} catch (Exception e) {
if (e instanceof IOException) {
throw (IOException) e;
} else {
IOException ioe = new IOException();
// avoid use of IOException(throwable) to be compatible with J5
ioe.initCause(e);
throw ioe;
}
}
if (header != null) {
in = getBlobFromLibrary(process, header);
if (in != null) {
IVMData vmdata = getVMData(process, in);
data.add(vmdata);
}
}
}
vmDataCache.put(process, data);
return data;
}
Aggregations