mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils.git
synced 2025-06-11 02:26:00 +00:00
Added STA_DEBUG_HEAP_STATS for debugging
This commit is contained in:
parent
615900f16e
commit
dccdacae42
29
include/sta/rtos/debug/heap_stats.hpp
Normal file
29
include/sta/rtos/debug/heap_stats.hpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* heap_stats.hpp
|
||||||
|
*
|
||||||
|
* Created on: Nov 21, 2023
|
||||||
|
* Author: Dario
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef RTOS_DEBUG_HEAP_STATS_HPP
|
||||||
|
#define RTOS_DEBUG_HEAP_STATS_HPP
|
||||||
|
|
||||||
|
#include <sta/config.hpp>
|
||||||
|
#ifdef STA_DEBUGGING_ENABLED
|
||||||
|
|
||||||
|
#include <sta/debug/debug.hpp>
|
||||||
|
|
||||||
|
void printHeapStats();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Print the current heap stats.
|
||||||
|
*/
|
||||||
|
# define STA_DEBUG_HEAP_STATS() printHeapStats()
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
# define STA_DEBUG_HEAP_STATS() ((void)0)
|
||||||
|
|
||||||
|
#endif // STA_DEBUGGING_ENABLED
|
||||||
|
|
||||||
|
#endif /* RTOS_DEBUG_HEAP_STATS_HPP */
|
31
src/debug/heap_stats.cpp
Normal file
31
src/debug/heap_stats.cpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* heap_stats.cpp
|
||||||
|
*
|
||||||
|
* Created on: Nov 21, 2023
|
||||||
|
* Author: Dario
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sta/rtos/debug/heap_stats.hpp>
|
||||||
|
|
||||||
|
#ifdef STA_DEBUGGING_ENABLED
|
||||||
|
|
||||||
|
#include <FreeRTOS.h>
|
||||||
|
#include <cmsis_os2.h>
|
||||||
|
|
||||||
|
void printHeapStats()
|
||||||
|
{
|
||||||
|
xHeapStats stats;
|
||||||
|
vPortGetHeapStats(&stats);
|
||||||
|
|
||||||
|
STA_DEBUG_PRINTF(
|
||||||
|
"[HEAP STATS] \n Available: %d\n Lowest: %d\n Mallocs: %d\n Frees: %d",
|
||||||
|
stats.xAvailableHeapSpaceInBytes,
|
||||||
|
stats.xMinimumEverFreeBytesRemaining,
|
||||||
|
stats.xNumberOfSuccessfulAllocations,
|
||||||
|
stats.xNumberOfSuccessfulFrees
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // STA_DEBUGGING_ENABLED
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user