summaryrefslogtreecommitdiffstatshomepage
path: root/unix
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-01-19 11:48:48 +0000
committerDamien George <damien.p.george@gmail.com>2014-01-19 11:48:48 +0000
commitcbd2f7482c8bf457cc17da763859dbba6e03e2a2 (patch)
tree8d6badc4197fe0d5763d381dd97586176db9fbae /unix
parente02b2d43912d13d216936786e4b7a33918877418 (diff)
downloadmicropython-cbd2f7482c8bf457cc17da763859dbba6e03e2a2.tar.gz
micropython-cbd2f7482c8bf457cc17da763859dbba6e03e2a2.zip
py: Add module/function/class name to exceptions.
Exceptions know source file, line and block name. Also tidy up some debug printing functions and provide a global flag to enable/disable them.
Diffstat (limited to 'unix')
-rw-r--r--unix/main.c14
-rw-r--r--unix/mpconfigport.h2
2 files changed, 9 insertions, 7 deletions
diff --git a/unix/main.c b/unix/main.c
index 39a772d1eb..35fca2059a 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -53,9 +53,11 @@ static void execute_from_lexer(mp_lexer_t *lex, mp_parse_input_kind_t input_kind
qstr source_name = mp_lexer_source_name(lex);
mp_lexer_free(lex);
- //printf("----------------\n");
- //mp_parse_node_show(pn, 0);
- //printf("----------------\n");
+ /*
+ printf("----------------\n");
+ mp_parse_node_print(pn, 0);
+ printf("----------------\n");
+ */
mp_obj_t module_fun = mp_compile(pn, source_name, is_repl);
@@ -73,10 +75,10 @@ static void execute_from_lexer(mp_lexer_t *lex, mp_parse_input_kind_t input_kind
// uncaught exception
mp_obj_t exc = (mp_obj_t)nlr.ret_val;
if (MP_OBJ_IS_TYPE(exc, &exception_type)) {
- qstr file;
+ qstr file, block;
machine_uint_t line;
- mp_obj_exception_get_source_info(exc, &file, &line);
- printf("File \"%s\", line %d\n", qstr_str(file), (int)line);
+ mp_obj_exception_get_source_info(exc, &file, &line, &block);
+ printf("File \"%s\", line %d, in %s\n", qstr_str(file), (int)line, qstr_str(block));
}
mp_obj_print(exc, PRINT_REPR);
printf("\n");
diff --git a/unix/mpconfigport.h b/unix/mpconfigport.h
index b36c171969..10abb8ce75 100644
--- a/unix/mpconfigport.h
+++ b/unix/mpconfigport.h
@@ -9,11 +9,11 @@
#define MICROPY_EMIT_THUMB (0)
#define MICROPY_EMIT_INLINE_THUMB (0)
#define MICROPY_MEM_STATS (1)
+#define MICROPY_DEBUG_PRINTERS (1)
#define MICROPY_ENABLE_REPL_HELPERS (1)
#define MICROPY_ENABLE_LEXER_UNIX (1)
#define MICROPY_ENABLE_FLOAT (1)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_LONGLONG)
-#define MICROPY_SHOW_BC (0)
// type definitions for the specific machine