[rtems commit] libcsupport: Delete malloc statistics

Sebastian Huber sebh at rtems.org
Fri Nov 28 12:38:33 UTC 2014


Module:    rtems
Branch:    master
Commit:    01557b0c6e723627427195bb33bdfe0b125c70b1
Changeset: http://git.rtems.org/rtems/commit/?id=01557b0c6e723627427195bb33bdfe0b125c70b1

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Nov 27 11:44:48 2014 +0100

libcsupport: Delete malloc statistics

Use the heap handler statistics instead.  Add heap walk option to MALLOC
shell command.

close #1367

---

 cpukit/libcsupport/Makefile.am                     |  7 +-
 cpukit/libcsupport/include/rtems/malloc.h          | 63 -----------------
 cpukit/libcsupport/src/calloc.c                    |  5 --
 cpukit/libcsupport/src/free.c                      | 10 +--
 cpukit/libcsupport/src/malloc.c                    |  8 ---
 cpukit/libcsupport/src/malloc_get_statistics.c     | 36 ----------
 cpukit/libcsupport/src/malloc_initialize.c         | 11 ---
 cpukit/libcsupport/src/malloc_p.h                  |  7 --
 cpukit/libcsupport/src/malloc_report_statistics.c  | 29 --------
 .../src/malloc_report_statistics_plugin.c          | 59 ----------------
 cpukit/libcsupport/src/malloc_statistics_helpers.c | 77 ---------------------
 cpukit/libcsupport/src/posix_memalign.c            |  6 --
 cpukit/libcsupport/src/realloc.c                   |  4 --
 .../libcsupport/src/rtems_heap_extend_via_sbrk.c   |  2 -
 cpukit/libcsupport/src/rtems_memalign.c            |  6 --
 cpukit/libmisc/shell/main_mallocinfo.c             | 32 ++++-----
 cpukit/sapi/include/confdefs.h                     | 13 ----
 doc/shell/memory.t                                 | 79 ++++++++--------------
 doc/user/conf.t                                    | 31 ---------
 testsuites/libtests/Makefile.am                    |  2 +-
 testsuites/libtests/configure.ac                   |  1 -
 testsuites/libtests/malloc05/Makefile.am           | 21 ------
 testsuites/libtests/malloc05/init.c                | 58 ----------------
 testsuites/libtests/malloc05/malloc05.doc          | 19 ------
 testsuites/libtests/malloc05/malloc05.scn          |  4 --
 testsuites/libtests/malloctest/task1.c             |  1 -
 26 files changed, 45 insertions(+), 546 deletions(-)

diff --git a/cpukit/libcsupport/Makefile.am b/cpukit/libcsupport/Makefile.am
index dfa8736..1486194 100644
--- a/cpukit/libcsupport/Makefile.am
+++ b/cpukit/libcsupport/Makefile.am
@@ -98,10 +98,9 @@ MALLOC_C_FILES = src/malloc_initialize.c src/calloc.c src/malloc.c \
     src/realloc.c src/_calloc_r.c src/_malloc_r.c \
     src/free.c src/_free_r.c \
     src/_realloc_r.c src/mallocfreespace.c \
-   src/mallocgetheapptr.c src/mallocsetheapptr.c \
-    src/mallocinfo.c src/malloc_walk.c src/malloc_get_statistics.c \
-    src/malloc_report_statistics.c src/malloc_report_statistics_plugin.c \
-    src/malloc_statistics_helpers.c src/posix_memalign.c \
+    src/mallocgetheapptr.c src/mallocsetheapptr.c \
+    src/mallocinfo.c src/malloc_walk.c \
+    src/posix_memalign.c \
     src/rtems_memalign.c src/malloc_deferred.c \
     src/malloc_dirtier.c src/malloc_p.h src/rtems_malloc.c \
     src/rtems_heap_extend_via_sbrk.c \
diff --git a/cpukit/libcsupport/include/rtems/malloc.h b/cpukit/libcsupport/include/rtems/malloc.h
index 25c2ead..7c00f21 100644
--- a/cpukit/libcsupport/include/rtems/malloc.h
+++ b/cpukit/libcsupport/include/rtems/malloc.h
@@ -48,34 +48,6 @@ void RTEMS_Malloc_Initialize(
   Heap_Initialization_or_extend_handler extend
 );
 
