summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorNicolas Pennequin <nicolas.pennequin@free.fr>2007-04-24 23:58:57 +0000
committerNicolas Pennequin <nicolas.pennequin@free.fr>2007-04-24 23:58:57 +0000
commit6ac306a515e560e01fdfd36495afb034ea6a5080 (patch)
tree9d2c4dcd4141baee6760c1dbfab247ad46569b96 /apps
parent4ddc764a7c1738fc39da8b95c560d07940e8de9a (diff)
downloadrockbox-6ac306a515e560e01fdfd36495afb034ea6a5080.tar.gz
rockbox-6ac306a515e560e01fdfd36495afb034ea6a5080.zip
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')
-rw-r--r--apps/gui/wps_debug.c53
-rw-r--r--apps/gui/wps_parser.c37
2 files changed, 51 insertions, 39 deletions
diff --git a/apps/gui/wps_debug.c b/apps/gui/wps_debug.c
index ad9395b05d..335c994881 100644
--- a/apps/gui/wps_debug.c
+++ b/apps/gui/wps_debug.c
@@ -24,11 +24,19 @@
24#include "gwps.h" 24#include "gwps.h"
25#include "debug.h" 25#include "debug.h"
26 26
27#define PARSE_FAIL_UNCLOSED_COND 1
28#define PARSE_FAIL_INVALID_CHAR 2
29#define PARSE_FAIL_COND_SYNTAX_ERROR 3
30
31#ifdef SIMULATOR
32extern bool debug_wps;
33#endif
34
27static char *next_str(bool next) { 35static char *next_str(bool next) {
28 return next ? "next" : ""; 36 return next ? "next " : "";
29} 37}
30 38
31void dump_wps_tokens(struct wps_data *data) 39static void dump_wps_tokens(struct wps_data *data)
32{ 40{
33 struct wps_token *token; 41 struct wps_token *token;
34 int i, j; 42 int i, j;
@@ -358,7 +366,7 @@ void dump_wps_tokens(struct wps_data *data)
358 DEBUGF("\n"); 366 DEBUGF("\n");
359} 367}
360 368
361void print_line_info(struct wps_data *data) 369static void print_line_info(struct wps_data *data)
362{ 370{
363 int i, j; 371 int i, j;
364 struct wps_line *line; 372 struct wps_line *line;
@@ -395,7 +403,7 @@ void print_line_info(struct wps_data *data)
395 DEBUGF("\n"); 403 DEBUGF("\n");
396} 404}
397 405
398void print_wps_strings(struct wps_data *data) 406static void print_wps_strings(struct wps_data *data)
399{ 407{
400 int i, len, total_len = 0, buf_used = 0; 408 int i, len, total_len = 0, buf_used = 0;
401 409
@@ -414,7 +422,7 @@ void print_wps_strings(struct wps_data *data)
414} 422}
415 423
416#ifdef HAVE_LCD_BITMAP 424#ifdef HAVE_LCD_BITMAP
417void print_img_cond_indexes(struct wps_data *data) 425static void print_img_cond_indexes(struct wps_data *data)
418{ 426{
419 DEBUGF("Image conditional indexes:\n"); 427 DEBUGF("Image conditional indexes:\n");
420 int i; 428 int i;
@@ -427,4 +435,39 @@ void print_img_cond_indexes(struct wps_data *data)
427} 435}
428#endif /*HAVE_LCD_BITMAP */ 436#endif /*HAVE_LCD_BITMAP */
429 437
438void print_debug_info(struct wps_data *data, int fail, int line)
439{
440#ifdef SIMULATOR
441 if (debug_wps)
442 {
443 dump_wps_tokens(data);
444 print_line_info(data);
445 print_wps_strings(data);
446#ifdef HAVE_LCD_BITMAP
447 print_img_cond_indexes(data);
448#endif
449 }
450#endif /* SIMULATOR */
451
452 if (fail)
453 {
454 DEBUGF("Failed parsing on line %d : ", line);
455 switch (fail)
456 {
457 case PARSE_FAIL_UNCLOSED_COND:
458 DEBUGF("Unclosed conditional");
459 break;
460
461 case PARSE_FAIL_INVALID_CHAR:
462 DEBUGF("Invalid conditional char (not in an open conditional)");
463 break;
464
465 case PARSE_FAIL_COND_SYNTAX_ERROR:
466 DEBUGF("Conditional syntax error");
467 break;
468 }
469 DEBUGF("\n");
470 }
471}
472
430#endif /* DEBUG */ 473#endif /* DEBUG */
diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c
index d3e8454737..ec98d95ee4 100644
--- a/apps/gui/wps_parser.c
+++ b/apps/gui/wps_parser.c
@@ -69,11 +69,8 @@ static const char *backdrop_bmp_name;
69#endif 69#endif
70 70
71#ifdef DEBUG 71#ifdef DEBUG
72/* debugging functions */ 72/* debugging function */
73extern void dump_wps_tokens(struct wps_data *data); 73extern void print_debug_info(struct wps_data *data, int fail, int line);
74extern void print_line_info(struct wps_data *data);
75extern void print_img_cond_indexes(struct wps_data *data);
76extern void print_wps_strings(struct wps_data *data);
77#endif 74#endif
78 75
79static void wps_reset(struct wps_data *data); 76static void wps_reset(struct wps_data *data);
@@ -795,36 +792,8 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr)
795 } 792 }
796 793
797#ifdef DEBUG 794#ifdef DEBUG
798 795 print_debug_info(data, fail, line);
799#if 0 /* optional debugging code */
800 dump_wps_tokens(data);
801 print_line_info(data);
802 print_wps_strings(data);
803#ifdef HAVE_LCD_BITMAP
804 print_img_cond_indexes(data);
805#endif 796#endif
806#endif
807
808 if (fail)
809 {
810 DEBUGF("Failed parsing on line %d : ", line);
811 switch (fail)
812 {
813 case PARSE_FAIL_UNCLOSED_COND:
814 DEBUGF("Unclosed conditional");
815 break;
816
817 case PARSE_FAIL_INVALID_CHAR:
818 DEBUGF("Invalid conditional char (not in an open conditional)");
819 break;
820
821 case PARSE_FAIL_COND_SYNTAX_ERROR:
822 DEBUGF("Conditional syntax error");
823 break;
824 }
825 DEBUGF("\n");
826 }
827#endif /* DEBUG */
828 797
829 if (fail) 798 if (fail)
830 wps_reset(data); 799 wps_reset(data);