Search in sources :

Example 6 with J9MemTagIterator

use of com.ibm.j9ddr.vm29.j9.walkers.J9MemTagIterator in project openj9 by eclipse.

the class J9MemTagCommands method buildCallsitesTable.

private Map<String, J9DbgExtMemStats> buildCallsitesTable(J9MemTagIterator it, boolean lookingForFreedCallSites) {
    Map<String, J9DbgExtMemStats> callSites = new TreeMap<String, J9DbgExtMemStats>();
    while (it.hasNext()) {
        J9MemTagPointer header = it.next();
        long allocSize;
        String callsite;
        try {
            allocSize = header.allocSize().longValue();
            if (lookingForFreedCallSites && it.isFooterCorrupted()) {
                /* 
					 * Corrupted footer is accepted only if freed call sites are being searched. 					 
					 * 
					 * If any part of current freed memory block re-allocated, 
					 * then just assume the memory between freed header and alloc header as freed memory.
					 *   
					 */
                J9MemTagIterator allocIte = J9MemTagIterator.iterateAllocatedHeaders(header.longValue() + J9MemTag.SIZEOF, header.add(allocSize).longValue() + +J9MemTag.SIZEOF);
                if (allocIte.hasNext()) {
                    J9MemTagPointer nextAllocHeader = allocIte.next();
                    allocSize = nextAllocHeader.longValue() - header.longValue();
                }
            }
            callsite = header.callSite().getCStringAtOffset(0);
            /*
				 * Since the type of next alloc size memory is known, iterator can safely jump to the end of it.  
				 */
            it.moveCurrentSearchAddress(allocSize);
            if (!callSites.containsKey(callsite)) {
                callSites.put(callsite, new J9DbgExtMemStats(header.allocSize().longValue()));
            } else {
                J9DbgExtMemStats memStats = callSites.get(callsite);
                memStats.incrementTotalBlocksAllocated();
                memStats.addTotalBytesAllocated(header.allocSize().longValue());
            }
        } catch (CorruptDataException e) {
            // Unlikely - J9MemTagIterator already checksummed the header
            out.println("Unexpected CDE reading contents of " + Long.toHexString(header.getAddress()));
            e.printStackTrace(out);
            continue;
        }
    }
    return callSites;
}
Also used : CorruptDataException(com.ibm.j9ddr.CorruptDataException) TreeMap(java.util.TreeMap) J9MemTagPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MemTagPointer) J9MemTagIterator(com.ibm.j9ddr.vm29.j9.walkers.J9MemTagIterator)

Example 7 with J9MemTagIterator

use of com.ibm.j9ddr.vm29.j9.walkers.J9MemTagIterator in project openj9 by eclipse.

the class J9MemTagCommands method corruptData.

/**
 * CorruptData handler used with J9MemTagIterator
 */
public void corruptData(String message, CorruptDataException e, boolean fatal) {
    if (e instanceof J9MemTagCheckError) {
        J9MemTagCheckError casted = (J9MemTagCheckError) e;
        out.println("J9MemTag check failed at " + Long.toHexString(casted.getAddress()) + ": " + message + " :" + e.getMessage());
    } else {
        e.printStackTrace(out);
    }
}
Also used : J9MemTagCheckError(com.ibm.j9ddr.vm29.pointer.helper.J9MemTagHelper.J9MemTagCheckError)

Aggregations

J9MemTagIterator (com.ibm.j9ddr.vm29.j9.walkers.J9MemTagIterator)6 CorruptDataException (com.ibm.j9ddr.CorruptDataException)4 J9MemTagPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MemTagPointer)4 ArrayList (java.util.ArrayList)2 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)1 J9MemTagCheckError (com.ibm.j9ddr.vm29.pointer.helper.J9MemTagHelper.J9MemTagCheckError)1 TreeMap (java.util.TreeMap)1