Search in sources :

Example 16 with ImagePointer

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;
}
Also used : CorruptImagePointer(com.ibm.dtfj.image.j9.corrupt.CorruptImagePointer) ImagePointer(com.ibm.dtfj.image.ImagePointer)

Example 17 with ImagePointer

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();
}
Also used : ImagePointer(com.ibm.dtfj.image.ImagePointer) JCCorruptData(com.ibm.dtfj.image.javacore.JCCorruptData) Iterator(java.util.Iterator) Vector(java.util.Vector)

Example 18 with ImagePointer

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));
}
Also used : CorruptDataException(com.ibm.dtfj.image.CorruptDataException) ImageAddressSpace(com.ibm.dtfj.image.ImageAddressSpace) ImagePointer(com.ibm.dtfj.image.ImagePointer) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) MemoryAccessException(com.ibm.dtfj.image.MemoryAccessException)

Example 19 with ImagePointer

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();
    }
}
Also used : ImagePointer(com.ibm.dtfj.image.ImagePointer) JavaClass(com.ibm.dtfj.java.JavaClass) CorruptData(com.ibm.dtfj.image.j9.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) MemoryAccessException(com.ibm.dtfj.image.MemoryAccessException)

Example 20 with ImagePointer

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();
}
Also used : CorruptDataException(com.ibm.dtfj.image.CorruptDataException) MemoryAccessException(com.ibm.dtfj.image.MemoryAccessException) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) ImagePointer(com.ibm.dtfj.image.ImagePointer) JavaObject(com.ibm.dtfj.java.JavaObject) Iterator(java.util.Iterator) JavaObject(com.ibm.dtfj.java.JavaObject) CorruptData(com.ibm.dtfj.image.j9.CorruptData) Vector(java.util.Vector)

Aggregations

ImagePointer (com.ibm.dtfj.image.ImagePointer)45 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)19 MemoryAccessException (com.ibm.dtfj.image.MemoryAccessException)12 JavaClass (com.ibm.dtfj.java.JavaClass)9 JCInvalidArgumentsException (com.ibm.dtfj.java.javacore.JCInvalidArgumentsException)8 CorruptData (com.ibm.dtfj.image.j9.CorruptData)7 JavaObject (com.ibm.dtfj.java.JavaObject)7 BuilderFailureException (com.ibm.dtfj.javacore.builder.BuilderFailureException)7 Iterator (java.util.Iterator)7 JCJavaClass (com.ibm.dtfj.java.javacore.JCJavaClass)6 ImageAddressSpace (com.ibm.dtfj.image.ImageAddressSpace)5 JCJavaObject (com.ibm.dtfj.java.javacore.JCJavaObject)4 ArrayList (java.util.ArrayList)4 Vector (java.util.Vector)4 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)3 ImageSection (com.ibm.dtfj.image.ImageSection)3 JCImageThread (com.ibm.dtfj.image.javacore.JCImageThread)3 JCJavaMonitor (com.ibm.dtfj.java.javacore.JCJavaMonitor)3 IOException (java.io.IOException)3 CorruptData (com.ibm.dtfj.image.CorruptData)2