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

Contents of /navit/navit/debug.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (show annotations) (download)
Mon Feb 4 17:41:59 2013 UTC (11 years, 1 month ago) by zoff99
File MIME type: text/plain
File size: 5213 byte(s)
new map version, lots of fixes and experimental new features
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 *
46 * define some debug stuff here
47 *
48 *
49 *
50 */
51 // #define NAVIT_FUNC_CALLS_DEBUG_PRINT 1
52 // #define NAVIT_SAY_DEBUG_PRINT 1
53 // #define NAVIT_MEASURE_TIME_DEBUG 1
54 // #define NAVIT_CALLBACK_DEBUG_PRINT 1
55 #define NAVIT_ATTR_SAFETY_CHECK 1
56 //
57 // #define DEBUG_GLIB_MALLOC 1 // <-- does not work yet!
58 // #define DEBUG_GLIB_FREE 1
59 // #define DEBUG_GLIB_REALLY_FREE 1
60 // #define DEBUG_GLIB_MEM_FUNCTIONS 1
61 /*
62 *
63 *
64 *
65 *
66 *
67 *
68 *
69 */
70
71 #ifdef __cplusplus
72 extern "C"
73 {
74 #endif
75
76 #include <stdarg.h>
77 #include <string.h>
78
79 #ifdef _MSC_VER
80 #define __PRETTY_FUNCTION__ __FUNCTION__
81 #endif
82
83 #ifndef HAVE_API_ANDROID
84 #define g_free_func g_free
85 #endif
86
87 extern int debug_level;
88 #define dbg_str2(x) #x
89 #define dbg_str1(x) dbg_str2(x)
90 #define dbg_module dbg_str1(MODULE)
91 #define dbg(level,...) { if (debug_level >= level) debug_printf(level,dbg_module,strlen(dbg_module),__PRETTY_FUNCTION__, strlen(__PRETTY_FUNCTION__),1,__VA_ARGS__); }
92 #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)))
93
94 //#ifdef DEBUG_MALLOC
95 // ----------------
96 //#undef g_new
97 //#undef g_new0
98 //#define g_new(type, size) (type *)debug_malloc(__FILE__,__LINE__,__PRETTY_FUNCTION__,sizeof(type)*(size))
99 //#define g_new0(type, size) (type *)debug_malloc0(__FILE__,__LINE__,__PRETTY_FUNCTION__,sizeof(type)*(size))
100 //#define g_malloc(size) debug_malloc(__FILE__,__LINE__,__PRETTY_FUNCTION__,(size))
101 //#define g_malloc0(size) debug_malloc0(__FILE__,__LINE__,__PRETTY_FUNCTION__,(size))
102 //#define g_realloc(ptr,size) debug_realloc(__FILE__,__LINE__,__PRETTY_FUNCTION__,ptr,(size))
103 //#define g_free(ptr) debug_free(__FILE__,__LINE__,__PRETTY_FUNCTION__,ptr)
104 //#define g_strdup(ptr) debug_strdup(__FILE__,__LINE__,__PRETTY_FUNCTION__,ptr)
105 //#define g_strdup_printf(fmt...) debug_guard(__FILE__,__LINE__,__PRETTY_FUNCTION__,g_strdup_printf(fmt))
106 //#define graphics_icon_path(x) debug_guard(__FILE__,__LINE__,__PRETTY_FUNCTION__,graphics_icon_path(x))
107 //#define dbg_guard(x) debug_guard(__FILE__,__LINE__,__PRETTY_FUNCTION__,x)
108 //#define g_free_func debug_free_func
109 // ----------------
110 //#else
111 // ----------------
112 //#define g_free_func g_free
113 #define dbg_guard(x) x
114 // ----------------
115 //#endif
116
117 /* prototypes */
118 struct attr;
119 struct debug;
120 void debug_init(const char *program_name);
121 void debug_level_set(const char *name, int level);
122 struct debug *debug_new(struct attr *parent, struct attr **attrs);
123 int debug_level_get(const char *name);
124 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);
125 void debug_printf(int level, const char *module, const int mlen, const char *function, const int flen, int prefix, const char *fmt, ...);
126 void debug_assert_fail(const char *module, const int mlen, const char *function, const int flen, const char *file, int line, const char *expr);
127 void debug_destroy(void);
128 void debug_set_logfile(const char *path);
129 void debug_dump_mallocs(void);
130 void *debug_malloc(const char *where, int line, const char *func, int size);
131 void *debug_malloc0(const char *where, int line, const char *func, int size);
132 char *debug_strdup(const char *where, int line, const char *func, const char *ptr);
133 char *debug_guard(const char *where, int line, const char *func, char *str);
134 void debug_free(const char *where, int line, const char *func, void *ptr);
135 void debug_free_func(void *ptr);
136 void debug_finished(void);
137 void *debug_realloc(const char *where, int line, const char *func, void *ptr, int size);
138 /* end of prototypes */
139
140 #ifdef __cplusplus
141 }
142 #endif
143
144 #endif
145

   
Visit the ZANavi Wiki