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

Contents of /navit/navit/debug.h

Parent Directory Parent Directory | Revision Log Revision Log


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

   
Visit the ZANavi Wiki