use of com.ibm.dtfj.image.ImagePointer in project openj9 by eclipse.
the class JavaThread method addNewStackFrame.
public JavaStackFrame addNewStackFrame(long arguments, long method, long pc, int lineNumber) {
JavaStackFrame frame = null;
JavaMethod javaMethod = _javaVM.methodForID(method);
ImagePointer frameAddr = _javaVM.pointerInAddressSpace(arguments);
ImagePointer programCounter = _javaVM.pointerInAddressSpace(pc);
if (javaMethod == null) {
ImagePointer meth = _javaVM.pointerInAddressSpace(method);
frame = new JavaStackFrame(_javaVM, frameAddr, meth, programCounter, lineNumber);
} else {
frame = new JavaStackFrame(_javaVM, frameAddr, javaMethod, programCounter, lineNumber);
}
addFrame(frame);
return frame;
}
use of com.ibm.dtfj.image.ImagePointer in project openj9 by eclipse.
the class JCJavaMonitor method getThreads.
/**
* @param threadIDs
*/
private Iterator getThreads(Vector threadIDs) {
Vector threads = new Vector();
Iterator it = threadIDs.iterator();
while (it.hasNext()) {
ImagePointer pointer = (ImagePointer) it.next();
JCJavaThread waitingThread = fRuntime.findJavaThread(pointer.getAddress());
if (waitingThread != null) {
threads.add(waitingThread);
} else {
threads.add(new JCCorruptData("Unknown thread", pointer));
}
}
return threads.iterator();
}
use of com.ibm.dtfj.image.ImagePointer in project openj9 by eclipse.
the class HexdumpCommand method doCommand.
public void doCommand(String[] args) {
StringBuffer stringBuffer = new StringBuffer();
ImageAddressSpace imageAddressSpace = ctx.getAddressSpace();
if (null == imageAddressSpace) {
out.println("Could not find an address space which contains a process in this core file");
return;
}
long addressInDecimal = 0;
// dump 256 bytes by default
int numBytesToPrint = 16 * 16;
int asciiIndex = 0;
if (args.length != 0) {
Long address = Utils.longFromString(args[0]);
if (null == address) {
out.println("Specified address is invalid");
return;
}
addressInDecimal = address.longValue();
} else {
out.println("\"hexdump\" requires at least an address parameter");
return;
}
if (args.length > 1) {
try {
numBytesToPrint = Integer.parseInt(args[1]);
} catch (NumberFormatException nfe) {
out.println("Specified length is invalid");
return;
}
}
ImagePointer imagePointerBase = imageAddressSpace.getPointer(addressInDecimal);
boolean is_zOSdump = false;
try {
is_zOSdump = ctx.getImage().getSystemType().toLowerCase().indexOf("z/os") >= 0;
} catch (DataUnavailable e1) {
// unable to get the dump OS type, continue without the additional zOS EBCDIC option
} catch (CorruptDataException e1) {
// unable to get the dump OS type, continue without the additional zOS EBCDIC option
}
String asciiChars = "";
String ebcdicChars = "";
long i;
for (i = 0; i < numBytesToPrint; i++) {
ImagePointer imagePointer = imagePointerBase.add(i);
// stringBuffer.append(Long.toHexString(imagePointer.getAddress())+":\t");
try {
Byte byteValue = new Byte(imagePointer.getByteAt(0));
asciiIndex = (int) byteValue.byteValue();
if (asciiIndex < 0) {
asciiIndex += 256;
}
String rawHexString = Integer.toHexString(byteValue.intValue());
String fixedHexString = fixHexStringLength(rawHexString);
String hexText = fixedHexString;
if (0 == i % 4) {
hexText = " " + hexText;
}
if (0 == i % 16) {
hexText = "\n" + Long.toHexString(imagePointer.getAddress()) + ":" + hexText;
asciiChars = " |";
ebcdicChars = " |";
}
stringBuffer.append(hexText);
asciiChars += Utils.byteToAscii.substring(asciiIndex, asciiIndex + 1);
if (15 == i % 16 && i != 0) {
asciiChars += "|";
stringBuffer.append(asciiChars);
}
if (is_zOSdump) {
// for zOS dumps, output additional EBCDIC interpretation of the memory byes
ebcdicChars += Utils.byteToEbcdic.substring(asciiIndex, asciiIndex + 1);
if (15 == i % 16 && i != 0) {
ebcdicChars += "|";
stringBuffer.append(ebcdicChars);
}
}
} catch (MemoryAccessException e) {
out.println("Address not in memory - 0x" + Long.toHexString(imagePointer.getAddress()));
return;
} catch (CorruptDataException e) {
out.println("Dump data is corrupted");
return;
}
}
long undisplayedBytes = 16 - i % 16;
if (16 != undisplayedBytes) {
stringBuffer.append(padSpace(undisplayedBytes, asciiChars));
if (is_zOSdump) {
// Add padding and output the remaining EBCDIC characters
for (int j = 0; j < undisplayedBytes; j++) {
ebcdicChars = " " + ebcdicChars;
}
stringBuffer.append(" " + ebcdicChars);
}
}
stringBuffer.append("\n");
out.println(new String(stringBuffer));
/*properties.put(Utils.CURRENT_MEM_ADDRESS,
Long.toHexString(addressInDecimal+numBytesToPrint));*/
ctx.getProperties().put(Utils.CURRENT_MEM_ADDRESS, new Long(addressInDecimal));
ctx.getProperties().put(Utils.CURRENT_NUM_BYTES_TO_PRINT, new Integer(numBytesToPrint));
}
use of com.ibm.dtfj.image.ImagePointer in project openj9 by eclipse.
the class JavaObject method getJavaClass.
/* (non-Javadoc)
* @see com.ibm.dtfj.java.JavaObject#getJavaClass()
*/
public JavaClass getJavaClass() throws CorruptDataException {
if (0 != _basePointer.getAddress()) {
ImagePointer classPointer;
if (_containingHeap == null)
throw new CorruptDataException(new CorruptData("unable to access class pointer as containing heap is null", _basePointer));
try {
classPointer = _containingHeap.readClassPointerRelativeTo(_basePointer);
} catch (MemoryAccessException e) {
throw new CorruptDataException(new CorruptData("unable to access class pointer", _basePointer));
}
long classID = classPointer.getAddress();
/* CMVC 167379: Lowest few bits of the class id are used as flags, and should be
* masked with ~(J9_REQUIRED_CLASS_ALIGNMENT - 1) to find real class id.
*/
long classAlignment = _containingHeap.getClassAlignment();
long alignedClassID = classID;
if (classAlignment > 0) {
alignedClassID &= (~(classAlignment - 1L));
}
JavaClass ret = _javaVM.getClassForID(alignedClassID);
if (ret == null) {
throw new CorruptDataException(new CorruptData("Unknown class ID " + Long.toHexString(alignedClassID) + " for object " + Long.toHexString(_basePointer.getAddress()) + " (read class ID from " + Long.toHexString(classPointer.getAddress()) + ", in memory value was " + Long.toHexString(classID) + ")", _basePointer));
}
return ret;
} else {
throw new NullPointerException();
}
}
use of com.ibm.dtfj.image.ImagePointer in project openj9 by eclipse.
the class JavaClass method getConstantPoolReferences.
/* (non-Javadoc)
* @see com.ibm.dtfj.java.JavaClass#getConstantPoolReferences()
*/
public Iterator getConstantPoolReferences() {
// first look up all the class IDs and translate them into classes then add the objects
Iterator ids = _constantPoolClassRefs.iterator();
Vector allRefs = new Vector();
while (ids.hasNext()) {
long oneID = ((Long) ids.next()).longValue();
Object toBeAdded = null;
com.ibm.dtfj.java.JavaClass oneClass = _javaVM.getClassForID(oneID);
if (oneClass == null) {
toBeAdded = new CorruptData("Unknown class in constant pool " + oneID, null);
} else {
try {
toBeAdded = oneClass.getObject();
} catch (CorruptDataException e) {
toBeAdded = e.getCorruptData();
} catch (Exception e) {
toBeAdded = new CorruptData(e.getMessage());
}
}
allRefs.add(toBeAdded);
}
// Loop through the list of constant pool objects, instantiating them and adding them to the list
for (int i = 0; i < _constantPoolObjects.size(); i++) {
try {
long objectId = ((Long) (_constantPoolObjects.get(i))).longValue();
if (objectId != 0) {
ImagePointer pointer = _javaVM.pointerInAddressSpace(objectId);
try {
JavaObject instance = _javaVM.getObjectAtAddress(pointer);
allRefs.add(instance);
} catch (IllegalArgumentException e) {
// getObjectAtAddress may throw an IllegalArgumentException if the address is not aligned
allRefs.add(new CorruptData(e.getMessage(), pointer));
}
}
} catch (CorruptDataException e) {
allRefs.add(e.getCorruptData());
}
}
return allRefs.iterator();
}
Aggregations