Changeset 2c3c657 in rtems


Ignore:
Timestamp:
11/27/14 12:25:22 (9 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, master
Children:
d006b46d
Parents:
01557b0
git-author:
Sebastian Huber <sebastian.huber@…> (11/27/14 12:25:22)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/28/14 12:09:07)
Message:

score: Return heap stats via _Heap_Get_information

Print out heap statistics via the MALLOC and WKSPACE shell commands.

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/src/resource_snapshot.c

    r01557b0 r2c3c657  
    9999}
    100100
     101static void get_heap_info(Heap_Control *heap, Heap_Information_block *info)
     102{
     103  _Heap_Get_information(heap, info);
     104  memset(&info->Stats, 0, sizeof(info->Stats));
     105}
     106
    101107void rtems_resource_snapshot_take(rtems_resource_snapshot *snapshot)
    102108{
     
    108114  _Thread_Kill_zombies();
    109115
    110   #ifdef HEAP_PROTECTION
    111     _Heap_Protection_free_all_delayed_blocks(RTEMS_Malloc_Heap);
    112     _Heap_Protection_free_all_delayed_blocks(&_Workspace_Area);
    113   #endif
    114 
    115   _Heap_Get_information(RTEMS_Malloc_Heap, &snapshot->heap_info);
    116   _Heap_Get_information(&_Workspace_Area, &snapshot->workspace_info);
     116  get_heap_info(RTEMS_Malloc_Heap, &snapshot->heap_info);
     117  get_heap_info(&_Workspace_Area, &snapshot->workspace_info);
    117118
    118119  for (i = 0; i < RTEMS_ARRAY_SIZE(objects_info_table); ++i) {
  • cpukit/libmisc/shell/internal.h

    r01557b0 r2c3c657  
    3333
    3434extern void rtems_shell_print_heap_info(
    35   const char       *c,
    36   Heap_Information *h
     35  const char             *c,
     36  const Heap_Information *h
    3737);
    3838
     39extern void rtems_shell_print_heap_stats(
     40  const Heap_Statistics *s
     41);
    3942
    4043extern void rtems_shell_print_unified_work_area_message(void);
  • cpukit/libmisc/shell/main_mallocinfo.c

    r01557b0 r2c3c657  
    3838    rtems_shell_print_heap_info( "free", &info.Free );
    3939    rtems_shell_print_heap_info( "used", &info.Used );
     40    rtems_shell_print_heap_stats( &info.Stats );
    4041  }
    4142
  • cpukit/libmisc/shell/main_wkspaceinfo.c

    r01557b0 r2c3c657  
    2525void rtems_shell_print_unified_work_area_message(void)
    2626{
    27   printf( "\nC Program Heap and RTEMS Workspace are %s.\n",
     27  printf( "C Program Heap and RTEMS Workspace are %s.\n",
    2828    rtems_configuration_get_unified_work_area() ? "the same" : "separate"
    2929  );
     
    4242  rtems_shell_print_heap_info( "free", &info.Free );
    4343  rtems_shell_print_heap_info( "used", &info.Used );
     44  rtems_shell_print_heap_stats( &info.Stats );
    4445
    4546  return 0;
  • cpukit/libmisc/shell/print_heapinfo.c

    r01557b0 r2c3c657  
    1515
    1616#include <inttypes.h>
     17#include <stdio.h>
    1718
    18 #include <rtems.h>
    19 #include <rtems/shell.h>
    2019#include "internal.h"
    2120
    2221void rtems_shell_print_heap_info(
    23   const char       *c,
    24   Heap_Information *h
     22  const char             *c,
     23  const Heap_Information *h
    2524)
    2625{
    2726  printf(
    28     "Number of %s blocks: %" PRId32 "\n"
    29     "Largest %s block:    %" PRId32 "\n"
    30     "Total bytes %s:      %" PRId32 "\n",
     27    "Number of %s blocks:                    %12" PRId32 "\n"
     28    "Largest %s block:                       %12" PRId32 "\n"
     29    "Total bytes %s:                         %12" PRId32 "\n",
    3130    c, h->number,
    3231    c, h->largest,
     
    3433  );
    3534}
     35
     36void rtems_shell_print_heap_stats(
     37  const Heap_Statistics *s
     38)
     39{
     40  printf(
     41    "Instance number:                          %12" PRIu32 "\n"
     42    "Size of the allocatable area in bytes:    %12" PRIuPTR "\n"
     43    "Minimum free size ever in bytes:          %12" PRIuPTR "\n"
     44    "Maximum number of free blocks ever:       %12" PRIu32 "\n"
     45    "Maximum number of blocks searched ever:   %12" PRIu32 "\n"
     46    "Total number of successful allocations:   %12" PRIu32 "\n"
     47    "Total number of searches ever:            %12" PRIu32 "\n"
     48    "Total number of successful calls to free: %12" PRIu32 "\n"
     49    "Total number of successful resizes:       %12" PRIu32 "\n",
     50    s->instance,
     51    s->size,
     52    s->min_free_size,
     53    s->max_free_blocks,
     54    s->max_search,
     55    s->allocs,
     56    s->searches,
     57    s->frees,
     58    s->resizes
     59  );
     60}
  • cpukit/score/include/rtems/score/heap.h

    r01557b0 r2c3c657  
    314314
    315315  /**
    316    * @brief Total number of suceessful calls to free.
     316   * @brief Total number of successful calls to free.
    317317   */
    318318  uint32_t frees;
     
    367367  Heap_Information Free;
    368368  Heap_Information Used;
     369  Heap_Statistics Stats;
    369370} Heap_Information_block;
    370371
  • cpukit/score/src/heapgetinfo.c

    r01557b0 r2c3c657  
    5151  _Heap_Protection_free_all_delayed_blocks( the_heap );
    5252  _Heap_Iterate( the_heap, _Heap_Get_information_visitor, the_info );
     53  the_info->Stats = the_heap->stats;
    5354}
  • doc/shell/memory.t

    r01557b0 r2c3c657  
    547547@item Largest used block
    548548@item Total bytes used
     549@item Instance number
     550@item Size of the allocatable area in bytes
     551@item Minimum free size ever in bytes
     552@item Maximum number of free blocks ever
     553@item Maximum number of blocks searched ever
     554@item Total number of successful allocations
     555@item Total number of searches ever
     556@item Total number of successful calls to free
     557@item Total number of successful resizes
    549558@end itemize
    550559
     
    566575@example
    567576SHLL [/] $ malloc
    568 Number of free blocks: 3
    569 Largest free block:    3626672
    570 Total bytes free:      3627768
    571 Number of used blocks: 130
    572 Largest used block:    1048
    573 Total bytes used:      10136
     577C Program Heap and RTEMS Workspace are the same.
     578Number of free blocks:                              14
     579Largest free block:                          266157192
     580Total bytes free:                            266164928
     581Number of used blocks:                             167
     582Largest used block:                              16424
     583Total bytes used:                                90888
     584Instance number:                                     0
     585Size of the allocatable area in bytes:       266255816
     586Minimum free size ever in bytes:             266156136
     587Maximum number of free blocks ever:                 15
     588Maximum number of blocks searched ever:             15
     589Total number of successful allocations:            186
     590Total number of searches ever:                     186
     591Total number of successful calls to free:           19
     592Total number of successful resizes:                  0
    574593SHLL [/] $ malloc walk
    575594malloc walk
Note: See TracChangeset for help on using the changeset viewer.