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 |
// #define _CIDEBUG_BUILD_ 1
|
159 |
|
160 |
|
161 |
#ifdef _CIDEBUG_BUILD_
|
162 |
#define tests_dbg(level,...) debug_for_tests_printf(level,__VA_ARGS__);
|
163 |
#else
|
164 |
#define tests_dbg(level,...) #level
|
165 |
#endif
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
//#ifdef DEBUG_MALLOC
|
171 |
// ----------------
|
172 |
//#undef g_new
|
173 |
//#undef g_new0
|
174 |
//#define g_new(type, size) (type *)debug_malloc(__FILE__,__LINE__,__PRETTY_FUNCTION__,sizeof(type)*(size))
|
175 |
//#define g_new0(type, size) (type *)debug_malloc0(__FILE__,__LINE__,__PRETTY_FUNCTION__,sizeof(type)*(size))
|
176 |
//#define g_malloc(size) debug_malloc(__FILE__,__LINE__,__PRETTY_FUNCTION__,(size))
|
177 |
//#define g_malloc0(size) debug_malloc0(__FILE__,__LINE__,__PRETTY_FUNCTION__,(size))
|
178 |
//#define g_realloc(ptr,size) debug_realloc(__FILE__,__LINE__,__PRETTY_FUNCTION__,ptr,(size))
|
179 |
//#define g_free(ptr) debug_free(__FILE__,__LINE__,__PRETTY_FUNCTION__,ptr)
|
180 |
//#define g_strdup(ptr) debug_strdup(__FILE__,__LINE__,__PRETTY_FUNCTION__,ptr)
|
181 |
//#define g_strdup_printf(fmt...) debug_guard(__FILE__,__LINE__,__PRETTY_FUNCTION__,g_strdup_printf(fmt))
|
182 |
//#define graphics_icon_path(x) debug_guard(__FILE__,__LINE__,__PRETTY_FUNCTION__,graphics_icon_path(x))
|
183 |
//#define dbg_guard(x) debug_guard(__FILE__,__LINE__,__PRETTY_FUNCTION__,x)
|
184 |
//#define g_free_func debug_free_func
|
185 |
// ----------------
|
186 |
//#else
|
187 |
// ----------------
|
188 |
//#define g_free_func g_free
|
189 |
#define dbg_guard(x) x
|
190 |
// ----------------
|
191 |
//#endif
|
192 |
|
193 |
/* prototypes */
|
194 |
struct attr;
|
195 |
struct debug;
|
196 |
void debug_init(const char *program_name);
|
197 |
void debug_level_set(const char *name, int level);
|
198 |
struct debug *debug_new(struct attr *parent, struct attr **attrs);
|
199 |
int debug_level_get(const char *name);
|
200 |
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);
|
201 |
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);
|
202 |
void debug_printf(int level, const char *module, const int mlen, const char *function, const int flen, int prefix, const char *fmt, ...);
|
203 |
void debug_for_tests_vprintf(int level, const char *fmt, va_list ap);
|
204 |
void debug_for_tests_printf(int level, const char *fmt, ...);
|
205 |
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, ...);
|
206 |
void debug_assert_fail(const char *module, const int mlen, const char *function, const int flen, const char *file, int line, const char *expr);
|
207 |
void debug_destroy(void);
|
208 |
void debug_set_logfile(const char *path);
|
209 |
void debug_dump_mallocs(void);
|
210 |
void *debug_malloc(const char *where, int line, const char *func, int size);
|
211 |
void *debug_malloc0(const char *where, int line, const char *func, int size);
|
212 |
char *debug_strdup(const char *where, int line, const char *func, const char *ptr);
|
213 |
char *debug_guard(const char *where, int line, const char *func, char *str);
|
214 |
void debug_free(const char *where, int line, const char *func, void *ptr);
|
215 |
void debug_free_func(void *ptr);
|
216 |
void debug_finished(void);
|
217 |
void *debug_realloc(const char *where, int line, const char *func, void *ptr, int size);
|
218 |
void debug_get_timestamp_millis(long *ts_millis);
|
219 |
/* end of prototypes */
|
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
// printf -----------
|
230 |
|
231 |
#if 0
|
232 |
#include <stdarg.h>
|
233 |
|
234 |
#define NEED_ASPRINTF
|
235 |
#define NEED_ASNPRINTF
|
236 |
#define NEED_VASPRINTF
|
237 |
#define NEED_VASNPRINTF
|
238 |
|
239 |
/* #define PREFER_PORTABLE_SNPRINTF */
|
240 |
|
241 |
#include "snprintf.h"
|
242 |
|
243 |
|
244 |
#undef g_strdup_printf
|
245 |
#define g_strdup_printf(format, ...) g_strdup_printf_custom(format, __VA_ARGS__)
|
246 |
|
247 |
#undef g_strdup_vprintf
|
248 |
#define g_strdup_vprintf(format, args) g_strdup_vprintf_custom(format, args)
|
249 |
|
250 |
#undef g_vasprintf
|
251 |
#define g_vasprintf(str, format, args) g_vasprintf_custom(str, format, args)
|
252 |
|
253 |
// ---- BAD !!!! ----
|
254 |
typedef char gchar;
|
255 |
typedef short gshort;
|
256 |
typedef long glong;
|
257 |
typedef int gint;
|
258 |
typedef gint gboolean;
|
259 |
// ---- BAD !!!! ----
|
260 |
|
261 |
gchar* g_strdup_printf_custom(const gchar *format, ...);
|
262 |
gchar* g_strdup_vprintf_custom(const gchar *format, va_list args);
|
263 |
gint g_vasprintf_custom(gchar **string, gchar const *format, va_list args);
|
264 |
#endif
|
265 |
|
266 |
|
267 |
#define HAVE_STDARG_H 1
|
268 |
//#define HAVE_STDDEF_H 1
|
269 |
//#define HAVE_STDINT_H 1
|
270 |
//#define HAVE_STDLIB_H 1
|
271 |
//#define HAVE_INTTYPES_H 1
|
272 |
//#define HAVE_LOCALE_H 1
|
273 |
//#define HAVE_LOCALECONV 1
|
274 |
//#define HAVE_LCONV_DECIMAL_POINT
|
275 |
//#define HAVE_LCONV_THOUSANDS_SEP
|
276 |
#define HAVE_LONG_DOUBLE 1
|
277 |
#define HAVE_LONG_LONG_INT 1
|
278 |
#define HAVE_UNSIGNED_LONG_LONG_INT 1
|
279 |
//#define HAVE_INTMAX_T
|
280 |
//#define HAVE_UINTMAX_T
|
281 |
//#define HAVE_UINTPTR_T
|
282 |
//#define HAVE_PTRDIFF_T
|
283 |
//#define HAVE_VA_COPY 1
|
284 |
//#define HAVE___VA_COPY 1
|
285 |
|
286 |
#ifndef NO_GTYPES_
|
287 |
|
288 |
#include <stdarg.h>
|
289 |
|
290 |
|
291 |
|
292 |
#undef g_strdup_printf
|
293 |
#define g_strdup_printf(format, ...) g_strdup_printf_custom(format, __VA_ARGS__)
|
294 |
|
295 |
#undef g_strdup_vprintf
|
296 |
#define g_strdup_vprintf(format, args) g_strdup_vprintf_custom(format, args)
|
297 |
|
298 |
#undef g_vasprintf
|
299 |
#define g_vasprintf(str, format, args) g_vasprintf_custom(str, format, args)
|
300 |
|
301 |
// ---- BAD !!!! ----
|
302 |
typedef char gchar;
|
303 |
typedef short gshort;
|
304 |
typedef long glong;
|
305 |
typedef int gint;
|
306 |
typedef gint gboolean;
|
307 |
// ---- BAD !!!! ----
|
308 |
|
309 |
gchar* g_strdup_printf_custom(const gchar *format, ...);
|
310 |
gchar* g_strdup_vprintf_custom(const gchar *format, va_list args);
|
311 |
gint g_vasprintf_custom(gchar **string, gchar const *format, va_list args);
|
312 |
|
313 |
|
314 |
//#if !HAVE_VSNPRINTF
|
315 |
int rpl_vsnprintf(char *, size_t, const char *, va_list);
|
316 |
//#endif
|
317 |
//#if !HAVE_SNPRINTF
|
318 |
int rpl_snprintf(char *, size_t, const char *, ...);
|
319 |
//#endif
|
320 |
//#if !HAVE_VASPRINTF
|
321 |
int rpl_vasprintf(char **, const char *, va_list);
|
322 |
//#endif
|
323 |
//#if !HAVE_ASPRINTF
|
324 |
int rpl_asprintf(char **, const char *, ...);
|
325 |
|
326 |
#define vsnprintf rpl_vsnprintf
|
327 |
#define snprintf rpl_snprintf
|
328 |
#define vasprintf rpl_vasprintf
|
329 |
#define asprintf rpl_asprintf
|
330 |
|
331 |
|
332 |
#else
|
333 |
|
334 |
#ifndef XXMAPTOOL
|
335 |
#include <glib.h>
|
336 |
gchar* g_strdup_printf_custom(const gchar *format, ...);
|
337 |
gchar* g_strdup_vprintf_custom(const gchar *format, va_list args);
|
338 |
gint g_vasprintf_custom(gchar **string, gchar const *format, va_list args);
|
339 |
#else
|
340 |
#define g_strdup_printf_custom g_strdup_printf
|
341 |
#define g_strdup_vprintf_custom g_strdup_vprintf
|
342 |
#define g_vasprintf_custom g_vasprintf
|
343 |
#endif
|
344 |
|
345 |
|
346 |
#endif
|
347 |
|
348 |
// printf -----------
|
349 |
|
350 |
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 |
#ifdef __cplusplus
|
359 |
}
|
360 |
#endif
|
361 |
|
362 |
#endif
|
363 |
|
364 |
|