~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

Viewing changes to storage/innobase/include/mem0dbg.h

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************
 
2
The memory management: the debug code. This is not a compilation module,
 
3
but is included in mem0mem.* !
 
4
 
 
5
(c) 1994, 1995 Innobase Oy
 
6
 
 
7
Created 6/9/1994 Heikki Tuuri
 
8
*******************************************************/
 
9
 
 
10
/* In the debug version each allocated field is surrounded with
 
11
check fields whose sizes are given below */
 
12
 
 
13
#ifdef UNIV_MEM_DEBUG
 
14
#define MEM_FIELD_HEADER_SIZE   ut_calc_align(2 * sizeof(ulint),\
 
15
                                                UNIV_MEM_ALIGNMENT)
 
16
#define MEM_FIELD_TRAILER_SIZE  sizeof(ulint)
 
17
#else
 
18
#define MEM_FIELD_HEADER_SIZE   0
 
19
#endif
 
20
 
 
21
 
 
22
/* Space needed when allocating for a user a field of
 
23
length N. The space is allocated only in multiples of
 
24
UNIV_MEM_ALIGNMENT. In the debug version there are also
 
25
check fields at the both ends of the field. */
 
26
#ifdef UNIV_MEM_DEBUG
 
27
#define MEM_SPACE_NEEDED(N) ut_calc_align((N) + MEM_FIELD_HEADER_SIZE\
 
28
                 + MEM_FIELD_TRAILER_SIZE, UNIV_MEM_ALIGNMENT)
 
29
#else
 
30
#define MEM_SPACE_NEEDED(N) ut_calc_align((N), UNIV_MEM_ALIGNMENT)
 
31
#endif
 
32
 
 
33
#if defined UNIV_MEM_DEBUG || defined UNIV_DEBUG
 
34
/*******************************************************************
 
35
Checks a memory heap for consistency and prints the contents if requested.
 
36
Outputs the sum of sizes of buffers given to the user (only in
 
37
the debug version), the physical size of the heap and the number of
 
38
blocks in the heap. In case of error returns 0 as sizes and number
 
39
of blocks. */
 
40
 
 
41
void
 
42
mem_heap_validate_or_print(
 
43
/*=======================*/
 
44
        mem_heap_t*     heap,   /* in: memory heap */
 
45
        byte*           top,    /* in: calculate and validate only until
 
46
                                this top pointer in the heap is reached,
 
47
                                if this pointer is NULL, ignored */
 
48
        ibool            print,  /* in: if TRUE, prints the contents
 
49
                                of the heap; works only in
 
50
                                the debug version */
 
51
        ibool*           error,  /* out: TRUE if error */
 
52
        ulint*          us_size,/* out: allocated memory
 
53
                                (for the user) in the heap,
 
54
                                if a NULL pointer is passed as this
 
55
                                argument, it is ignored; in the
 
56
                                non-debug version this is always -1 */
 
57
        ulint*          ph_size,/* out: physical size of the heap,
 
58
                                if a NULL pointer is passed as this
 
59
                                argument, it is ignored */
 
60
        ulint*          n_blocks); /* out: number of blocks in the heap,
 
61
                                if a NULL pointer is passed as this
 
62
                                argument, it is ignored */
 
63
/******************************************************************
 
64
Validates the contents of a memory heap. */
 
65
 
 
66
ibool
 
67
mem_heap_validate(
 
68
/*==============*/
 
69
                                /* out: TRUE if ok */
 
70
        mem_heap_t*   heap);    /* in: memory heap */
 
71
#endif /* UNIV_MEM_DEBUG || UNIV_DEBUG */
 
72
#ifdef UNIV_DEBUG
 
73
/******************************************************************
 
74
Checks that an object is a memory heap (or a block of it) */
 
75
 
 
76
ibool
 
77
mem_heap_check(
 
78
/*===========*/
 
79
                                /* out: TRUE if ok */
 
80
        mem_heap_t*   heap);    /* in: memory heap */
 
81
#endif /* UNIV_DEBUG */
 
82
#ifdef UNIV_MEM_DEBUG
 
83
/*********************************************************************
 
84
TRUE if no memory is currently allocated. */
 
85
 
 
86
ibool
 
87
mem_all_freed(void);
 
88
/*===============*/
 
89
                        /* out: TRUE if no heaps exist */
 
90
/*********************************************************************
 
91
Validates the dynamic memory */
 
92
 
 
93
ibool
 
94
mem_validate_no_assert(void);
 
95
/*=========================*/
 
96
                        /* out: TRUE if error */
 
97
/****************************************************************
 
98
Validates the dynamic memory */
 
99
 
 
100
ibool
 
101
mem_validate(void);
 
102
/*===============*/
 
103
                        /* out: TRUE if ok */
 
104
#endif /* UNIV_MEM_DEBUG */
 
105
/****************************************************************
 
106
Tries to find neigboring memory allocation blocks and dumps to stderr
 
107
the neighborhood of a given pointer. */
 
108
 
 
109
void
 
110
mem_analyze_corruption(
 
111
/*===================*/
 
112
        void*   ptr);   /* in: pointer to place of possible corruption */
 
113
/*********************************************************************
 
114
Prints information of dynamic memory usage and currently allocated memory
 
115
heaps or buffers. Can only be used in the debug version. */
 
116
 
 
117
void
 
118
mem_print_info(void);
 
119
/*================*/
 
120
/*********************************************************************
 
121
Prints information of dynamic memory usage and currently allocated memory
 
122
heaps or buffers since the last ..._print_info or..._print_new_info. */
 
123
 
 
124
void
 
125
mem_print_new_info(void);
 
126
/*====================*/