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

Contents of /navit/navit/debug.h

Parent Directory Parent Directory | Revision Log Revision Log


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

   
Visit the ZANavi Wiki