-/*
- *  Malloc Statistics Structure
- */
-typedef struct {
-    uint32_t    space_available;             /* current size of malloc area */
-    uint32_t    malloc_calls;                /* # calls to malloc */
-    uint32_t    memalign_calls;              /* # calls to memalign */
-    uint32_t    free_calls;
-    uint32_t    realloc_calls;
-    uint32_t    calloc_calls;
-    uint32_t    max_depth;		     /* most ever malloc'd at 1 time */
-    uintmax_t   lifetime_allocated;
-    uintmax_t   lifetime_freed;
-} rtems_malloc_statistics_t;
-
-/*
- *  Malloc statistics plugin
- */
-typedef struct {
-  void (*initialize)(void);
-  void (*at_malloc)(void *);
-  void (*at_free)(void *);
-} rtems_malloc_statistics_functions_t;
-
-extern rtems_malloc_statistics_functions_t
-  rtems_malloc_statistics_helpers_table;
-extern rtems_malloc_statistics_functions_t *rtems_malloc_statistics_helpers;
-
 extern ptrdiff_t RTEMS_Malloc_Sbrk_amount;
 
 static inline void rtems_heap_set_sbrk_amount( ptrdiff_t sbrk_amount )
@@ -122,41 +94,6 @@ void rtems_malloc_dirty_memory(
 );
 
 /**
- *  @brief Print Malloc Statistic Usage Report
- *
- *  This method fills in the called provided malloc statistics area.
- *
- *  @return This method returns 0 if successful and -1 on error.
- */
-int malloc_get_statistics(
-  rtems_malloc_statistics_t *stats
-);
-
-/**
- *  @brief Print Malloc Statistic Usage Report
- *
- *  This method prints a malloc statistics report.
- *
- *  @note It uses printk to print the report.
- */
-void malloc_report_statistics(void);
-
-/**
- *  @brief Print Malloc Statistic Usage Report
- *
- *  This method prints a malloc statistics report.
- *
- *  @param[in] context is the context to pass to the print handler
- *  @param[in] print is the print handler
- *
- *  @note It uses the CALLER's routine to print the report.
- */
-void malloc_report_statistics_with_plugin(
-  void                  *context,
-  rtems_printk_plugin_t  print
-);
-
-/**
  *  @brief RTEMS Variation on Aligned Memory Allocation
  *
  *  This method is a help memalign implementation which does all
diff --git a/cpukit/libcsupport/src/calloc.c b/cpukit/libcsupport/src/calloc.c
index 095b467..915ece3 100644
--- a/cpukit/libcsupport/src/calloc.c
+++ b/cpukit/libcsupport/src/calloc.c
@@ -19,7 +19,6 @@
 #endif
 
 #if defined(RTEMS_NEWLIB) && !defined(HAVE_CALLOC)
-#include "malloc_p.h"
 #include <stdlib.h>
 #include <string.h>
 
@@ -31,15 +30,11 @@ void *calloc(
   char   *cptr;
   size_t  length;
 
-  MSBUMP(calloc_calls, 1);
-
   length = nelem * elsize;
   cptr = malloc( length );
   if ( cptr )
     memset( cptr, '\0', length );
 
-  MSBUMP(malloc_calls, (uint32_t) -1);   /* subtract off the malloc */
-
   return cptr;
 }
 #endif
diff --git a/cpukit/libcsupport/src/free.c b/cpukit/libcsupport/src/free.c
index 2a7e3d9..63eb7b8 100644
--- a/cpukit/libcsupport/src/free.c
+++ b/cpukit/libcsupport/src/free.c
@@ -24,12 +24,12 @@
 
 #include <rtems/score/sysstate.h>
 
