00001 /***************************************************************************** 00002 00003 Copyright (C) 1994, 2010, Innobase Oy. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it under 00006 the terms of the GNU General Public License as published by the Free Software 00007 Foundation; version 2 of the License. 00008 00009 This program is distributed in the hope that it will be useful, but WITHOUT 00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00011 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License along with 00014 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin 00015 St, Fifth Floor, Boston, MA 02110-1301 USA 00016 00017 *****************************************************************************/ 00018 00019 /**************************************************/ 00027 /* In the debug version each allocated field is surrounded with 00028 check fields whose sizes are given below */ 00029 00030 #pragma once 00031 #ifdef UNIV_MEM_DEBUG 00032 # ifndef UNIV_HOTBACKUP 00033 /* The mutex which protects in the debug version the hash table 00034 containing the list of live memory heaps, and also the global 00035 variables in mem0dbg.c. */ 00036 extern mutex_t mem_hash_mutex; 00037 # endif /* !UNIV_HOTBACKUP */ 00038 00039 #define MEM_FIELD_HEADER_SIZE ut_calc_align(2 * sizeof(ulint),\ 00040 UNIV_MEM_ALIGNMENT) 00041 #define MEM_FIELD_TRAILER_SIZE sizeof(ulint) 00042 #else 00043 #define MEM_FIELD_HEADER_SIZE 0 00044 #endif 00045 00046 00047 /* Space needed when allocating for a user a field of 00048 length N. The space is allocated only in multiples of 00049 UNIV_MEM_ALIGNMENT. In the debug version there are also 00050 check fields at the both ends of the field. */ 00051 #ifdef UNIV_MEM_DEBUG 00052 #define MEM_SPACE_NEEDED(N) ut_calc_align((N) + MEM_FIELD_HEADER_SIZE\ 00053 + MEM_FIELD_TRAILER_SIZE, UNIV_MEM_ALIGNMENT) 00054 #else 00055 #define MEM_SPACE_NEEDED(N) ut_calc_align((N), UNIV_MEM_ALIGNMENT) 00056 #endif 00057 00058 #if defined UNIV_MEM_DEBUG || defined UNIV_DEBUG 00059 /***************************************************************/ 00065 UNIV_INTERN 00066 void 00067 mem_heap_validate_or_print( 00068 /*=======================*/ 00069 mem_heap_t* heap, 00070 byte* top, 00073 ibool print, 00076 ibool* error, 00077 ulint* us_size, 00082 ulint* ph_size, 00085 ulint* n_blocks); 00088 /**************************************************************/ 00091 UNIV_INTERN 00092 ibool 00093 mem_heap_validate( 00094 /*==============*/ 00095 mem_heap_t* heap); 00096 #endif /* UNIV_MEM_DEBUG || UNIV_DEBUG */ 00097 #ifdef UNIV_DEBUG 00098 /**************************************************************/ 00101 UNIV_INTERN 00102 ibool 00103 mem_heap_check( 00104 /*===========*/ 00105 mem_heap_t* heap); 00106 #endif /* UNIV_DEBUG */ 00107 #ifdef UNIV_MEM_DEBUG 00108 /*****************************************************************/ 00111 UNIV_INTERN 00112 ibool 00113 mem_all_freed(void); 00114 /*===============*/ 00115 /*****************************************************************/ 00118 UNIV_INTERN 00119 ibool 00120 mem_validate_no_assert(void); 00121 /*=========================*/ 00122 /************************************************************/ 00125 UNIV_INTERN 00126 ibool 00127 mem_validate(void); 00128 /*===============*/ 00129 #endif /* UNIV_MEM_DEBUG */ 00130 /************************************************************/ 00133 UNIV_INTERN 00134 void 00135 mem_analyze_corruption( 00136 /*===================*/ 00137 void* ptr); 00138 /*****************************************************************/ 00141 UNIV_INTERN 00142 void 00143 mem_print_info(void); 00144 /*================*/ 00145 /*****************************************************************/ 00148 UNIV_INTERN 00149 void 00150 mem_print_new_info(void); 00151 /*====================*/