~aleteoryx/muditaos

e6adfdb39acff59834ecdb9e941ec9fc534535e2 — Maciej-Mudita 3 years ago ac68ec9
[MOS-75] Fix incorrect data in pure heapstats tool

"pure heapstats" command was returning incorrect
system heap data
2 files changed, 12 insertions(+), 12 deletions(-)

M module-os/memory/usermem.c
M tools/misc
M module-os/memory/usermem.c => module-os/memory/usermem.c +11 -11
@@ 104,8 104,8 @@ static BlockLink_t userxStart, *userpxEnd = NULL;

/* Keeps track of the number of free bytes remaining, but says nothing about
fragmentation. */
static size_t xFreeBytesRemaining = 0U;
static size_t xMinimumEverFreeBytesRemaining = 0U;
static size_t userxFreeBytesRemaining = 0U;
static size_t userxMinimumEverFreeBytesRemaining = 0U;


/* Gets set to the top bit of an size_t type.  When this bit in the xBlockSize


@@ 167,7 167,7 @@ void *usermalloc(size_t xWantedSize)
					mtCOVERAGE_TEST_MARKER();
				}

				if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) )
				if( ( xWantedSize > 0 ) && ( xWantedSize <= userxFreeBytesRemaining ) )
				{
					/* Traverse the list from the start	(lowest address) block until
					one	of adequate size is found. */


@@ 222,11 222,11 @@ void *usermalloc(size_t xWantedSize)
							mtCOVERAGE_TEST_MARKER();
						}

						xFreeBytesRemaining -= pxBlock->xBlockSize;
						userxFreeBytesRemaining -= pxBlock->xBlockSize;

						if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining )
						if( userxFreeBytesRemaining < userxMinimumEverFreeBytesRemaining )
						{
							xMinimumEverFreeBytesRemaining = xFreeBytesRemaining;
							userxMinimumEverFreeBytesRemaining = userxFreeBytesRemaining;
						}
						else
						{


@@ 330,7 330,7 @@ void userfree(void *pv)
					vTaskSuspendAll();
					{
						/* Add this block to the list of free blocks. */
						xFreeBytesRemaining += pxLink->xBlockSize;
						userxFreeBytesRemaining += pxLink->xBlockSize;
						traceFREE( pv, pxLink->xBlockSize );
						prvInsertBlockIntoFreeList( ( ( BlockLink_t * ) pxLink ) );
					}


@@ 397,13 397,13 @@ void *userrealloc(void *pv, size_t xWantedSize) {

size_t usermemGetFreeHeapSize( void )
{
    return xFreeBytesRemaining;
    return userxFreeBytesRemaining;
}
/*-----------------------------------------------------------*/

size_t usermemGetMinimumEverFreeHeapSize( void )
{
    return xMinimumEverFreeBytesRemaining;
    return userxMinimumEverFreeBytesRemaining;
}
/*-----------------------------------------------------------*/



@@ 462,8 462,8 @@ size_t xTotalHeapSize = USERMEM_TOTAL_HEAP_SIZE;
    #endif

	/* Only one block exists - and it covers the entire usable heap space. */
	xMinimumEverFreeBytesRemaining = pxFirstFreeBlock->xBlockSize;
	xFreeBytesRemaining = pxFirstFreeBlock->xBlockSize;
	userxMinimumEverFreeBytesRemaining = pxFirstFreeBlock->xBlockSize;
	userxFreeBytesRemaining = pxFirstFreeBlock->xBlockSize;

	/* Work out the position of the top bit in a size_t variable. */
	xBlockAllocatedBit = ( ( size_t ) 1 ) << ( ( sizeof( size_t ) * heapBITS_PER_BYTE ) - 1 );

M tools/misc => tools/misc +1 -1
@@ 1,1 1,1 @@
Subproject commit 82dce5ad5558a6df4c3f1583ef4e5908ac5fcd9d
Subproject commit eeae49f9d885b6315ca1c4c912108066b5e2388b