+#include "malloc_p.h"
+
 void free(
   void *ptr
 )
 {
-  MSBUMP(free_calls, 1);
-
   if ( !ptr )
     return;
 
@@ -41,12 +41,6 @@ void free(
       return;
   }
 
-  /*
-   *  If configured, update the statistics
-   */
-  if ( rtems_malloc_statistics_helpers )
-    (*rtems_malloc_statistics_helpers->at_free)(ptr);
-
   if ( !_Protected_heap_Free( RTEMS_Malloc_Heap, ptr ) ) {
     printk( "Program heap: free of bad pointer %p -- range %p - %p \n",
       ptr,
diff --git a/cpukit/libcsupport/src/malloc.c b/cpukit/libcsupport/src/malloc.c
index 4645fdb..73203e5 100644
--- a/cpukit/libcsupport/src/malloc.c
+++ b/cpukit/libcsupport/src/malloc.c
@@ -30,8 +30,6 @@ void *malloc(
 {
   void        *return_this;
 
-  MSBUMP(malloc_calls, 1);
-
   /*
    *  If some free's have been deferred, then do them now.
    */
@@ -71,12 +69,6 @@ void *malloc(
   if ( rtems_malloc_dirty_helper )
     (*rtems_malloc_dirty_helper)( return_this, size );
 
-  /*
-   *  If configured, update the statistics
-   */
-  if ( rtems_malloc_statistics_helpers )
-    (*rtems_malloc_statistics_helpers->at_malloc)(return_this);
-
   return return_this;
 }
 
diff --git a/cpukit/libcsupport/src/malloc_get_statistics.c b/cpukit/libcsupport/src/malloc_get_statistics.c
deleted file mode 100644
index a54a4c1..0000000
--- a/cpukit/libcsupport/src/malloc_get_statistics.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- *  @file
- *
- *  @brief Print Malloc Statistic Usage Report
- *  @ingroup MallocSupport
- */
-
-/*
- *  COPYRIGHT (c) 1989-2007.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef RTEMS_NEWLIB
-#include "malloc_p.h"
-
-int malloc_get_statistics(
-  rtems_malloc_statistics_t *stats
-)
-{
-  if ( !stats )
-    return -1;
-  _RTEMS_Lock_allocator();
-  *stats = rtems_malloc_statistics;
-  _RTEMS_Unlock_allocator();
-  return 0;
-}
-
-#endif
diff --git a/cpukit/libcsupport/src/malloc_initialize.c b/cpukit/libcsupport/src/malloc_initialize.c
index 75dc574..60fe2d9 100644
--- a/cpukit/libcsupport/src/malloc_initialize.c
+++ b/cpukit/libcsupport/src/malloc_initialize.c
@@ -22,8 +22,6 @@
 #include "malloc_p.h"
 
 #ifdef RTEMS_NEWLIB
-rtems_malloc_statistics_t rtems_malloc_statistics;
-
 void RTEMS_Malloc_Initialize(
   const Heap_Area *areas,
   size_t area_count,
@@ -59,15 +57,6 @@ void RTEMS_Malloc_Initialize(
       );
     }
   }
-
-  /*
-   *  If configured, initialize the statistics support
-   */
-  if ( rtems_malloc_statistics_helpers != NULL ) {
-    (*rtems_malloc_statistics_helpers->initialize)();
-  }
-
-  MSBUMP( space_available, _Protected_heap_Get_size( heap ) );
 }
 #else
 void RTEMS_Malloc_Initialize(
diff --git a/cpukit/libcsupport/src/malloc_p.h b/cpukit/libcsupport/src/malloc_p.h
index 4295aeb..89adc5f 100644
--- a/cpukit/libcsupport/src/malloc_p.h
+++ b/cpukit/libcsupport/src/malloc_p.h
@@ -22,13 +22,6 @@
 #include <rtems/chain.h>
 
 /*
- *  Malloc Statistics Structure
- */
-extern rtems_malloc_statistics_t rtems_malloc_statistics;
-
-#define MSBUMP(_f,_n)    rtems_malloc_statistics._f += (_n)
-
-/*
  *  Process deferred free operations
  */
 bool malloc_is_system_state_OK(void);
diff --git a/cpukit/libcsupport/src/malloc_report_statistics.c b/cpukit/libcsupport/src/malloc_report_statistics.c
deleted file mode 100644
index d726b72..0000000
--- a/cpukit/libcsupport/src/malloc_report_statistics.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- *  @file
- *
- *  @brief Print Malloc Statistic Usage Report
- *  @ingroup MallocSupport
- */
-
-/*
- *  COPYRIGHT (c) 1989-2007.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef RTEMS_NEWLIB
-#include "malloc_p.h"
-
-void malloc_report_statistics(void)
-{
-  malloc_report_statistics_with_plugin( NULL, printk_plugin );
-}
-
-#endif
diff --git a/cpukit/libcsupport/src/malloc_report_statistics_plugin.c b/cpukit/libcsupport/src/malloc_report_statistics_plugin.c
deleted file mode 100644
index 1113944..0000000
--- a/cpukit/libcsupport/src/malloc_report_statistics_plugin.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- *  malloc_report_statistics with plugin Implementation
- *
- *  COPYRIGHT (c) 1989-2007.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef RTEMS_NEWLIB
-#include "malloc_p.h"
-#include "inttypes.h"
-
-void malloc_report_statistics_with_plugin(
-  void                  *context,
-  rtems_printk_plugin_t  print
-)
-{
-  rtems_malloc_statistics_t *s = &rtems_malloc_statistics;
-  uint32_t space_available = s->space_available;
-  uint32_t allocated = (uint32_t) (s->lifetime_allocated - s->lifetime_freed);
-  uint32_t max_depth = s->max_depth;
-    /* avoid float! */
-  uint32_t allocated_per_cent = (allocated * 100) / space_available;
-  uint32_t max_depth_per_cent = (max_depth * 100) / space_available;
-
-  (*print)(
-    context,
-    "Malloc statistics\n"
-    "  avail:%"PRIu32"k  allocated:%"PRIu32"k (%"PRIu32"%%) "
-      "max:%"PRIu32"k (%"PRIu32"%%)"
-      " lifetime:%"PRIuMAX"k freed:%"PRIuMAX"k\n",
-    space_available / 1024,
-    allocated / 1024,
-    allocated_per_cent,
-    max_depth / 1024,
-    max_depth_per_cent,
-    s->lifetime_allocated / 1024,
-    s->lifetime_freed / 1024
-  );
-  (*print)(
-    context,
-    "  Call counts:   malloc:%"PRIu32"   memalign:%"PRIu32"   free:%"PRIu32
-       "   realloc:%"PRIu32"   calloc:%"PRIu32"\n",
-    s->malloc_calls,
-    s->memalign_calls,
-    s->free_calls,
-    s->realloc_calls,
-    s->calloc_calls
-  );
-}
-
-#endif
diff --git a/cpukit/libcsupport/src/malloc_statistics_helpers.c b/cpukit/libcsupport/src/malloc_statistics_helpers.c
deleted file mode 100644
index 1ac128f..0000000
--- a/cpukit/libcsupport/src/malloc_statistics_helpers.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- *  @file
- *
- *  @brief Malloc Statistics Support
- *  @ingroup MallocSupport
- */
-
-/*
- *  COPYRIGHT (c) 1989-2007.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef RTEMS_NEWLIB
-#include "malloc_p.h"
-
-#include <sys/reent.h>
-#include <stdlib.h>
-#include <string.h>
-
-static void rtems_malloc_statistics_initialize( void )
-{
-  /*
-   * Zero all the statistics
-   */
-  (void) memset(&rtems_malloc_statistics, 0, sizeof(rtems_malloc_statistics));
-}
-
-static void rtems_malloc_statistics_at_malloc(
-  void *pointer
-)
-{
-  uintptr_t actual_size = 0;
-  uint32_t current_depth;
-  rtems_malloc_statistics_t *s = &rtems_malloc_statistics;
-
-  if ( !pointer )
-    return;
-
-  _Protected_heap_Get_block_size(RTEMS_Malloc_Heap, pointer, &actual_size);
-
-  MSBUMP(lifetime_allocated, actual_size);
-
-  current_depth = (uint32_t) (s->lifetime_allocated - s->lifetime_freed);
-  if (current_depth > s->max_depth)
-      s->max_depth = current_depth;
-}
-
-/**
- *  If the pointer is not in the heap, then we won't be able to get its
- *  size and thus we skip updating the statistics.
- */
-static void rtems_malloc_statistics_at_free(
-  void *pointer
-)
-{
-  uintptr_t size;
-
-  if (_Protected_heap_Get_block_size(RTEMS_Malloc_Heap, pointer, &size) ) {
-    MSBUMP(lifetime_freed, size);
-  }
-}
-
-rtems_malloc_statistics_functions_t rtems_malloc_statistics_helpers_table = {
-  rtems_malloc_statistics_initialize,
-  rtems_malloc_statistics_at_malloc,
-  rtems_malloc_statistics_at_free,
-};
-
-#endif
diff --git a/cpukit/libcsupport/src/posix_memalign.c b/cpukit/libcsupport/src/posix_memalign.c
index 97e3080..80865cd 100644
--- a/cpukit/libcsupport/src/posix_memalign.c
+++ b/cpukit/libcsupport/src/posix_memalign.c
@@ -1,7 +1,6 @@
 /**
  * @file
  *
- * @brief Update call statistics
  * @ingroup libcsupport
  */
 
@@ -30,11 +29,6 @@ int posix_memalign(
   size_t   size
 )
 {
-  /*
-   *  Update call statistics
-   */
-  MSBUMP(memalign_calls, 1);
-
   if (((alignment - 1) & alignment) != 0 || (alignment < sizeof(void *)))
     return EINVAL;
 
diff --git a/cpukit/libcsupport/src/realloc.c b/cpukit/libcsupport/src/realloc.c
index 2ca239d..6efdfdf 100644
--- a/cpukit/libcsupport/src/realloc.c
+++ b/cpukit/libcsupport/src/realloc.c
@@ -35,8 +35,6 @@ void *realloc(
   uintptr_t old_size;
   char    *new_area;
 
-  MSBUMP(realloc_calls, 1);
-
   /*
    *  Do not attempt to allocate memory if in a critical section or ISR.
    */
@@ -77,8 +75,6 @@ void *realloc(
 
   new_area = malloc( size );
 
-  MSBUMP(malloc_calls, (uint32_t) -1);   /* subtract off the malloc */
-
   if ( !new_area ) {
     return (void *) 0;
   }
diff --git a/cpukit/libcsupport/src/rtems_heap_extend_via_sbrk.c b/cpukit/libcsupport/src/rtems_heap_extend_via_sbrk.c
index e895dc5..61bc1cf 100644
--- a/cpukit/libcsupport/src/rtems_heap_extend_via_sbrk.c
+++ b/cpukit/libcsupport/src/rtems_heap_extend_via_sbrk.c
@@ -52,8 +52,6 @@ void *rtems_heap_extend_via_sbrk(
       bool ok = _Protected_heap_Extend( heap, area_begin, sbrk_size );
 
       if ( ok ) {
-        MSBUMP( space_available, sbrk_size );
-
         return_this = _Protected_heap_Allocate( heap, alloc_size );
       } else {
         sbrk( -sbrk_size );
diff --git a/cpukit/libcsupport/src/rtems_memalign.c b/cpukit/libcsupport/src/rtems_memalign.c
index 1b9c6bc..5755fa0 100644
--- a/cpukit/libcsupport/src/rtems_memalign.c
+++ b/cpukit/libcsupport/src/rtems_memalign.c
@@ -62,12 +62,6 @@ int rtems_memalign(
   if ( !return_this )
     return ENOMEM;
 
-  /*
-   *  If configured, update the more involved statistics
-   */
-  if ( rtems_malloc_statistics_helpers )
-    (*rtems_malloc_statistics_helpers->at_malloc)(pointer);
-
   *pointer = return_this;
   return 0;
 }
diff --git a/cpukit/libmisc/shell/main_mallocinfo.c b/cpukit/libmisc/shell/main_mallocinfo.c
index b708296..54c602a 100644
--- a/cpukit/libmisc/shell/main_mallocinfo.c
+++ b/cpukit/libmisc/shell/main_mallocinfo.c
@@ -19,7 +19,7 @@
 #include <rtems.h>
 #include <rtems/malloc.h>
 #include <rtems/libcsupport.h>
-#include <rtems/shell.h>
+#include <rtems/shellconfig.h>
 
 #include "internal.h"
 
@@ -28,31 +28,23 @@ static int rtems_shell_main_malloc_info(
   char *argv[]
 )
 {
-  if ( argc == 2 ) {
-    rtems_shell_print_unified_work_area_message();
+  if ( argc == 2 && strcmp( argv[ 1 ], "walk" ) == 0 ) {
+    malloc_walk( 0, true );
+  } else {
+    region_information_block info;
 
-    if ( !strcmp( argv[1], "info" ) ) {
-      region_information_block info;
-
-      malloc_info( &info );
-      rtems_shell_print_heap_info( "free", &info.Free );
-      rtems_shell_print_heap_info( "used", &info.Used );
-      return 0;
-    } else if ( !strcmp( argv[1], "stats" ) ) {
-      malloc_report_statistics_with_plugin(
-        stdout,
-        (rtems_printk_plugin_t) fprintf
-      );
-      return 0;
-    }
+    rtems_shell_print_unified_work_area_message();
+    malloc_info( &info );
+    rtems_shell_print_heap_info( "free", &info.Free );
+    rtems_shell_print_heap_info( "used", &info.Used );
   }
-  fprintf( stderr, "%s: [info|stats]\n", argv[0] );
-  return -1;
+
+  return 0;
 }
 
 rtems_shell_cmd_t rtems_shell_MALLOC_INFO_Command = {
   "malloc",                                   /* name */
-  "[info|stats]",                             /* usage */
+  "malloc [walk]",                            /* usage */
   "mem",                                      /* topic */
   rtems_shell_main_malloc_info,               /* command */
   NULL,                                       /* alias */
diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h
index a30c008..76cba05 100644
--- a/cpukit/sapi/include/confdefs.h
+++ b/cpukit/sapi/include/confdefs.h
@@ -1115,19 +1115,6 @@ const rtems_libio_helper rtems_fs_init_helper =
 
 #ifdef CONFIGURE_INIT
   /**
-   * This configures the malloc family statistics to be available.
-   * By default only function call counts are kept.
-   */
-  rtems_malloc_statistics_functions_t *rtems_malloc_statistics_helpers =
-    #ifndef CONFIGURE_MALLOC_STATISTICS
-      NULL;
-    #else
-      &rtems_malloc_statistics_helpers_table;
-    #endif
-#endif
-
-#ifdef CONFIGURE_INIT
-  /**
    * This configures the sbrk() support for the malloc family.
    * By default it is assumed that the BSP provides all available
    * RAM to the malloc family implementation so sbrk()'ing to get
diff --git a/doc/shell/memory.t b/doc/shell/memory.t
index 3227e73..0fdf1f8 100644
--- a/doc/shell/memory.t
+++ b/doc/shell/memory.t
@@ -530,18 +530,14 @@ extern rtems_shell_cmd_t rtems_shell_MMOVE_Command;
 @subheading SYNOPSYS:
 
 @example
-malloc [info|stats]
+malloc [walk]
 @end example
 
 @subheading DESCRIPTION:
 
-This command prints either information or statistics about the
-C Program Heap used by the @code{malloc} family of calls based upon
-the value of the first argument passed to the command.
-
-When the subcommand @code{info} is specified, information on the
-current state of the C Program Heap is reported.  This includes the following
-information:
+This command prints information about the current state of the C Program Heap
+used by the @code{malloc()} family of calls if no or invalid options are passed
+to the command.  This includes the following information:
 
 @itemize @bullet
 @item Number of free blocks
@@ -552,23 +548,8 @@ information:
 @item Total bytes used
 @end itemize
 
-When the subcommand @code{stats} is specified, statistics on the
-the C Program Heap are reported.  Malloc Family Statistics must
-be enabled for all of the values to be updated.  The statistics
-available includes the following information:
-
- at itemize @bullet
- at item
- at item Currently available memory (in kilobytes)
- at item Currently allocated memory (in kilobytes)
- at item Maximum amount of memory ever allocated (in kilobytes)
- at item Lifetime tally of allocated memory  (in kilobytes)
- at item Lifetime tally of freed memory (in kilobytes)
- at item Number of calls to @code{malloc}
- at item Number of calls to @code{free}
- at item Number of calls to @code{realloc}
- at item Number of calls to @code{calloc}
- at end itemize
+When the subcommand @code{walk} is specified, then a heap walk will be
+performed and information about each block is printed out.
 
 @subheading EXIT STATUS:
 
@@ -576,47 +557,41 @@ This command returns 0 on success and non-zero if an error is encountered.
 
 @subheading NOTES:
 
- at findex CONFIGURE_MALLOC_STATISTICS
-
-The @code{CONFIGURE_MALLOC_STATISTICS} @code{confdefs.h} constant
-must be defined when the application is configured for the full
-set of statistics information to be available.
+NONE
 
 @subheading EXAMPLES:
 
 The following is an example of how to use the @code{malloc} command.
 
 @example
-SHLL [/] $ malloc info
+SHLL [/] $ malloc
 Number of free blocks: 3
 Largest free block:    3626672
 Total bytes free:      3627768
 Number of used blocks: 130
 Largest used block:    1048
 Total bytes used:      10136
-SHLL [/] $ malloc stats
-Malloc statistics
-  avail:3552k  allocated:9k (0%) max:10k (0%) lifetime:21k freed:12k
-  Call counts:   malloc:203   free:93   realloc:0   calloc:20
-SHLL [/] $ malloc info
-Number of free blocks: 3
-Largest free block:    3626672
-Total bytes free:      3627768
-Number of used blocks: 130
-Largest used block:    1048
-Total bytes used:      10136
-SHLL [/] $ malloc stats
-Malloc statistics
-  avail:3552k  allocated:9k (0%) max:10k (0%) lifetime:23k freed:14k
-  Call counts:   malloc:205   free:95   realloc:0   calloc:20
+SHLL [/] $ malloc walk
+malloc walk
+PASS[0]: page size 8, min block size 48
+        area begin 0x00210210, area end 0x0FFFC000
+        first block 0x00210214, last block 0x0FFFBFDC
+        first free 0x00228084, last free 0x00228354
+PASS[0]: block 0x00210214: size 88
+...
+PASS[0]: block 0x00220154: size 144
+PASS[0]: block 0x002201E4: size 168, prev 0x002205BC, next 0x00228354 (= last free)
+PASS[0]: block 0x0022028C: size 168, prev_size 168
+...
+PASS[0]: block 0x00226E7C: size 4136
+PASS[0]: block 0x00227EA4: size 408, prev 0x00228084 (= first free), next 0x00226CE4
+PASS[0]: block 0x0022803C: size 72, prev_size 408
+PASS[0]: block 0x00228084: size 648, prev 0x0020F75C (= head), next 0x00227EA4
+PASS[0]: block 0x0022830C: size 72, prev_size 648
+PASS[0]: block 0x00228354: size 266157192, prev 0x002201E4, next 0x0020F75C (= tail)
+PASS[0]: block 0x0FFFBFDC: size 4028711480, prev_size 266157192
 @end example
 
-Note that in the above example, the lifetime allocated and free
-values have increased between the two calls to @code{malloc stats}
-even though the amount of memory available in the C Program Heap
-is the same in both the @code{malloc info} invocations. This indicates
-that memory was allocated and freed as a side-effect of the commands.
-
 @subheading CONFIGURATION:
 
 @findex CONFIGURE_SHELL_NO_COMMAND_MALLOC
diff --git a/doc/user/conf.t b/doc/user/conf.t
index d72ff06..68b5ede 100644
--- a/doc/user/conf.t
+++ b/doc/user/conf.t
@@ -2434,37 +2434,6 @@ related configuration parameters supported by
 @code{<rtems/confdefs.h>}.
 
 @c
- at c === CONFIGURE_MALLOC_STATISTICS ===
- at c
- at subsection Enable Malloc Family Statistics
-
- at findex CONFIGURE_MALLOC_STATISTICS
-
-
- at table @b
- at item CONSTANT:
- at code{CONFIGURE_MALLOC_STATISTICS}
-
- at item DATA TYPE:
-Boolean feature macro.
-
- at item RANGE:
-Defined or undefined.
-
- at item DEFAULT VALUE:
-This is not defined by default, and Malloc Statistics are disabled.
-
- at end table
-
- at subheading DESCRIPTION:
-This configuration parameter is defined when the application wishes to
-enable the gathering of more detailed statistics on the C Malloc Family
-of routines.
-
- at subheading NOTES:
-None.
-
- at c
 @c === CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS ===
 @c
 @subsection Specify Maximum Number of File Descriptors
diff --git a/testsuites/libtests/Makefile.am b/testsuites/libtests/Makefile.am
index a5f39d8..4f22ac8 100644
--- a/testsuites/libtests/Makefile.am
+++ b/testsuites/libtests/Makefile.am
@@ -24,7 +24,7 @@ _SUBDIRS += capture01
 
 _SUBDIRS += bspcmdline01 cpuuse devfs01 devfs02 devfs03 devfs04 \
     deviceio01 devnullfatal01 dumpbuf01 gxx01 top\
-    malloctest malloc02 malloc03 malloc04 malloc05 heapwalk \
+    malloctest malloc02 malloc03 malloc04 heapwalk \
     putenvtest monitor monitor02 rtmonuse stackchk stackchk01 \
     termios termios01 termios02 termios03 termios04 termios05 \
     termios06 termios07 termios08 \
diff --git a/testsuites/libtests/configure.ac b/testsuites/libtests/configure.ac
index 8efedb2..f8eb272 100644
--- a/testsuites/libtests/configure.ac
+++ b/testsuites/libtests/configure.ac
@@ -117,7 +117,6 @@ malloctest/Makefile
 malloc02/Makefile
 malloc03/Makefile
 malloc04/Makefile
-malloc05/Makefile
 monitor/Makefile
 monitor02/Makefile
 mouse01/Makefile
diff --git a/testsuites/libtests/malloc05/Makefile.am b/testsuites/libtests/malloc05/Makefile.am
deleted file mode 100644
index 816b169..0000000
--- a/testsuites/libtests/malloc05/Makefile.am
+++ /dev/null
@@ -1,21 +0,0 @@
-
-rtems_tests_PROGRAMS = malloc05
-malloc05_SOURCES = init.c
-
-dist_rtems_tests_DATA = malloc05.scn
-dist_rtems_tests_DATA += malloc05.doc
-
-include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP at .cfg
-include $(top_srcdir)/../automake/compile.am
-include $(top_srcdir)/../automake/leaf.am
-
-AM_CPPFLAGS += -I$(top_srcdir)/../support/include
-
-LINK_OBJS = $(malloc05_OBJECTS)
-LINK_LIBS = $(malloc05_LDLIBS)
-
-malloc05$(EXEEXT): $(malloc05_OBJECTS) $(malloc05_DEPENDENCIES)
-	@rm -f malloc05$(EXEEXT)
-	$(make-exe)
-
-include $(top_srcdir)/../automake/local.am
diff --git a/testsuites/libtests/malloc05/init.c b/testsuites/libtests/malloc05/init.c
deleted file mode 100644
index d832573..0000000
--- a/testsuites/libtests/malloc05/init.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *  COPYRIGHT (c) 1989-2012.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <tmacros.h>
-#include "test_support.h"
-#include <rtems/malloc.h>
-
-const char rtems_test_name[] = "MALLOC 5";
-
-/* forward declarations to avoid warnings */
-rtems_task Init(rtems_task_argument argument);
-
-rtems_task Init(
-  rtems_task_argument argument
-)
-{
-  int                        sc;
-  rtems_malloc_statistics_t  stats;
-
-  TEST_BEGIN();
-
-  puts( "malloc_get_statistics( NULL ) - returns -1" );
-  sc = malloc_get_statistics( NULL );
-  rtems_test_assert( sc == -1 );
-
-  puts( "malloc_get_statistics( &stats ) - returns -0" );
-  sc = malloc_get_statistics( &stats );
-  rtems_test_assert( sc == 0 );
-
-  TEST_END();
-
-  rtems_test_exit(0);
-}
-
-/* configuration information */
-
-#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
-#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
-
-#define CONFIGURE_MAXIMUM_TASKS             1
-#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
-
-#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
-
-#define CONFIGURE_INIT
-
-#include <rtems/confdefs.h>
-/* end of file */
diff --git a/testsuites/libtests/malloc05/malloc05.doc b/testsuites/libtests/malloc05/malloc05.doc
deleted file mode 100644
index 7cc3e3c..0000000
--- a/testsuites/libtests/malloc05/malloc05.doc
+++ /dev/null
@@ -1,19 +0,0 @@
-#  COPYRIGHT (c) 1989-2010.
-#  On-Line Applications Research Corporation (OAR).
-#
-#  The license and distribution terms for this file may be
-#  found in the file LICENSE in this distribution or at
-#  http://www.rtems.org/license/LICENSE.
-#
-
-This file describes the directives and concepts tested by this test set.
-
-test set name:  malloc05
-
-directives:
-
-  malloc_get_statistics
-
-concepts:
-
-+ Fully exercise malloc_get_statistics.
diff --git a/testsuites/libtests/malloc05/malloc05.scn b/testsuites/libtests/malloc05/malloc05.scn
deleted file mode 100644
index 0331bf6..0000000
--- a/testsuites/libtests/malloc05/malloc05.scn
+++ /dev/null
@@ -1,4 +0,0 @@
-*** TEST MALLOC05 ***
-malloc_get_statistics( NULL ) - returns -1
-malloc_get_statistics( &stats ) - returns -0
-*** END OF TEST MALLOC05 ***
diff --git a/testsuites/libtests/malloctest/task1.c b/testsuites/libtests/malloctest/task1.c
index b19c320..753a74e 100644
--- a/testsuites/libtests/malloctest/task1.c
+++ b/testsuites/libtests/malloctest/task1.c
@@ -59,7 +59,6 @@ rtems_task Task_1_through_5(
     }
     printf("mallocing %d bytes\n",mem_amt);
     memset( mem_ptr, mem_amt, mem_amt );
-    malloc_report_statistics();
     malloc_walk_ok = malloc_walk( 1, false );
     rtems_test_assert( malloc_walk_ok );
     status = rtems_task_wake_after(




More information about the vc mailing list