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

Contents of /navit/navit/debug.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 54 - (show annotations) (download)
Mon Dec 12 13:41:30 2016 UTC (7 years, 4 months ago) by zoff99
File MIME type: text/plain
File size: 11146 byte(s)
v2.0.56
1 /**
2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2012 - 2015 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_ATTR_SAFETY_CHECK 1 // leave this always ON !!
52 // #define NAVIT_FUNC_CALLS_DEBUG_PRINT 1
53 // #define NAVIT_SAY_DEBUG_PRINT 1
54 // #define NAVIT_MEASURE_TIME_DEBUG 1
55 // #define NAVIT_CALLBACK_DEBUG_PRINT 1
56 // #define NAVIT_ROUTING_DEBUG_PRINT 1
57 // #define NAVIT_GPS_DIRECTION_DAMPING 1
58 // #define NAVIT_FREE_TEXT_DEBUG_PRINT 1
59 // #define NAVIT_ANGLE_LIST_DEBUG_PRINT_DRAW 1
60 // #define NAVIT_ANGLE_LIST_DEBUG_PRINT_2 1
61 // #define NAVIT_ANGLE_LIST_DEBUG_PRINT_1 1
62 // #define NAVIT_DEBUG_BAREMETAL 1
63 // #define NAVIT_DEBUG_COORD_LIST 1
64 // #define NAVIT_DEBUG_COORD_DIE2TE_LIST 1
65 //
66 #define NAVIT_DEBUG_SPEECH_POSITION 1
67 //
68 #define NAVIT_TRACKING_SHOW_REAL_GPS_POS 1
69 #define NAVIT_NAVIGATION_REMOVE_DUPL_WAYS 1
70 #define NAVIT_SHOW_ROUTE_ARROWS 1
71 #define NAVIT_CALC_ALLOWED_NEXT_WAYS 1
72 #define NAVIT_CALC_LANES 1
73 #define NAVIT_TRACKING_STICK_TO_ROUTE 1
74 //
75 //
76 #define CAR_STICK_TO_ROUTE_001 1 // stick to route harder in car mode
77 //
78 // #define NAVIT_ROUTE_DIJKSTRA_REVERSE 1
79 //
80 // #define DEBUG_GLIB_MALLOC 1 // <-- does not work yet!
81 // #define DEBUG_GLIB_FREE 1
82 // #define DEBUG_GLIB_REALLY_FREE 1
83 // #define DEBUG_GLIB_MEM_FUNCTIONS 1
84
85 extern int global_func_indent_counter;
86 extern const char* global_func_indent_spaces;
87
88 /*
89 *
90 *
91 *
92 *
93 *
94 *
95 *
96 */
97
98 #ifdef __cplusplus
99 extern "C"
100 {
101 #endif
102
103 #include <stdarg.h>
104 #include <string.h>
105
106 #ifdef _MSC_VER
107 #define __PRETTY_FUNCTION__ __FUNCTION__
108 #endif
109
110 #ifndef HAVE_API_ANDROID
111 #define g_free_func g_free
112 #endif
113
114 /** Possible debug levels (inspired by SLF4J). */
115 typedef enum {
116 /** Internal use only, do not use for logging. */
117 lvl_unset=-1,
118
119 /** Informational message. Should make sense to non-programmers. */
120 lvl_info, // = 0
121
122 /** Error: something did not work. */
123 lvl_error, // = 1
124
125 /** Warning: something may not have worked. */
126 lvl_warning, // = 2
127
128 /** Debug output: (almost) anything goes. */
129 lvl_debug // = 3
130
131 } dbg_level;
132
133
134 extern int debug_level;
135
136
137 #ifdef _DEBUG_BUILD_
138
139 #define dbg_str2(x) #x
140 #define dbg_str1(x) dbg_str2(x)
141 #define dbg_module dbg_str1(MODULE)
142 #define dbg(level,...) { if (debug_level >= level) debug_printf(level,dbg_module,strlen(dbg_module),__PRETTY_FUNCTION__, strlen(__PRETTY_FUNCTION__),1,__VA_ARGS__); }
143 #define dbg_func(level,indent,...) { if (debug_level >= level) debug_printf_func(level,indent,dbg_module,strlen(dbg_module),__PRETTY_FUNCTION__, strlen(__PRETTY_FUNCTION__),1,__VA_ARGS__); }
144 #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)))
145
146 #else
147
148 #define dbg_str2(x) #x
149 #define dbg_str1(x) #x
150 #define dbg_module dbg_str1(MODULE)
151 #define dbg(level,...) #level
152 #define dbg_func(level,indent,...) #level
153 #define dbg_assert(expr) ((expr) ? (void) 0 : (void) 0)
154
155 #endif
156
157
158 // ---- only use this line for debugging ----
159 // ---- only use this line for debugging ----
160 // #define _CIDEBUG_BUILD_ 1
161 // ---- only use this line for debugging ----
162 // ---- only use this line for debugging ----
163
164
165 #ifdef _CIDEBUG_BUILD_
166 #define tests_dbg(level,...) debug_for_tests_printf(level,__VA_ARGS__);
167 #else
168 #define tests_dbg(level,...) #level
169 #endif
170
171 #if 1
172 #define system_log(level,...) debug_for_tests2_printf(level,__VA_ARGS__);
173 #else
174 #define system_log(level,...) #level
175 #endif
176
177
178
179 //#ifdef DEBUG_MALLOC
180 // ----------------
181 //#undef g_new
182 //#undef g_new0
183 //#define g_new(type, size) (type *)debug_malloc(__FILE__,__LINE__,__PRETTY_FUNCTION__,sizeof(type)*(size))
184 //#define g_new0(type, size) (type *)debug_malloc0(__FILE__,__LINE__,__PRETTY_FUNCTION__,sizeof(type)*(size))
185 //#define g_malloc(size) debug_malloc(__FILE__,__LINE__,__PRETTY_FUNCTION__,(size))
186 //#define g_malloc0(size) debug_malloc0(__FILE__,__LINE__,__PRETTY_FUNCTION__,(size))
187 //#define g_realloc(ptr,size) debug_realloc(__FILE__,__LINE__,__PRETTY_FUNCTION__,ptr,(size))
188 //#define g_free(ptr) debug_free(__FILE__,__LINE__,__PRETTY_FUNCTION__,ptr)
189 //#define g_strdup(ptr) debug_strdup(__FILE__,__LINE__,__PRETTY_FUNCTION__,ptr)
190 //#define g_strdup_printf(fmt...) debug_guard(__FILE__,__LINE__,__PRETTY_FUNCTION__,g_strdup_printf(fmt))
191 //#define graphics_icon_path(x) debug_guard(__FILE__,__LINE__,__PRETTY_FUNCTION__,graphics_icon_path(x))
192 //#define dbg_guard(x) debug_guard(__FILE__,__LINE__,__PRETTY_FUNCTION__,x)
193 //#define g_free_func debug_free_func
194 // ----------------
195 //#else
196 // ----------------
197 //#define g_free_func g_free
198 #define dbg_guard(x) x
199 // ----------------
200 //#endif
201
202 /* prototypes */
203 struct attr;
204 struct debug;
205 void debug_init(const char *program_name);
206 void debug_level_set(const char *name, int level);
207 struct debug *debug_new(struct attr *parent, struct attr **attrs);
208 int debug_level_get(const char *name);
209 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);
210 void debug_vprintf_func(int level, int indent, const char *module, const int mlen, const char *function, const int flen, int prefix, const char *fmt, va_list ap);
211 void debug_printf(int level, const char *module, const int mlen, const char *function, const int flen, int prefix, const char *fmt, ...);
212 void debug_for_tests_vprintf(int level, const char *fmt, va_list ap);
213 void debug_for_tests2_vprintf(int level, const char *fmt, va_list ap);
214 void debug_for_tests_printf(int level, const char *fmt, ...);
215 void debug_for_tests2_printf(int level, const char *fmt, ...);
216 void debug_printf_func(int level, int indent, const char *module, const int mlen, const char *function, const int flen, int prefix, const char *fmt, ...);
217 void debug_assert_fail(const char *module, const int mlen, const char *function, const int flen, const char *file, int line, const char *expr);
218 void debug_destroy(void);
219 void debug_set_logfile(const char *path);
220 void debug_dump_mallocs(void);
221 void *debug_malloc(const char *where, int line, const char *func, int size);
222 void *debug_malloc0(const char *where, int line, const char *func, int size);
223 char *debug_strdup(const char *where, int line, const char *func, const char *ptr);
224 char *debug_guard(const char *where, int line, const char *func, char *str);
225 void debug_free(const char *where, int line, const char *func, void *ptr);
226 void debug_free_func(void *ptr);
227 void debug_finished(void);
228 void *debug_realloc(const char *where, int line, const char *func, void *ptr, int size);
229 void debug_get_timestamp_millis(long *ts_millis);
230 /* end of prototypes */
231
232
233
234
235
236
237
238
239
240 // printf -----------
241
242 #if 0
243 #include <stdarg.h>
244
245 #define NEED_ASPRINTF
246 #define NEED_ASNPRINTF
247 #define NEED_VASPRINTF
248 #define NEED_VASNPRINTF
249
250 /* #define PREFER_PORTABLE_SNPRINTF */
251
252 #include "snprintf.h"
253
254
255 #undef g_strdup_printf
256 #define g_strdup_printf(format, ...) g_strdup_printf_custom(format, __VA_ARGS__)
257
258 #undef g_strdup_vprintf
259 #define g_strdup_vprintf(format, args) g_strdup_vprintf_custom(format, args)
260
261 #undef g_vasprintf
262 #define g_vasprintf(str, format, args) g_vasprintf_custom(str, format, args)
263
264 // ---- BAD !!!! ----
265 typedef char gchar;
266 typedef short gshort;
267 typedef long glong;
268 typedef int gint;
269 typedef gint gboolean;
270 // ---- BAD !!!! ----
271
272 gchar* g_strdup_printf_custom(const gchar *format, ...);
273 gchar* g_strdup_vprintf_custom(const gchar *format, va_list args);
274 gint g_vasprintf_custom(gchar **string, gchar const *format, va_list args);
275 #endif
276
277
278 #define HAVE_STDARG_H 1
279 //#define HAVE_STDDEF_H 1
280 //#define HAVE_STDINT_H 1
281 //#define HAVE_STDLIB_H 1
282 //#define HAVE_INTTYPES_H 1
283 //#define HAVE_LOCALE_H 1
284 //#define HAVE_LOCALECONV 1
285 //#define HAVE_LCONV_DECIMAL_POINT
286 //#define HAVE_LCONV_THOUSANDS_SEP
287 #define HAVE_LONG_DOUBLE 1
288 #define HAVE_LONG_LONG_INT 1
289 #define HAVE_UNSIGNED_LONG_LONG_INT 1
290 //#define HAVE_INTMAX_T
291 //#define HAVE_UINTMAX_T
292 //#define HAVE_UINTPTR_T
293 //#define HAVE_PTRDIFF_T
294 //#define HAVE_VA_COPY 1
295 //#define HAVE___VA_COPY 1
296
297 #ifndef NO_GTYPES_
298
299 #include <stdarg.h>
300
301
302
303 #undef g_strdup_printf
304 #define g_strdup_printf(format, ...) g_strdup_printf_custom(format, __VA_ARGS__)
305
306 #undef g_strdup_vprintf
307 #define g_strdup_vprintf(format, args) g_strdup_vprintf_custom(format, args)
308
309 #undef g_vasprintf
310 #define g_vasprintf(str, format, args) g_vasprintf_custom(str, format, args)
311
312 // ---- BAD !!!! ----
313 typedef char gchar;
314 typedef short gshort;
315 typedef long glong;
316 typedef int gint;
317 typedef gint gboolean;
318 // ---- BAD !!!! ----
319
320 gchar* g_strdup_printf_custom(const gchar *format, ...);
321 gchar* g_strdup_vprintf_custom(const gchar *format, va_list args);
322 gint g_vasprintf_custom(gchar **string, gchar const *format, va_list args);
323
324
325 //#if !HAVE_VSNPRINTF
326 int rpl_vsnprintf(char *, size_t, const char *, va_list);
327 //#endif
328 //#if !HAVE_SNPRINTF
329 int rpl_snprintf(char *, size_t, const char *, ...);
330 //#endif
331 //#if !HAVE_VASPRINTF
332 int rpl_vasprintf(char **, const char *, va_list);
333 //#endif
334 //#if !HAVE_ASPRINTF
335 int rpl_asprintf(char **, const char *, ...);
336
337 #define vsnprintf rpl_vsnprintf
338 #define snprintf rpl_snprintf
339 #define vasprintf rpl_vasprintf
340 #define asprintf rpl_asprintf
341
342
343 #else
344
345 #ifndef XXMAPTOOL
346 #include <glib.h>
347 gchar* g_strdup_printf_custom(const gchar *format, ...);
348 gchar* g_strdup_vprintf_custom(const gchar *format, va_list args);
349 gint g_vasprintf_custom(gchar **string, gchar const *format, va_list args);
350 #else
351 #define g_strdup_printf_custom g_strdup_printf
352 #define g_strdup_vprintf_custom g_strdup_vprintf
353 #define g_vasprintf_custom g_vasprintf
354 #endif
355
356
357 #endif
358
359 // printf -----------
360
361
362
363
364
365
366
367
368
369 #ifdef __cplusplus
370 }
371 #endif
372
373 #endif
374
375

   
Visit the ZANavi Wiki