This tools is promising and seems to work. But I'd have some questions about the log entries.
- what does ELogContentOnFree means?
This means that the content of the cell will be logged when the cell is freed.
- Could you please detail the R: (realloc?) line in the log file? An example that confuses me below. What is that 0 in the realloc?
Yes, R: is a reallocation. Here is the code.
<source>
TAny* RNBHeap::ReAlloc(TAny* aPtr, TInt aSize, TInt aMode)
{
TInt oldLen=0;
if(aPtr)
oldLen=AllocLen(aPtr);
TAny* cell=RHeap::ReAlloc(aPtr, aSize, aMode);
if(iMode & ELogRealloc)
{
TBuf<200> logStr;
_LIT(KFmt, "\nR: 0x%08x %d 0x%08x %09d %09d");
logStr.Format(KFmt, cell, oldLen, aPtr, aSize, aMode);
iLogger.Log(logStr);
}
return cell;
} </source>
A: 0x55903398 000000032
R: 0x55903398 0 0x00000000 000000032 000000000
A: 0x559033c0 000000060
A: 0x55903400 000000032
A: 0x55903428 000000028
A: 0x55903448 000000068
A: 0x559031a8 000000020
A: 0x55903490 000000048
A: 0x559034c8 000000036
A: 0x559034f0 000000068
A: 0x55903538 000000016
A: 0x55903550 000000028
D: 0x55903398 000000036 = 88319055c03390550034905528349055a8319055
R: 0x55903570 36 0x55903398 000000064 000000000
A: 0x55903398 000000024
- What is that 4bytes different on allocated and reallocated buffers. See example above where 0x559036b8 is allocated for 32bytes, and later it's 36 and
This is just the difference between size of the allocated data and the size of the cell, which contains the points to the next cell on the heap.
A: 0x559036b8 000000016
R: 0x559036b8 0 0x00000000 000000016 000000000
D: 0x559036b8 000000020 = 4e38201003030303030303030303030303030303
Thanks!
I am glad it was interesting to someone. It could probably be developed a bit more. It was just something I bashed out over a couple of days out of interest.