use of com.ibm.j9ddr.corereaders.memory.MemoryFault in project openj9 by eclipse.
the class GpInfoCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
long vmAddress = context.vmAddress;
try {
long j9rasAddress = CommandUtils.followPointerFromStructure(context, "J9JavaVM", vmAddress, "j9ras");
long crashInfoAddress = CommandUtils.followPointerFromStructure(context, "J9RAS", j9rasAddress, "crashInfo");
if (crashInfoAddress != 0l) {
long failingThread = CommandUtils.followPointerFromStructure(context, "J9RASCrashInfo", crashInfoAddress, "failingThread");
long failingThreadID = CommandUtils.followPointerFromStructure(context, "J9RASCrashInfo", crashInfoAddress, "failingThreadID");
long gpinfo = CommandUtils.followPointerFromStructure(context, "J9RASCrashInfo", crashInfoAddress, "gpInfo");
out.println("Failing Thread: !j9vmthread 0x" + Long.toHexString(failingThread));
out.println("Failing Thread ID: 0x" + Long.toHexString(failingThreadID) + " (" + failingThreadID + ")");
out.println("gpInfo:");
out.println(CommandUtils.getCStringAtAddress(context.process, gpinfo));
} else {
out.println("Core does not appear to have been triggered by a gpf. No J9RASCrashInfo found.");
}
} catch (MemoryFault e) {
throw new DDRInteractiveCommandException(e);
} catch (com.ibm.j9ddr.NoSuchFieldException e) {
throw new DDRInteractiveCommandException(e);
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.corereaders.memory.MemoryFault in project openj9 by eclipse.
the class VMDataFactory method foundRAS.
private static ImageInputStream foundRAS(IProcess addressSpace, long candidateAddress) throws IOException {
try {
j9RASAddress = candidateAddress;
String structureFileName = System.getProperty(STRUCTUREFILE_PROPERTY);
if (structureFileName != null) {
// for it in the blob archive
try {
return getStructureDataFromFile(structureFileName, addressSpace);
} catch (FileNotFoundException e) {
return getBlobFromArchive(structureFileName, addressSpace);
}
}
int j9RASVersion = addressSpace.getIntAt(candidateAddress + J9RAS_VERSION_OFFSET);
short j9RASMajorVersion = (short) (j9RASVersion >> 16);
if (j9RASMajorVersion < MINIMUM_J9RAS_MAJOR_VERSION) {
return locateInServiceVMStructure(addressSpace);
}
long ddrDataStart = addressSpace.getPointerAt(candidateAddress + DDR_DATA_POINTER_OFFSET);
if (0 == ddrDataStart) {
// CMVC 172446 : no valid address to DDR blob, so see if we can locate it via the blob archive
try {
return locateInServiceVMStructure(addressSpace);
} catch (IOException e) {
// failed to locate a blob
MissingDDRStructuresException ioe = new MissingDDRStructuresException(addressSpace, "System dump was generated by a DDR-enabled JVM, but did not contain embedded DDR structures. This dump cannot be analyzed by DDR. " + "You can specify the location of a DDR structure file to use with the " + STRUCTUREFILE_PROPERTY + " system property");
ioe.initCause(e);
throw ioe;
}
}
// the address may be a marker to treat it in a special way, rather than as an actual address
// -1 = the blob is located directly after this structure
// -2 = there is only a blob descriptor loaded
long marker = (addressSpace.bytesPerPointer() == 4) ? 0xFFFFFFFF00000000L | ddrDataStart : ddrDataStart;
if (marker == -2) {
StructureHeader header = new StructureHeader((byte) 1);
ddrDataStart = candidateAddress + DDR_DATA_POINTER_OFFSET + (addressSpace.bytesPerPointer() * 2);
ImageInputStream stream = new IMemoryImageInputStream(addressSpace, ddrDataStart);
header.readBlobVersion(stream);
return getBlobFromLibrary(addressSpace, header);
}
if (marker == -1) {
if (j9RASVersion == 0x100000) {
// there is one pointer in the way that needs to be skipped over
ddrDataStart = candidateAddress + DDR_DATA_POINTER_OFFSET + (addressSpace.bytesPerPointer() * 2);
} else {
MissingDDRStructuresException ioe = new MissingDDRStructuresException(addressSpace, "System dump was generated by a DDR-enabled JVM, but did not contain embedded DDR structures. This dump cannot be analyzed by DDR. " + "You can specify the location of a DDR structure file to use with the " + STRUCTUREFILE_PROPERTY + " system property");
throw ioe;
}
}
return new IMemoryImageInputStream(addressSpace, ddrDataStart);
} catch (MemoryFault e) {
// put the stack trace to the log
Logger logger = Logger.getLogger(LoggerNames.LOGGER_STRUCTURE_READER);
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
logger.logp(FINE, null, null, sw.toString());
throw new IOException(e.getMessage());
}
}
use of com.ibm.j9ddr.corereaders.memory.MemoryFault 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.corereaders.memory.MemoryFault in project openj9 by eclipse.
the class JniImageInputStream method read.
@Override
public int read() throws IOException {
try {
byte readAddress = memory.getByteAt(streamPos);
streamPos++;
return readAddress;
} catch (MemoryFault e) {
throw new IOException(e.getMessage() + ":" + e.getAddress());
}
}
use of com.ibm.j9ddr.corereaders.memory.MemoryFault in project openj9 by eclipse.
the class BaseWindowsOSThread method walkStack32.
private void walkStack32() throws CorruptDataException {
// Windows stack frames can be read by following the ebp to the base of
// the stack: old ebp is at ebp(0) and and return address to parent context
// is ebp(sizeof(void*))
// 1) find the ebp in the register file
long ebp = getBasePointer();
long eip = getInstructionPointer();
long esp = getStackPointer();
long stackStart = getStackStart();
long stackEnd = getStackEnd();
// eip may be -1 if we're in a system call
if (-1 == eip && stackStart <= esp && esp < stackEnd) {
try {
eip = process.getPointerAt(esp);
} catch (MemoryFault e) {
// ignore
}
}
int bytesPerPointer = process.bytesPerPointer();
// Add the current frame first. If ebp doesn't point into the stack, try esp.
if (Addresses.lessThanOrEqual(stackStart, ebp) && Addresses.lessThan(ebp, stackEnd)) {
stackFrames.add(new OSStackFrame(ebp, eip));
} else if (Addresses.lessThan(stackStart, esp) && Addresses.lessThan(esp, stackEnd)) {
stackFrames.add(new OSStackFrame(esp, eip));
ebp = esp + bytesPerPointer;
}
while (stackStart <= ebp && ebp < stackEnd) {
try {
long newBP = process.getPointerAt(ebp);
long retAddress = process.getPointerAt(ebp + bytesPerPointer);
stackFrames.add(new OSStackFrame(newBP, retAddress));
ebp = newBP;
} catch (MemoryFault e) {
// stop trying to read meaningless memory
break;
}
}
}
Aggregations