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;
}
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);
}
}
Aggregations