diff --git a/ChangeLog b/ChangeLog index ef687d659e..82f3fdc097 100644 --- a/ChangeLog +++ b/ChangeLog @@ -423,6 +423,7 @@ * NSH: Add cd and pwd commands and current working directory to all NSH commands that refer to paths. * Fix errors and warnings introduced into Linux sim build because of recent - Cygwin-related changes + Cygwin-based sim changes + * NSH: Add mem command to display heap usage diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html index f01dbd6e20..ade9169574 100644 --- a/Documentation/NuttX.html +++ b/Documentation/NuttX.html @@ -1057,7 +1057,8 @@ nuttx-0.3.13 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> * NSH: Add cd and pwd commands and current working directory to all NSH commands that refer to paths. * Fix errors and warnings introduced into Linux sim build because of recent - Cygwin-related changes + Cygwin-based sim changes + * NSH: Add mem command to display heap usage pascal-0.1.3 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> diff --git a/arch/sim/src/up_initialize.c b/arch/sim/src/up_initialize.c index fcfe9d24b0..7eb49cb1fa 100644 --- a/arch/sim/src/up_initialize.c +++ b/arch/sim/src/up_initialize.c @@ -41,6 +41,7 @@ #include #include #include +#include #include "up_internal.h" /**************************************************************************** diff --git a/examples/README.txt b/examples/README.txt index 6012d2087e..82055e3978 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -47,6 +47,7 @@ examples/nsh ifconfig CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS > 0 ls CONFIG_NFILE_DESCRIPTORS > 0 mb,mh,mw --- + mem --- mkdir !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 mkfatfs !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_FS_FAT mkfifo !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0 diff --git a/examples/nsh/nsh.h b/examples/nsh/nsh.h index 7ee0d71923..0484f4f218 100644 --- a/examples/nsh/nsh.h +++ b/examples/nsh/nsh.h @@ -239,6 +239,7 @@ extern int cmd_exec(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); extern int cmd_mb(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); extern int cmd_mh(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); extern int cmd_mw(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +extern int cmd_mem(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); extern int cmd_ps(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); #if CONFIG_NFILE_DESCRIPTORS > 0 diff --git a/examples/nsh/nsh_dbgcmds.c b/examples/nsh/nsh_dbgcmds.c index 5ae5d658ef..7e6cc72947 100644 --- a/examples/nsh/nsh_dbgcmds.c +++ b/examples/nsh/nsh_dbgcmds.c @@ -277,3 +277,24 @@ int cmd_mw(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return ret; } +/**************************************************************************** + * Name: cmd_mem + ****************************************************************************/ + +int cmd_mem(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) +{ + struct mallinfo mem; + +#ifdef CONFIG_CAN_PASS_STRUCTS + mem = mallinfo(); +#else + (void)mallinfo(&mem); +#endif + + nsh_output(vtbl, " arena: %8x\n", mem.arena); + nsh_output(vtbl, " ordblks: %8d\n", mem.ordblks); + nsh_output(vtbl, " mxordblk: %8x\n", mem.mxordblk); + nsh_output(vtbl, " uordblks: %8x\n", mem.uordblks); + nsh_output(vtbl, " fordblks: %8x\n", mem.fordblks); + return OK; +} \ No newline at end of file diff --git a/examples/nsh/nsh_main.c b/examples/nsh/nsh_main.c index cfa280edab..0d233016bd 100644 --- a/examples/nsh/nsh_main.c +++ b/examples/nsh/nsh_main.c @@ -111,6 +111,7 @@ static const struct cmdmap_s g_cmdmap[] = { "ls", cmd_ls, 1, 5, "[-lRs] " }, #endif { "mb", cmd_mb, 2, 3, "[=][ ]" }, + { "mem", cmd_mem, 1, 1, NULL }, #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 { "mkdir", cmd_mkdir, 2, 2, "" }, #ifdef CONFIG_FS_FAT