PIPS
malloc_debug.c
Go to the documentation of this file.
1 /*
2 
3  $Id: malloc_debug.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifdef HAVE_CONFIG_H
25  #include "pips_config.h"
26 #endif
27 /* #include <sys/stdtypes.h>*/
28 /* #include "stdlib.h" */
29 
30 #include "genC.h"
31 
32 #include "misc.h"
33 
35 {
36  debug_on("MALLOC_DEBUG_LEVEL");
37 #if __GNUC__foo || sunfoo
38  if (get_debug_level()==9) {
39  debug(9, "pips_malloc_debug",
40  "malloc_debug level of error diagnosis is 2\n");
41  malloc_debug(2);
42  }
43  else if (get_debug_level()>=5) {
44  debug(5, "pips_malloc_debug", "malloc(50) returns %x\n",
45  (int) malloc(50));
46  debug(5, "pips_malloc_debug", "call to malloc_verify()\n");
47  pips_assert("pips_malloc_debug", malloc_verify());
48  malloc_debug(1);
49  }
50  else if (get_debug_level()>=1)
51  malloc_debug(1);
52  else
53  malloc_debug(0);
54 #else
55  debug(1, "pips_malloc_debug", "No malloc_debug on this system\n");
56 #endif
57  debug_off();
58 }
void * malloc(YYSIZE_T)
void pips_malloc_debug()
include <sys/stdtypes.h>
Definition: malloc_debug.c:34
#define debug_on(env)
Definition: misc-local.h:157
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define debug_off()
Definition: misc-local.h:160
int get_debug_level(void)
GET_DEBUG_LEVEL returns the current debugging level.
Definition: debug.c:67
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189