diff --git a/debug.h b/debug.h index 0aeed2f..4dec59a 100644 --- a/debug.h +++ b/debug.h @@ -20,6 +20,16 @@ #include #include +#ifdef __DEBUG_LEVEL__ +#undef __DEBUG_LEVEL__ +#endif +/* You can change the debug level here + * 0: no log + * 1: Assert + * 2: Assert + Log + */ +#define __DEBUG_LEVEL__ 9 + // ----------- log ----------- #define ANSI_FG_BLACK "\33[1;30m" @@ -52,10 +62,15 @@ printf(__VA_ARGS__); \ } while (0) +#if __DEBUG_LEVEL__ >= 2 #define Log(format, ...) \ _Log(ANSI_FMT("[%s:%d %s] " format, ANSI_FG_BLUE) "\n", \ __FILE__, __LINE__, __func__, ## __VA_ARGS__) +#else +#define Log(format, ...) (NULL) +#endif +#ifdef __DEBUG_LEVEL__ >= 1 #define Assert(cond, format, ...) \ do { \ if (!(cond)) { \ @@ -64,6 +79,9 @@ assert(cond); \ } \ } while (0) +#else +#define Assert(cond, format, ...) (NULL) +#endif #define panic(format, ...) Assert(0, format, ## __VA_ARGS__) diff --git a/main.c b/main.c index dacd6fe..0b8df29 100644 --- a/main.c +++ b/main.c @@ -45,7 +45,7 @@ static struct { } cmd_table [] = { { "help", "Display information about all supported commands", cmd_help }, { "p", "p EXPR: To evaluate an expression EXPR and output the result", cmd_p }, - { "q", "Exit NEMU", cmd_q }, + { "q", "Exit EXPR", cmd_q }, /* TODO: Add more commands */