forked from len0rd/rockbox
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
This commit is contained in:
parent
4ddc764a7c
commit
6ac306a515
3 changed files with 58 additions and 40 deletions
|
|
@ -24,11 +24,19 @@
|
||||||
#include "gwps.h"
|
#include "gwps.h"
|
||||||
#include "debug.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) {
|
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;
|
struct wps_token *token;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
@ -358,7 +366,7 @@ void dump_wps_tokens(struct wps_data *data)
|
||||||
DEBUGF("\n");
|
DEBUGF("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_line_info(struct wps_data *data)
|
static void print_line_info(struct wps_data *data)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
struct wps_line *line;
|
struct wps_line *line;
|
||||||
|
|
@ -395,7 +403,7 @@ void print_line_info(struct wps_data *data)
|
||||||
DEBUGF("\n");
|
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;
|
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
|
#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");
|
DEBUGF("Image conditional indexes:\n");
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -427,4 +435,39 @@ void print_img_cond_indexes(struct wps_data *data)
|
||||||
}
|
}
|
||||||
#endif /*HAVE_LCD_BITMAP */
|
#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 */
|
#endif /* DEBUG */
|
||||||
|
|
|
||||||
|
|
@ -69,11 +69,8 @@ static const char *backdrop_bmp_name;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
/* debugging functions */
|
/* debugging function */
|
||||||
extern void dump_wps_tokens(struct wps_data *data);
|
extern void print_debug_info(struct wps_data *data, int fail, int line);
|
||||||
extern void print_line_info(struct wps_data *data);
|
|
||||||
extern void print_img_cond_indexes(struct wps_data *data);
|
|
||||||
extern void print_wps_strings(struct wps_data *data);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void wps_reset(struct wps_data *data);
|
static void wps_reset(struct wps_data *data);
|
||||||
|
|
@ -795,36 +792,8 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
print_debug_info(data, fail, line);
|
||||||
#if 0 /* optional debugging code */
|
|
||||||
dump_wps_tokens(data);
|
|
||||||
print_line_info(data);
|
|
||||||
print_wps_strings(data);
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
|
||||||
print_img_cond_indexes(data);
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
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 */
|
|
||||||
|
|
||||||
if (fail)
|
if (fail)
|
||||||
wps_reset(data);
|
wps_reset(data);
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,8 @@ char having_new_lcd = true; /* Used for player simulator */
|
||||||
|
|
||||||
bool debug_audio = false;
|
bool debug_audio = false;
|
||||||
|
|
||||||
|
bool debug_wps = false;
|
||||||
|
|
||||||
long start_tick;
|
long start_tick;
|
||||||
|
|
||||||
Uint32 tick_timer(Uint32 interval, void *param)
|
Uint32 tick_timer(Uint32 interval, void *param)
|
||||||
|
|
@ -200,6 +202,9 @@ int main(int argc, char *argv[])
|
||||||
if (!strcmp("--debugaudio", argv[x])) {
|
if (!strcmp("--debugaudio", argv[x])) {
|
||||||
debug_audio = true;
|
debug_audio = true;
|
||||||
printf("Writing debug audio file.\n");
|
printf("Writing debug audio file.\n");
|
||||||
|
} else if (!strcmp("--debugwps", argv[x])) {
|
||||||
|
debug_wps = true;
|
||||||
|
printf("WPS debug mode enabled.\n");
|
||||||
} else if (!strcmp("--background", argv[x])) {
|
} else if (!strcmp("--background", argv[x])) {
|
||||||
background = true;
|
background = true;
|
||||||
printf("Using background image.\n");
|
printf("Using background image.\n");
|
||||||
|
|
@ -217,9 +222,10 @@ int main(int argc, char *argv[])
|
||||||
printf("rockboxui\n");
|
printf("rockboxui\n");
|
||||||
printf("Arguments:\n");
|
printf("Arguments:\n");
|
||||||
printf(" --debugaudio \t Write raw PCM data to audiodebug.raw\n");
|
printf(" --debugaudio \t Write raw PCM data to audiodebug.raw\n");
|
||||||
|
printf(" --debugwps \t Print advanced WPS debug info\n");
|
||||||
printf(" --background \t Use background image of hardware\n");
|
printf(" --background \t Use background image of hardware\n");
|
||||||
printf(" --old_lcd \t [Player] simulate old playermodel (ROM version<4.51)\n");
|
printf(" --old_lcd \t [Player] simulate old playermodel (ROM version<4.51)\n");
|
||||||
printf(" --zoom \t window zoom (will disable backgrounds)\n");
|
printf(" --zoom [VAL]\t window zoom (will disable backgrounds)\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue