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

Contents of /navit/navit/debug.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 30 - (show annotations) (download)
Wed Aug 22 17:01:27 2012 UTC (11 years, 7 months ago) by zoff99
File MIME type: text/plain
File size: 4799 byte(s)
ZANavi 2.0, lots of changes, everything in its own thread, more performance
1 /**
2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2012 Zoff <zoff@zoff.cc>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU 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 General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * 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 /**
21 * Navit, a modular navigation system.
22 * Copyright (C) 2005-2008 Navit Team
23 *
24 * This program is free software; you can redistribute it and/or
25 * modify it under the terms of the GNU Library General Public License
26 * version 2 as published by the Free Software Foundation.
27 *
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU Library General Public License for more details.
32 *
33 * You should have received a copy of the GNU Library General Public
34 * License along with this program; if not, write to the
35 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
36 * Boston, MA 02110-1301, USA.
37 */
38
39 #ifndef NAVIT_DEBUG_H
40 #define NAVIT_DEBUG_H
41
42
43
44 /*
45 * define some debug stuff here
46 */
47 // #define NAVIT_FUNC_CALLS_DEBUG_PRINT 1
48 // #define NAVIT_SAY_DEBUG_PRINT 1
49 // #define NAVIT_MEASURE_TIME_DEBUG 1
50 // #define NAVIT_CALLBACK_DEBUG_PRINT 1
51
52
53 #ifdef __cplusplus
54 extern "C"
55 {
56 #endif
57
58 #include <stdarg.h>
59 #include <string.h>
60
61 #ifdef _MSC_VER
62 #define __PRETTY_FUNCTION__ __FUNCTION__
63 #endif
64
65 extern int debug_level;
66 #define dbg_str2(x) #x
67 #define dbg_str1(x) dbg_str2(x)
68 #define dbg_module dbg_str1(MODULE)
69 #define dbg(level,...) { if (debug_level >= level) debug_printf(level,dbg_module,strlen(dbg_module),__PRETTY_FUNCTION__, strlen(__PRETTY_FUNCTION__),1,__VA_ARGS__); }
70 #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)))
71
72 #ifdef DEBUG_MALLOC
73 #undef g_new
74 #undef g_new0
75 #define g_new(type, size) (type *)debug_malloc(__FILE__,__LINE__,__PRETTY_FUNCTION__,sizeof(type)*(size))
76 #define g_new0(type, size) (type *)debug_malloc0(__FILE__,__LINE__,__PRETTY_FUNCTION__,sizeof(type)*(size))
77 #define g_malloc(size) debug_malloc(__FILE__,__LINE__,__PRETTY_FUNCTION__,(size))
78 #define g_malloc0(size) debug_malloc0(__FILE__,__LINE__,__PRETTY_FUNCTION__,(size))
79 #define g_realloc(ptr,size) debug_realloc(__FILE__,__LINE__,__PRETTY_FUNCTION__,ptr,(size))
80 #define g_free(ptr) debug_free(__FILE__,__LINE__,__PRETTY_FUNCTION__,ptr)
81 #define g_strdup(ptr) debug_strdup(__FILE__,__LINE__,__PRETTY_FUNCTION__,ptr)
82 #define g_strdup_printf(fmt...) debug_guard(__FILE__,__LINE__,__PRETTY_FUNCTION__,g_strdup_printf(fmt))
83 #define graphics_icon_path(x) debug_guard(__FILE__,__LINE__,__PRETTY_FUNCTION__,graphics_icon_path(x))
84 #define dbg_guard(x) debug_guard(__FILE__,__LINE__,__PRETTY_FUNCTION__,x)
85 #define g_free_func debug_free_func
86 #else
87 #define g_free_func g_free
88 #define dbg_guard(x) x
89 #endif
90
91 /* prototypes */
92 struct attr;
93 struct debug;
94 void debug_init(const char *program_name);
95 void debug_level_set(const char *name, int level);
96 struct debug *debug_new(struct attr *parent, struct attr **attrs);
97 int debug_level_get(const char *name);
98 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);
99 void debug_printf(int level, const char *module, const int mlen, const char *function, const int flen, int prefix, const char *fmt, ...);
100 void debug_assert_fail(const char *module, const int mlen, const char *function, const int flen, const char *file, int line, const char *expr);
101 void debug_destroy(void);
102 void debug_set_logfile(const char *path);
103 void debug_dump_mallocs(void);
104 void *debug_malloc(const char *where, int line, const char *func, int size);
105 void *debug_malloc0(const char *where, int line, const char *func, int size);
106 char *debug_strdup(const char *where, int line, const char *func, const char *ptr);
107 char *debug_guard(const char *where, int line, const char *func, char *str);
108 void debug_free(const char *where, int line, const char *func, void *ptr);
109 void debug_free_func(void *ptr);
110 void debug_finished(void);
111 void *debug_realloc(const char *where, int line, const char *func, void *ptr, int size);
112 /* end of prototypes */
113
114 #ifdef __cplusplus
115 }
116 #endif
117
118 #endif
119

   
Visit the ZANavi Wiki