diff --git a/py/emitglue.c b/py/emitglue.c index 231e32ac2c..ed3b385d9f 100644 --- a/py/emitglue.c +++ b/py/emitglue.c @@ -96,9 +96,11 @@ void mp_emit_glue_assign_byte_code(mp_raw_code_t *rc, byte *code, uint len, uint DEBUG_printf(" %02x", code[i]); } DEBUG_printf("\n"); -#if MICROPY_DEBUG_PRINTERS - mp_byte_code_print(code, len); #endif +#if MICROPY_DEBUG_PRINTERS + if (mp_verbose_flag > 0) { + mp_byte_code_print(code, len); + } #endif } diff --git a/py/misc.h b/py/misc.h index 0c8161d100..5eb6624095 100644 --- a/py/misc.h +++ b/py/misc.h @@ -156,4 +156,6 @@ void vstr_vprintf(vstr_t *vstr, const char *fmt, va_list ap); // Debugging helpers int DEBUG_printf(const char *fmt, ...); +extern uint mp_verbose_flag; + #endif // _INCLUDED_MINILIB_H diff --git a/unix/main.c b/unix/main.c index d66a68d780..a7e4a907e3 100644 --- a/unix/main.c +++ b/unix/main.c @@ -58,6 +58,7 @@ // Command line options, with their defaults bool compile_only = false; uint emit_opt = MP_EMIT_OPT_NONE; +uint mp_verbose_flag; #if MICROPY_ENABLE_GC // Heap size of GC heap (if enabled) @@ -205,7 +206,9 @@ STATIC void do_str(const char *str) { int usage(char **argv) { printf( -"usage: %s [-X ] [-c ] []\n" +"usage: %s [] [-X ] [-c ] []\n" +"Options:\n" +"-v : verbose (trace various operations); can be multiple\n" "\n" "Implementation specific options:\n", argv[0] ); @@ -371,6 +374,8 @@ int main(int argc, char **argv) { a += 1; } else if (strcmp(argv[a], "-X") == 0) { a += 1; + } else if (strcmp(argv[a], "-v") == 0) { + mp_verbose_flag++; } else { return usage(argv); }