~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-03-18 12:12:31 UTC
  • Revision ID: james.westby@ubuntu.com-20100318121231-k6g1xe6cshbwa0f8
Tags: upstream-2010.03.1347
ImportĀ upstreamĀ versionĀ 2010.03.1347

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 
 
3
Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
 
4
 
 
5
This program is free software; you can redistribute it and/or modify it under
 
6
the terms of the GNU General Public License as published by the Free Software
 
7
Foundation; version 2 of the License.
 
8
 
 
9
This program is distributed in the hope that it will be useful, but WITHOUT
 
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 
12
 
 
13
You should have received a copy of the GNU General Public License along with
 
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 
15
Place, Suite 330, Boston, MA 02111-1307 USA
 
16
 
 
17
*****************************************************************************/
 
18
 
 
19
/**************************************************//**
 
20
@file include/mem0dbg.h
 
21
The memory management: the debug code. This is not a compilation module,
 
22
but is included in mem0mem.* !
 
23
 
 
24
Created 6/9/1994 Heikki Tuuri
 
25
*******************************************************/
 
26
 
 
27
/* In the debug version each allocated field is surrounded with
 
28
check fields whose sizes are given below */
 
29
 
 
30
#ifdef UNIV_MEM_DEBUG
 
31
#define MEM_FIELD_HEADER_SIZE   ut_calc_align(2 * sizeof(ulint),\
 
32
                                                UNIV_MEM_ALIGNMENT)
 
33
#define MEM_FIELD_TRAILER_SIZE  sizeof(ulint)
 
34
#else
 
35
#define MEM_FIELD_HEADER_SIZE   0
 
36
#endif
 
37
 
 
38
 
 
39
/* Space needed when allocating for a user a field of
 
40
length N. The space is allocated only in multiples of
 
41
UNIV_MEM_ALIGNMENT. In the debug version there are also
 
42
check fields at the both ends of the field. */
 
43
#ifdef UNIV_MEM_DEBUG
 
44
#define MEM_SPACE_NEEDED(N) ut_calc_align((N) + MEM_FIELD_HEADER_SIZE\
 
45
                 + MEM_FIELD_TRAILER_SIZE, UNIV_MEM_ALIGNMENT)
 
46
#else
 
47
#define MEM_SPACE_NEEDED(N) ut_calc_align((N), UNIV_MEM_ALIGNMENT)
 
48
#endif
 
49
 
 
50
#if defined UNIV_MEM_DEBUG || defined UNIV_DEBUG
 
51
/***************************************************************//**
 
52
Checks a memory heap for consistency and prints the contents if requested.
 
53
Outputs the sum of sizes of buffers given to the user (only in
 
54
the debug version), the physical size of the heap and the number of
 
55
blocks in the heap. In case of error returns 0 as sizes and number
 
56
of blocks. */
 
57
UNIV_INTERN
 
58
void
 
59
mem_heap_validate_or_print(
 
60
/*=======================*/
 
61
        mem_heap_t*     heap,   /*!< in: memory heap */
 
62
        byte*           top,    /*!< in: calculate and validate only until
 
63
                                this top pointer in the heap is reached,
 
64
                                if this pointer is NULL, ignored */
 
65
        ibool            print,  /*!< in: if TRUE, prints the contents
 
66
                                of the heap; works only in
 
67
                                the debug version */
 
68
        ibool*           error,  /*!< out: TRUE if error */
 
69
        ulint*          us_size,/*!< out: allocated memory
 
70
                                (for the user) in the heap,
 
71
                                if a NULL pointer is passed as this
 
72
                                argument, it is ignored; in the
 
73
                                non-debug version this is always -1 */
 
74
        ulint*          ph_size,/*!< out: physical size of the heap,
 
75
                                if a NULL pointer is passed as this
 
76
                                argument, it is ignored */
 
77
        ulint*          n_blocks); /*!< out: number of blocks in the heap,
 
78
                                if a NULL pointer is passed as this
 
79
                                argument, it is ignored */
 
80
/**************************************************************//**
 
81
Validates the contents of a memory heap.
 
82
@return TRUE if ok */
 
83
UNIV_INTERN
 
84
ibool
 
85
mem_heap_validate(
 
86
/*==============*/
 
87
        mem_heap_t*   heap);    /*!< in: memory heap */
 
88
#endif /* UNIV_MEM_DEBUG || UNIV_DEBUG */
 
89
#ifdef UNIV_DEBUG
 
90
/**************************************************************//**
 
91
Checks that an object is a memory heap (or a block of it)
 
92
@return TRUE if ok */
 
93
UNIV_INTERN
 
94
ibool
 
95
mem_heap_check(
 
96
/*===========*/
 
97
        mem_heap_t*   heap);    /*!< in: memory heap */
 
98
#endif /* UNIV_DEBUG */
 
99
#ifdef UNIV_MEM_DEBUG
 
100
/*****************************************************************//**
 
101
TRUE if no memory is currently allocated.
 
102
@return TRUE if no heaps exist */
 
103
UNIV_INTERN
 
104
ibool
 
105
mem_all_freed(void);
 
106
/*===============*/
 
107
/*****************************************************************//**
 
108
Validates the dynamic memory
 
109
@return TRUE if error */
 
110
UNIV_INTERN
 
111
ibool
 
112
mem_validate_no_assert(void);
 
113
/*=========================*/
 
114
/************************************************************//**
 
115
Validates the dynamic memory
 
116
@return TRUE if ok */
 
117
UNIV_INTERN
 
118
ibool
 
119
mem_validate(void);
 
120
/*===============*/
 
121
#endif /* UNIV_MEM_DEBUG */
 
122
/************************************************************//**
 
123
Tries to find neigboring memory allocation blocks and dumps to stderr
 
124
the neighborhood of a given pointer. */
 
125
UNIV_INTERN
 
126
void
 
127
mem_analyze_corruption(
 
128
/*===================*/
 
129
        void*   ptr);   /*!< in: pointer to place of possible corruption */
 
130
/*****************************************************************//**
 
131
Prints information of dynamic memory usage and currently allocated memory
 
132
heaps or buffers. Can only be used in the debug version. */
 
133
UNIV_INTERN
 
134
void
 
135
mem_print_info(void);
 
136
/*================*/
 
137
/*****************************************************************//**
 
138
Prints information of dynamic memory usage and currently allocated memory
 
139
heaps or buffers since the last ..._print_info or..._print_new_info. */
 
140
UNIV_INTERN
 
141
void
 
142
mem_print_new_info(void);
 
143
/*====================*/