summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc/shell
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-11-27 13:25:22 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-11-28 13:09:07 +0100
commit2c3c657625f5129e3062058a2c83f0020fd6bab5 (patch)
tree1b6b2a5b125d4dffc1268768bc067f021c35a412 /cpukit/libmisc/shell
parentlibcsupport: Delete malloc statistics (diff)
downloadrtems-2c3c657625f5129e3062058a2c83f0020fd6bab5.tar.bz2
score: Return heap stats via _Heap_Get_information
Print out heap statistics via the MALLOC and WKSPACE shell commands.
Diffstat (limited to 'cpukit/libmisc/shell')
-rw-r--r--cpukit/libmisc/shell/internal.h7
-rw-r--r--cpukit/libmisc/shell/main_mallocinfo.c1
-rw-r--r--cpukit/libmisc/shell/main_wkspaceinfo.c3
-rw-r--r--cpukit/libmisc/shell/print_heapinfo.c39
4 files changed, 40 insertions, 10 deletions
diff --git a/cpukit/libmisc/shell/internal.h b/cpukit/libmisc/shell/internal.h
index ad51588b15..56b1bb6077 100644
--- a/cpukit/libmisc/shell/internal.h
+++ b/cpukit/libmisc/shell/internal.h
@@ -32,10 +32,13 @@ int rtems_shell_execute_cmd(const char *cmd, int argc, char *argv[]);
extern void rtems_shell_register_monitor_commands(void);
extern void rtems_shell_print_heap_info(
- const char *c,
- Heap_Information *h
+ const char *c,
+ const Heap_Information *h
);
+extern void rtems_shell_print_heap_stats(
+ const Heap_Statistics *s
+);
extern void rtems_shell_print_unified_work_area_message(void);
diff --git a/cpukit/libmisc/shell/main_mallocinfo.c b/cpukit/libmisc/shell/main_mallocinfo.c
index 54c602a6e8..43e988376a 100644
--- a/cpukit/libmisc/shell/main_mallocinfo.c
+++ b/cpukit/libmisc/shell/main_mallocinfo.c
@@ -37,6 +37,7 @@ static int rtems_shell_main_malloc_info(
malloc_info( &info );
rtems_shell_print_heap_info( "free", &info.Free );
rtems_shell_print_heap_info( "used", &info.Used );
+ rtems_shell_print_heap_stats( &info.Stats );
}
return 0;
diff --git a/cpukit/libmisc/shell/main_wkspaceinfo.c b/cpukit/libmisc/shell/main_wkspaceinfo.c
index f4f6f4db78..a9906524db 100644
--- a/cpukit/libmisc/shell/main_wkspaceinfo.c
+++ b/cpukit/libmisc/shell/main_wkspaceinfo.c
@@ -24,7 +24,7 @@
void rtems_shell_print_unified_work_area_message(void)
{
- printf( "\nC Program Heap and RTEMS Workspace are %s.\n",
+ printf( "C Program Heap and RTEMS Workspace are %s.\n",
rtems_configuration_get_unified_work_area() ? "the same" : "separate"
);
}
@@ -41,6 +41,7 @@ static int rtems_shell_main_wkspace_info(
_Protected_heap_Get_information( &_Workspace_Area, &info );
rtems_shell_print_heap_info( "free", &info.Free );
rtems_shell_print_heap_info( "used", &info.Used );
+ rtems_shell_print_heap_stats( &info.Stats );
return 0;
}
diff --git a/cpukit/libmisc/shell/print_heapinfo.c b/cpukit/libmisc/shell/print_heapinfo.c
index 12bc363f71..4ac9c96f88 100644
--- a/cpukit/libmisc/shell/print_heapinfo.c
+++ b/cpukit/libmisc/shell/print_heapinfo.c
@@ -14,22 +14,47 @@
#endif
#include <inttypes.h>
+#include <stdio.h>
-#include <rtems.h>
-#include <rtems/shell.h>
#include "internal.h"
void rtems_shell_print_heap_info(
- const char *c,
- Heap_Information *h
+ const char *c,
+ const Heap_Information *h
)
{
printf(
- "Number of %s blocks: %" PRId32 "\n"
- "Largest %s block: %" PRId32 "\n"
- "Total bytes %s: %" PRId32 "\n",
+ "Number of %s blocks: %12" PRId32 "\n"
+ "Largest %s block: %12" PRId32 "\n"
+ "Total bytes %s: %12" PRId32 "\n",
c, h->number,
c, h->largest,
c, h->total
);
}
+
+void rtems_shell_print_heap_stats(
+ const Heap_Statistics *s
+)
+{
+ printf(
+ "Instance number: %12" PRIu32 "\n"
+ "Size of the allocatable area in bytes: %12" PRIuPTR "\n"
+ "Minimum free size ever in bytes: %12" PRIuPTR "\n"
+ "Maximum number of free blocks ever: %12" PRIu32 "\n"
+ "Maximum number of blocks searched ever: %12" PRIu32 "\n"
+ "Total number of successful allocations: %12" PRIu32 "\n"
+ "Total number of searches ever: %12" PRIu32 "\n"
+ "Total number of successful calls to free: %12" PRIu32 "\n"
+ "Total number of successful resizes: %12" PRIu32 "\n",
+ s->instance,
+ s->size,
+ s->min_free_size,
+ s->max_free_blocks,
+ s->max_search,
+ s->allocs,
+ s->searches,
+ s->frees,
+ s->resizes
+ );
+}