diff options
| author | Damien George <damien@micropython.org> | 2024-03-07 11:38:27 +1100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-06-21 16:21:27 +1000 |
| commit | 9dbc787ce8dda9df39eb68c03de144155b2253f0 (patch) | |
| tree | f05e960eb7f1bc173570c2bca0901524ed813407 /mpy-cross/main.c | |
| parent | e2ae03e97963c2d338752bc4cbe8bd87981014fb (diff) | |
py/emitndebug: Add native debug emitter.
This emitter prints out pseudo-machine instructions, instead of the usual
output of the native emitter. It can be enabled on any port via
`MICROPY_EMIT_NATIVE_DEBUG` (make sure other native emitters are disabled)
but the easiest way to use it is with mpy-cross:
$ mpy-cross -march=debug file.py
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'mpy-cross/main.c')
| -rw-r--r-- | mpy-cross/main.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/mpy-cross/main.c b/mpy-cross/main.c index a9066215d..72b6e10fc 100644 --- a/mpy-cross/main.c +++ b/mpy-cross/main.c @@ -54,7 +54,7 @@ static void stdout_print_strn(void *env, const char *str, size_t len) { (void)dummy; } -static const mp_print_t mp_stdout_print = {NULL, stdout_print_strn}; +const mp_print_t mp_stdout_print = {NULL, stdout_print_strn}; static void stderr_print_strn(void *env, const char *str, size_t len) { (void)env; @@ -130,7 +130,7 @@ static int usage(char **argv) { "Target specific options:\n" "-msmall-int-bits=number : set the maximum bits used to encode a small-int\n" "-march=<arch> : set architecture for native emitter;\n" - " x86, x64, armv6, armv6m, armv7m, armv7em, armv7emsp, armv7emdp, xtensa, xtensawin, rv32imc\n" + " x86, x64, armv6, armv6m, armv7m, armv7em, armv7emsp, armv7emdp, xtensa, xtensawin, rv32imc, debug\n" "\n" "Implementation specific options:\n", argv[0] ); @@ -316,6 +316,9 @@ MP_NOINLINE int main_(int argc, char **argv) { } else if (strcmp(arch, "rv32imc") == 0) { mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_RV32IMC; mp_dynamic_compiler.nlr_buf_num_regs = MICROPY_NLR_NUM_REGS_RV32I; + } else if (strcmp(arch, "debug") == 0) { + mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_DEBUG; + mp_dynamic_compiler.nlr_buf_num_regs = 0; } else if (strcmp(arch, "host") == 0) { #if defined(__i386__) || defined(_M_IX86) mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_X86; |
