diff options
| author | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2007-04-24 23:58:57 +0000 |
|---|---|---|
| committer | Nicolas Pennequin <nicolas.pennequin@free.fr> | 2007-04-24 23:58:57 +0000 |
| commit | 6ac306a515e560e01fdfd36495afb034ea6a5080 (patch) | |
| tree | 9d2c4dcd4141baee6760c1dbfab247ad46569b96 /apps/gui/wps_debug.c | |
| parent | 4ddc764a7c1738fc39da8b95c560d07940e8de9a (diff) | |
| download | rockbox-6ac306a515e560e01fdfd36495afb034ea6a5080.zip rockbox-6ac306a515e560e01fdfd36495afb034ea6a5080.tar.gz rockbox-6ac306a515e560e01fdfd36495afb034ea6a5080.tar.bz2 rockbox-6ac306a515e560e01fdfd36495afb034ea6a5080.tar.xz | |
Add a new commandline switch to the simulator: "--debugwps". It enables printing of advanced (and very verbose) WPS debugging information. Also make the debugging code a bit cleaner.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13257 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/wps_debug.c')
| -rw-r--r-- | apps/gui/wps_debug.c | 53 |
1 files changed, 48 insertions, 5 deletions
diff --git a/apps/gui/wps_debug.c b/apps/gui/wps_debug.c index ad9395b..335c994 100644 --- a/apps/gui/wps_debug.c +++ b/apps/gui/wps_debug.c @@ -24,11 +24,19 @@ #include "gwps.h" #include "debug.h" +#define PARSE_FAIL_UNCLOSED_COND 1 +#define PARSE_FAIL_INVALID_CHAR 2 +#define PARSE_FAIL_COND_SYNTAX_ERROR 3 + +#ifdef SIMULATOR +extern bool debug_wps; +#endif + static char *next_str(bool next) { - return next ? "next" : ""; + return next ? "next " : ""; } -void dump_wps_tokens(struct wps_data *data) +static void dump_wps_tokens(struct wps_data *data) { struct wps_token *token; int i, j; @@ -358,7 +366,7 @@ void dump_wps_tokens(struct wps_data *data) DEBUGF("\n"); } -void print_line_info(struct wps_data *data) +static void print_line_info(struct wps_data *data) { int i, j; struct wps_line *line; @@ -395,7 +403,7 @@ void print_line_info(struct wps_data *data) DEBUGF("\n"); } -void print_wps_strings(struct wps_data *data) +static void print_wps_strings(struct wps_data *data) { int i, len, total_len = 0, buf_used = 0; @@ -414,7 +422,7 @@ void print_wps_strings(struct wps_data *data) } #ifdef HAVE_LCD_BITMAP -void print_img_cond_indexes(struct wps_data *data) +static void print_img_cond_indexes(struct wps_data *data) { DEBUGF("Image conditional indexes:\n"); int i; @@ -427,4 +435,39 @@ void print_img_cond_indexes(struct wps_data *data) } #endif /*HAVE_LCD_BITMAP */ +void print_debug_info(struct wps_data *data, int fail, int line) +{ +#ifdef SIMULATOR + if (debug_wps) + { + dump_wps_tokens(data); + print_line_info(data); + print_wps_strings(data); +#ifdef HAVE_LCD_BITMAP + print_img_cond_indexes(data); +#endif + } +#endif /* SIMULATOR */ + + if (fail) + { + DEBUGF("Failed parsing on line %d : ", line); + switch (fail) + { + case PARSE_FAIL_UNCLOSED_COND: + DEBUGF("Unclosed conditional"); + break; + + case PARSE_FAIL_INVALID_CHAR: + DEBUGF("Invalid conditional char (not in an open conditional)"); + break; + + case PARSE_FAIL_COND_SYNTAX_ERROR: + DEBUGF("Conditional syntax error"); + break; + } + DEBUGF("\n"); + } +} + #endif /* DEBUG */ |