Add dynamic memory info to meminfo command
This commit is contained in:
parent
66d6a76e1a
commit
4e4dc8e16e
@ -24,6 +24,7 @@
|
||||
#include <reflow-controller/adc-meas.h>
|
||||
#include <reflow-controller/digio.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <helper-macros/helper-macros.h>
|
||||
#include <reflow-controller/systick.h>
|
||||
#include <stm-periph/unique-id.h>
|
||||
@ -200,12 +201,13 @@ static shellmatta_retCode_t shell_cmd_cal(const shellmatta_handle_t handle,
|
||||
return SHELLMATTA_OK;
|
||||
}
|
||||
|
||||
static shellmatta_retCode_t shell_get_sp(const shellmatta_handle_t handle,
|
||||
static shellmatta_retCode_t shell_meminfo(const shellmatta_handle_t handle,
|
||||
const char *arguments,
|
||||
uint32_t length)
|
||||
{
|
||||
(void)arguments;
|
||||
(void)length;
|
||||
struct mallinfo mi;
|
||||
|
||||
shellmatta_printf(handle,
|
||||
"Stack pointer: %p\r\n"
|
||||
@ -214,6 +216,15 @@ static shellmatta_retCode_t shell_get_sp(const shellmatta_handle_t handle,
|
||||
read_stack_pointer(),
|
||||
stack_check_get_usage(),
|
||||
stack_check_get_free());
|
||||
|
||||
mi = mallinfo();
|
||||
shellmatta_printf(handle, "\r\nDynamic Memory Management\r\n");
|
||||
shellmatta_printf(handle, "Allocated bytes: %d\r\n", mi.arena, mi.arena);
|
||||
shellmatta_printf(handle, "Number of free chunks: %d\r\n", mi.ordblks);
|
||||
shellmatta_printf(handle, "Top-most, releasable space: %d\r\n", mi.keepcost);
|
||||
shellmatta_printf(handle, "Total free space: %d\r\n", mi.fordblks);
|
||||
shellmatta_printf(handle, "Total allocated space: %d\r\n", mi.uordblks);
|
||||
|
||||
return SHELLMATTA_OK;
|
||||
}
|
||||
|
||||
@ -352,11 +363,11 @@ static shellmatta_cmd_t cmd[10] = {
|
||||
.next = &cmd[8],
|
||||
},
|
||||
{
|
||||
.cmd = "get-stack-pointer",
|
||||
.cmdAlias = "sp",
|
||||
.helpText = "Get the stack pointer",
|
||||
.cmd = "meminfo",
|
||||
.cmdAlias = NULL,
|
||||
.helpText = "Get information about memory usage",
|
||||
.usageText = "",
|
||||
.cmdFct = shell_get_sp,
|
||||
.cmdFct = shell_meminfo,
|
||||
.next = &cmd[9],
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user