source: rtems/cpukit/score/src/heapwalk.c @ dd687d97

4.104.114.84.95
Last change on this file since dd687d97 was dd687d97, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:56:05

2003-09-04 Joel Sherrill <joel@…>

  • include/rtems/debug.h, include/rtems/seterr.h, include/rtems/system.h, include/rtems/score/address.h, include/rtems/score/apiext.h, include/rtems/score/apimutex.h, include/rtems/score/bitfield.h, include/rtems/score/chain.h, include/rtems/score/context.h, include/rtems/score/copyrt.h, include/rtems/score/coremsg.h, include/rtems/score/coremutex.h, include/rtems/score/coresem.h, include/rtems/score/heap.h, include/rtems/score/interr.h, include/rtems/score/isr.h, include/rtems/score/mpci.h, include/rtems/score/mppkt.h, include/rtems/score/object.h, include/rtems/score/objectmp.h, include/rtems/score/priority.h, include/rtems/score/stack.h, include/rtems/score/states.h, include/rtems/score/sysstate.h, include/rtems/score/thread.h, include/rtems/score/threadmp.h, include/rtems/score/threadq.h, include/rtems/score/tod.h, include/rtems/score/tqdata.h, include/rtems/score/userext.h, include/rtems/score/watchdog.h, include/rtems/score/wkspace.h, inline/rtems/score/address.inl, inline/rtems/score/chain.inl, inline/rtems/score/coremsg.inl, inline/rtems/score/coremutex.inl, inline/rtems/score/coresem.inl, inline/rtems/score/heap.inl, inline/rtems/score/isr.inl, inline/rtems/score/mppkt.inl, inline/rtems/score/object.inl, inline/rtems/score/objectmp.inl, inline/rtems/score/priority.inl, inline/rtems/score/stack.inl, inline/rtems/score/states.inl, inline/rtems/score/sysstate.inl, inline/rtems/score/thread.inl, inline/rtems/score/threadmp.inl, inline/rtems/score/tod.inl, inline/rtems/score/tqdata.inl, inline/rtems/score/userext.inl, inline/rtems/score/watchdog.inl, inline/rtems/score/wkspace.inl, macros/rtems/score/address.inl, macros/rtems/score/chain.inl, macros/rtems/score/coremsg.inl, macros/rtems/score/coremutex.inl, macros/rtems/score/coresem.inl, macros/rtems/score/heap.inl, macros/rtems/score/isr.inl, macros/rtems/score/mppkt.inl, macros/rtems/score/object.inl, macros/rtems/score/objectmp.inl, macros/rtems/score/priority.inl, macros/rtems/score/stack.inl, macros/rtems/score/states.inl, macros/rtems/score/sysstate.inl, macros/rtems/score/thread.inl, macros/rtems/score/threadmp.inl, macros/rtems/score/tod.inl, macros/rtems/score/tqdata.inl, macros/rtems/score/userext.inl, macros/rtems/score/watchdog.inl, macros/rtems/score/wkspace.inl, src/apiext.c, src/chain.c, src/coremsg.c, src/coremsgbroadcast.c, src/coremsgclose.c, src/coremsgflush.c, src/coremsgflushsupp.c, src/coremsgflushwait.c, src/coremsginsert.c, src/coremsgseize.c, src/coremsgsubmit.c, src/coremutex.c, src/coremutexflush.c, src/coremutexseize.c, src/coremutexsurrender.c, src/coresem.c, src/coresemflush.c, src/coresemseize.c, src/coresemsurrender.c, src/coretod.c, src/coretodset.c, src/coretodtickle.c, src/coretodtoseconds.c, src/coretodvalidate.c, src/heap.c, src/heapallocate.c, src/heapextend.c, src/heapfree.c, src/heapgetinfo.c, src/heapsizeofuserarea.c, src/heapwalk.c, src/interr.c, src/isr.c, src/iterateoverthreads.c, src/mpci.c, src/object.c, src/objectallocate.c, src/objectallocatebyindex.c, src/objectclearname.c, src/objectcomparenameraw.c, src/objectcomparenamestring.c, src/objectcopynameraw.c, src/objectcopynamestring.c, src/objectextendinformation.c, src/objectfree.c, src/objectget.c, src/objectgetbyindex.c, src/objectgetisr.c, src/objectgetnext.c, src/objectgetnoprotection.c, src/objectidtoname.c, src/objectinitializeinformation.c, src/objectmp.c, src/objectnametoid.c, src/objectshrinkinformation.c, src/thread.c, src/threadchangepriority.c, src/threadclearstate.c, src/threadclose.c, src/threadcreateidle.c, src/threaddelayended.c, src/threaddispatch.c, src/threadevaluatemode.c, src/threadget.c, src/threadhandler.c, src/threadidlebody.c, src/threadinitialize.c, src/threadloadenv.c, src/threadmp.c, src/threadq.c, src/threadqdequeue.c, src/threadqdequeuefifo.c, src/threadqdequeuepriority.c, src/threadqenqueue.c, src/threadqenqueuefifo.c, src/threadqenqueuepriority.c, src/threadqextract.c, src/threadqextractfifo.c, src/threadqextractpriority.c, src/threadqextractwithproxy.c, src/threadqfirst.c, src/threadqfirstfifo.c, src/threadqfirstpriority.c, src/threadqflush.c, src/threadqtimeout.c, src/threadready.c, src/threadreset.c, src/threadresettimeslice.c, src/threadrestart.c, src/threadresume.c, src/threadrotatequeue.c, src/threadsetpriority.c, src/threadsetstate.c, src/threadsettransient.c, src/threadstackallocate.c, src/threadstackfree.c, src/threadstart.c, src/threadstartmultitasking.c, src/threadsuspend.c, src/threadtickletimeslice.c, src/threadyieldprocessor.c, src/userext.c, src/watchdog.c, src/watchdogadjust.c, src/watchdoginsert.c, src/watchdogremove.c, src/watchdogtickle.c, src/wkspace.c: URL for license changed.
  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 *  Heap Handler
