Commit 6b344d78 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

py, unix: Add -v option, print bytecode dump if used.

This will work if MICROPY_DEBUG_PRINTERS is defined, which is only for
unix/windows ports. This makes it convenient to user uPy normally, but
easily get bytecode dump on the spot if needed, without constant recompiles
back and forth.

TODO: Add more useful debug output, adjust verbosity level on which
specifically bytecode dump happens.
parent 4187068c
......@@ -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
}
......
......@@ -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
......@@ -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 <opt>] [-c <command>] [<filename>]\n"
"usage: %s [<opts>] [-X <implopt>] [-c <command>] [<filename>]\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);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment