source: rtems/cpukit/libmisc/shell/main_mallocinfo.c @ 543fe820

4.104.114.95
Last change on this file since 543fe820 was 543fe820, checked in by Joel Sherrill <joel.sherrill@…>, on 12/18/07 at 20:36:40

2007-12-18 Joel Sherrill <joel.sherrill@…>

  • libcsupport/Makefile.am, libcsupport/preinstall.am, libcsupport/src/malloc.c, libcsupport/src/mallocinfo.c, libmisc/Makefile.am, libmisc/shell/main_mallocinfo.c, libmisc/shell/shellconfig.h: Split malloc.c into multiple files with one function per file. Also split out statistics into a separate file which can be plugged in dynamically. Right now, it is always in. I suspect that splitting the file removed more code than leaving statistics in. I tinkered with malloc information command in the shell. I resurrected the malloc arena code as malloc boundary. This code is now compiled all the time even though it does not appear to work.
  • libcsupport/include/rtems/malloc.h, libcsupport/src/_calloc_r.c, libcsupport/src/_free_r.c, libcsupport/src/_malloc_r.c, libcsupport/src/_realloc_r.c, libcsupport/src/calloc.c, libcsupport/src/free.c, libcsupport/src/malloc_boundary.c, libcsupport/src/malloc_get_statistics.c, libcsupport/src/malloc_initialize.c, libcsupport/src/malloc_p.h, libcsupport/src/malloc_report_statistics.c, libcsupport/src/malloc_report_statistics_plugin.c, libcsupport/src/malloc_statistics_helpers.c, libcsupport/src/malloc_walk.c, libcsupport/src/realloc.c, libmisc/shell/main_perioduse.c: New files.
  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 *  MALLOC_INFO Shell Command Implmentation
3 *
4 *  COPYRIGHT (c) 1989-2007.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#ifdef HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <inttypes.h>
19
20#include <rtems.h>
21#include <rtems/malloc.h>
22#include <rtems/shell.h>
23#include "internal.h"
24
25extern int malloc_info( region_information_block * );
26
27static void printit(
28  const char       *c,
29  Heap_Information *h
30)
31{
32  printf(
33    "Number of %s blocks: %" PRId32 "\n"
34    "Largest %s block:    %" PRId32 "\n"
35    "Total bytes %s:      %" PRId32 "\n",
36    c, h->number,
37    c, h->largest,
38    c, h->total
39  );
40}
41
42int rtems_shell_main_malloc_info(
43  int   argc,
44  char *argv[]
45)
46{
47  if ( argc == 2 ) {
48    if ( !strcmp( argv[1], "info" ) ) {
49      region_information_block info;
50
51      malloc_info( &info );
52      printit( "free", &info.Free );
53      printit( "used", &info.Used );
54      return 0;
55    } else if ( !strcmp( argv[1], "stats" ) ) {
56      malloc_report_statistics_with_plugin(
57        stdout,
58        (rtems_printk_plugin_t) fprintf
59      );
60      return 0;
61    }
62  }
63  fprintf( stderr, "subcommands info or stats\n" );
64  return -1;
65}
66
67rtems_shell_cmd_t rtems_shell_MALLOC_INFO_Command = {
68  "malloc",                                   /* name */
69  "[info|stats]",                             /* usage */
70  "mem",                                      /* topic */
71  rtems_shell_main_malloc_info,               /* command */
72  NULL,                                       /* alias */
73  NULL                                        /* next */
74};
75
Note: See TracBrowser for help on using the repository browser.