klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

commit d84d257e349626fc7f3197df33f6419c5ffd8340
parent c40010c093384c5c6f5c6855e56438aa29b0e879
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Fri, 29 Apr 2011 17:03:35 -0300

Added some primitive stacktraces.

Diffstat:
Msrc/krepl.c | 22++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/krepl.c b/src/krepl.c @@ -142,7 +142,8 @@ void error_fn(klisp_State *K, TValue *xparams, TValue obj) who_str = "?"; } char *msg = kstring_buf(err_obj->msg); - fprintf(stdout, "\n*ERROR*: %s: %s", who_str, msg); + fprintf(stdout, "\n*ERROR*: \n"); + fprintf(stdout, "%s: %s", who_str, msg); krooted_tvs_push(K, obj); @@ -152,20 +153,33 @@ void error_fn(klisp_State *K, TValue *xparams, TValue obj) fprintf(stdout, ": "); kwrite_display_to_port(K, port, err_obj->irritants, false); } - fprintf(stdout, "\n"); + kwrite_newline_to_port(K, port); +#if KTRACK_NAMES +#if KTRACK_SI /* Location */ /* TODO move to a new function */ /* MAYBE: remove */ if (khas_name(who) || khas_si(who)) { fprintf(stdout, "Location: "); kwrite_display_to_port(K, port, who, false); - fprintf(stdout, "\n"); + kwrite_newline_to_port(K, port); } /* Backtrace */ /* TODO move to a new function */ - + TValue tv_cont = err_obj->cont; + fprintf(stdout, "Backtrace: \n"); + while(ttiscontinuation(tv_cont)) { + kwrite_display_to_port(K, port, tv_cont, false); + kwrite_newline_to_port(K, port); + Continuation *cont = tv2cont(tv_cont); + tv_cont = cont->parent; + } + /* add extra newline at the end */ + kwrite_newline_to_port(K, port); +#endif +#endif krooted_tvs_pop(K); } else { fprintf(stdout, "\n*ERROR*: not an error object passed to "