py/mpconfig.h: Introduce MICROPY_DEBUG_PRINTER for debugging output.

This patch in effect renames MICROPY_DEBUG_PRINTER_DEST to
MICROPY_DEBUG_PRINTER, moving its default definition from
lib/utils/printf.c to py/mpconfig.h to make it official and documented, and
makes this macro a pointer rather than the actual mp_print_t struct.  This
is done to get consistency with MICROPY_ERROR_PRINTER, and provide this
macro for use outside just lib/utils/printf.c.

Ports are updated to use the new macro name.
pull/1/head
Damien George 2018-08-02 14:04:44 +10:00
parent 0c161691b4
commit da2d2b6d88
6 changed files with 13 additions and 9 deletions

View File

@ -41,11 +41,7 @@
int DEBUG_printf(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
#ifndef MICROPY_DEBUG_PRINTER_DEST
#define MICROPY_DEBUG_PRINTER_DEST mp_plat_print
#endif
extern const mp_print_t MICROPY_DEBUG_PRINTER_DEST;
int ret = mp_vprintf(&MICROPY_DEBUG_PRINTER_DEST, fmt, ap);
int ret = mp_vprintf(MICROPY_DEBUG_PRINTER, fmt, ap);
va_end(ap);
return ret;
}

View File

@ -172,7 +172,7 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args);
int DEBUG_printf(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
int ret = mp_vprintf(&MICROPY_DEBUG_PRINTER_DEST, fmt, ap);
int ret = mp_vprintf(MICROPY_DEBUG_PRINTER, fmt, ap);
va_end(ap);
return ret;
}

View File

@ -13,8 +13,8 @@
#define MICROPY_EMIT_XTENSA (1)
#define MICROPY_EMIT_INLINE_XTENSA (1)
#define MICROPY_MEM_STATS (0)
#define MICROPY_DEBUG_PRINTER (&mp_debug_print)
#define MICROPY_DEBUG_PRINTERS (1)
#define MICROPY_DEBUG_PRINTER_DEST mp_debug_print
#define MICROPY_READER_VFS (MICROPY_VFS)
#define MICROPY_ENABLE_GC (1)
#define MICROPY_ENABLE_FINALISER (1)
@ -145,6 +145,9 @@ typedef uint32_t sys_prot_t; // for modlwip
void *esp_native_code_commit(void*, size_t);
#define MP_PLAT_COMMIT_EXEC(buf, len) esp_native_code_commit(buf, len)
// printer for debugging output, goes to UART only
extern const struct _mp_print_t mp_debug_print;
#define mp_type_fileio mp_type_vfs_fat_fileio
#define mp_type_textio mp_type_vfs_fat_textio

View File

@ -54,7 +54,7 @@
#define MICROPY_DEBUG_PRINTERS (1)
// Printing debug to stderr may give tests which
// check stdout a chance to pass, etc.
#define MICROPY_DEBUG_PRINTER_DEST mp_stderr_print
#define MICROPY_DEBUG_PRINTER (&mp_stderr_print)
#define MICROPY_READER_POSIX (1)
#define MICROPY_USE_READLINE_HISTORY (1)
#define MICROPY_HELPER_REPL (1)

View File

@ -45,8 +45,8 @@
#define MICROPY_STACK_CHECK (1)
#define MICROPY_MALLOC_USES_ALLOCATED_SIZE (1)
#define MICROPY_MEM_STATS (1)
#define MICROPY_DEBUG_PRINTER (&mp_stderr_print)
#define MICROPY_DEBUG_PRINTERS (1)
#define MICROPY_DEBUG_PRINTER_DEST mp_stderr_print
#define MICROPY_READER_POSIX (1)
#define MICROPY_USE_READLINE_HISTORY (1)
#define MICROPY_HELPER_REPL (1)

View File

@ -366,6 +366,11 @@
#define MICROPY_MEM_STATS (0)
#endif
// The mp_print_t printer used for debugging output
#ifndef MICROPY_DEBUG_PRINTER
#define MICROPY_DEBUG_PRINTER (&mp_plat_print)
#endif
// Whether to build functions that print debugging info:
// mp_bytecode_print
// mp_parse_node_print