Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:19

0001 /*
0002  *  MALLOC_INFO Shell Command Implmentation
0003  *
0004  *  COPYRIGHT (c) 1989-2008.
0005  *  On-Line Applications Research Corporation (OAR).
0006  *
0007  *  The license and distribution terms for this file may be
0008  *  found in the file LICENSE in this distribution or at
0009  *  http://www.rtems.org/license/LICENSE.
0010  */
0011 
0012 #ifdef HAVE_CONFIG_H
0013 #include "config.h"
0014 #endif
0015 
0016 #include <inttypes.h>
0017 #include <string.h>
0018 
0019 #include <rtems.h>
0020 #include <rtems/malloc.h>
0021 #include <rtems/libcsupport.h>
0022 #include <rtems/shellconfig.h>
0023 
0024 #include "internal.h"
0025 
0026 static int rtems_shell_main_malloc_info(
0027   int   argc,
0028   char *argv[]
0029 )
0030 {
0031   if ( argc == 2 && strcmp( argv[ 1 ], "walk" ) == 0 ) {
0032     malloc_walk( 0, true );
0033   } else {
0034     Heap_Information_block info;
0035 
0036     rtems_shell_print_unified_work_area_message();
0037     malloc_info( &info );
0038     rtems_shell_print_heap_info( "free", &info.Free );
0039     rtems_shell_print_heap_info( "used", &info.Used );
0040     rtems_shell_print_heap_stats( &info.Stats );
0041   }
0042 
0043   return 0;
0044 }
0045 
0046 rtems_shell_cmd_t rtems_shell_MALLOC_INFO_Command = {
0047   "malloc",                                   /* name */
0048   "malloc [walk]",                            /* usage */
0049   "mem",                                      /* topic */
0050   rtems_shell_main_malloc_info,               /* command */
0051   NULL,                                       /* alias */
0052   NULL                                        /* next */
0053 };
0054