Skip to content

Commit 42cf77f

Browse files
committed
py/vm: For tracing use mp_printf, and print state when thread enabled.
mp_printf should be used to print the prefix because it's also used in mp_bytecode_print2 (otherwise, depending on the system, different output streams may be used). Also print the current thread state when threading is enabled to easily see which thread executes what opcode. Signed-off-by: Damien George <damien@micropython.org>
1 parent 6e5aea0 commit 42cf77f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

py/vm.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@
3939
// *FORMAT-OFF*
4040

4141
#if 0
42-
#define TRACE(ip) printf("sp=%d ", (int)(sp - &code_state->state[0] + 1)); mp_bytecode_print2(&mp_plat_print, ip, 1, code_state->fun_bc->const_table);
42+
#if MICROPY_PY_THREAD
43+
#define TRACE_PREFIX mp_printf(&mp_plat_print, "ts=%p sp=%d ", mp_thread_get_state(), (int)(sp - &code_state->state[0] + 1))
44+
#else
45+
#define TRACE_PREFIX mp_printf(&mp_plat_print, "sp=%d ", (int)(sp - &code_state->state[0] + 1))
46+
#endif
47+
#define TRACE(ip) TRACE_PREFIX; mp_bytecode_print2(&mp_plat_print, ip, 1, code_state->fun_bc->const_table);
4348
#else
4449
#define TRACE(ip)
4550
#endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy