/[zanavi_public1]/navit/navit/debug.h
ZANavi

Contents of /navit/navit/debug.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (hide annotations) (download)
Fri Oct 28 21:19:04 2011 UTC (12 years, 5 months ago) by zoff99
File MIME type: text/plain
File size: 3847 byte(s)
import files
1 zoff99 2 /**
2     * Navit, a modular navigation system.
3     * Copyright (C) 2005-2008 Navit Team
4     *
5     * This program is free software; you can redistribute it and/or
6     * modify it under the terms of the GNU Library General Public License
7     * version 2 as published by the Free Software Foundation.
8     *
9     * This program is distributed in the hope that it will be useful,
10     * but WITHOUT ANY WARRANTY; without even the implied warranty of
11     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12     * GNU Library General Public License for more details.
13     *
14     * You should have received a copy of the GNU Library General Public
15     * License along with this program; if not, write to the
16     * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17     * Boston, MA 02110-1301, USA.
18     */
19    
20     #ifndef NAVIT_DEBUG_H
21     #define NAVIT_DEBUG_H
22    
23     #ifdef __cplusplus
24     extern "C" {
25     #endif
26    
27     #include <stdarg.h>
28     #include <string.h>
29    
30     #ifdef _MSC_VER
31     #define __PRETTY_FUNCTION__ __FUNCTION__
32     #endif
33    
34     extern int debug_level;
35     #define dbg_str2(x) #x
36     #define dbg_str1(x) dbg_str2(x)
37     #define dbg_module dbg_str1(MODULE)
38     #define dbg(level,...) { if (debug_level >= level) debug_printf(level,dbg_module,strlen(dbg_module),__PRETTY_FUNCTION__, strlen(__PRETTY_FUNCTION__),1,__VA_ARGS__); }
39     #define dbg_assert(expr) ((expr) ? (void) 0 : debug_assert_fail(dbg_module,strlen(dbg_module),__PRETTY_FUNCTION__, strlen(__PRETTY_FUNCTION__),__FILE__,__LINE__,dbg_str1(expr)))
40    
41     #ifdef DEBUG_MALLOC
42     #undef g_new
43     #undef g_new0
44     #define g_new(type, size) (type *)debug_malloc(__FILE__,__LINE__,__PRETTY_FUNCTION__,sizeof(type)*(size))
45     #define g_new0(type, size) (type *)debug_malloc0(__FILE__,__LINE__,__PRETTY_FUNCTION__,sizeof(type)*(size))
46     #define g_malloc(size) debug_malloc(__FILE__,__LINE__,__PRETTY_FUNCTION__,(size))
47     #define g_malloc0(size) debug_malloc0(__FILE__,__LINE__,__PRETTY_FUNCTION__,(size))
48     #define g_realloc(ptr,size) debug_realloc(__FILE__,__LINE__,__PRETTY_FUNCTION__,ptr,(size))
49     #define g_free(ptr) debug_free(__FILE__,__LINE__,__PRETTY_FUNCTION__,ptr)
50     #define g_strdup(ptr) debug_strdup(__FILE__,__LINE__,__PRETTY_FUNCTION__,ptr)
51     #define g_strdup_printf(fmt...) debug_guard(__FILE__,__LINE__,__PRETTY_FUNCTION__,g_strdup_printf(fmt))
52     #define graphics_icon_path(x) debug_guard(__FILE__,__LINE__,__PRETTY_FUNCTION__,graphics_icon_path(x))
53     #define dbg_guard(x) debug_guard(__FILE__,__LINE__,__PRETTY_FUNCTION__,x)
54     #define g_free_func debug_free_func
55     #else
56     #define g_free_func g_free
57     #define dbg_guard(x) x
58     #endif
59    
60     /* prototypes */
61     struct attr;
62     struct debug;
63     void debug_init(const char *program_name);
64     void debug_level_set(const char *name, int level);
65     struct debug *debug_new(struct attr *parent, struct attr **attrs);
66     int debug_level_get(const char *name);
67     void debug_vprintf(int level, const char *module, const int mlen, const char *function, const int flen, int prefix, const char *fmt, va_list ap);
68     void debug_printf(int level, const char *module, const int mlen, const char *function, const int flen, int prefix, const char *fmt, ...);
69     void debug_assert_fail(const char *module, const int mlen, const char *function, const int flen, const char *file, int line, const char *expr);
70     void debug_destroy(void);
71     void debug_set_logfile(const char *path);
72     void debug_dump_mallocs(void);
73     void *debug_malloc(const char *where, int line, const char *func, int size);
74     void *debug_malloc0(const char *where, int line, const char *func, int size);
75     char *debug_strdup(const char *where, int line, const char *func, const char *ptr);
76     char *debug_guard(const char *where, int line, const char *func, char *str);
77     void debug_free(const char *where, int line, const char *func, void *ptr);
78     void debug_free_func(void *ptr);
79     void debug_finished(void);
80     void *debug_realloc(const char *where, int line, const char *func, void *ptr, int size);
81     /* end of prototypes */
82    
83     #ifdef __cplusplus
84     }
85     #endif
86    
87     #endif
88    

   
Visit the ZANavi Wiki