3 *
4 *  COPYRIGHT (c) 1989-1999.
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
15#include <rtems/system.h>
16#include <rtems/score/sysstate.h>
17#include <rtems/score/heap.h>
18
19/*PAGE
20 *
21 *  _Heap_Walk
22 *
23 *  This kernel routine walks the heap and verifies its correctness.
24 *
25 *  Input parameters:
26 *    the_heap  - pointer to heap header
27 *    source    - a numeric indicator of the invoker of this routine
28 *    do_dump   - when TRUE print the information
29 *
30 *  Output parameters: NONE
31 */
32
33#ifndef RTEMS_DEBUG
34
35void _Heap_Walk(
36  Heap_Control  *the_heap,
37  int            source,
38  boolean        do_dump
39)
40{
41}
42
43#else
44
45#include <stdio.h>
46#include <unistd.h>
47
48void _Heap_Walk(
49  Heap_Control  *the_heap,
50  int            source,
51  boolean        do_dump
52)
53{
54  Heap_Block *the_block  = 0;  /* avoid warnings */
55  Heap_Block *next_block = 0;  /* avoid warnings */
56  int         notdone = 1;
57  int         error = 0;
58  int         passes = 0;
59
60  /*
61   * We don't want to allow walking the heap until we have
62   * transferred control to the user task so we watch the
63   * system state.
64   */
65
66  if ( !_System_state_Is_up( _System_state_Get() ) )
67    return;
68
69  the_block = the_heap->start;
70
71  if (do_dump == TRUE) {
72    printf("\nPASS: %d  start @ 0x%p   final 0x%p,   first 0x%p  last 0x%p\n",
73            source, the_heap->start, the_heap->final,
74                  the_heap->first, the_heap->last
75          );
76  }
77
78  /*
79   * Handle the 1st block
80   */
81
82  if (the_block->back_flag != HEAP_DUMMY_FLAG) {
83    printf("PASS: %d  Back flag of 1st block isn't HEAP_DUMMY_FLAG\n", source);
84    error = 1;
85  }
86
87  while (notdone) {
88    passes++;
89    if (error && (passes > 10))
90        abort();
91   
92    if (do_dump == TRUE) {
93      printf("PASS: %d  Block @ 0x%p   Back %d,   Front %d",
94              source, the_block,
95              the_block->back_flag, the_block->front_flag);
96      if ( _Heap_Is_block_free(the_block) ) {
97        printf( "      Prev 0x%p,   Next 0x%p\n",
98                          the_block->previous, the_block->next);
99      } else {
100        printf("\n");
101      }
102    }
103
104    /*
105     * Handle the last block
106     */
107
108    if ( the_block->front_flag != HEAP_DUMMY_FLAG ) {
109      next_block = _Heap_Next_block(the_block);
110      if ( the_block->front_flag != next_block->back_flag ) {
111        error = 1;
112        printf("PASS: %d  Front and back flags don't match\n", source);
113        printf("         Current Block (%p):  Back - %d,  Front - %d",
114               the_block, the_block->back_flag, the_block->front_flag);
115        if (do_dump == TRUE) {
116          if (_Heap_Is_block_free(the_block)) {
117            printf("      Prev 0x%p,   Next 0x%p\n",
118                   the_block->previous, the_block->next);
119          } else {
120            printf("\n");
121          }
122        } else {
123          printf("\n");
124        }
125        printf("         Next Block (%p):     Back - %d,  Front - %d",
126               next_block, next_block->back_flag, next_block->front_flag);
127        if (do_dump == TRUE) {
128          if (_Heap_Is_block_free(next_block)) {
129            printf("      Prev 0x%p,   Next 0x%p\n",
130                   the_block->previous, the_block->next);
131          } else {
132            printf("\n");
133          }
134        } else {
135          printf("\n");
136        }
137      }
138    }
139
140    if (the_block->front_flag == HEAP_DUMMY_FLAG)
141      notdone = 0;
142    else
143      the_block = next_block;
144  }
145
146  if (error)
147      abort();
148}
149#endif
Note: See TracBrowser for help on using the repository browser.