diff --git a/lib/exec.c b/lib/exec.c index 030499a..3636426 100644 --- a/lib/exec.c +++ b/lib/exec.c @@ -45,7 +45,9 @@ static HAK_INLINE const char* proc_state_to_string (int state) return str[state + 1]; } -static hak_ooch_t oocstr_dash[] = { '-', '\0' }; +static hak_ooch_t oocstr_colon[2] = { ':', '\0' }; +static hak_ooch_t oocstr_dash[2] = { '-', '\0' }; +static hak_ooch_t oocstr_none[1] = { '\0' }; #define PROC_MAP_INC 64 @@ -2414,34 +2416,37 @@ static HAK_INLINE int do_throw (hak_t* hak, hak_oop_t val, hak_ooi_t ip) /* output backtrace */ HAK_LOG0(hak, HAK_LOG_IC | HAK_LOG_INFO, "[BACKTRACE]\n"); c = hak->active_context; - while ((hak_oop_t)c != hak->_nil) + if ((hak_oop_t)c != hak->_nil) { - f = c->base; - if (f->dbgi != hak->_nil) + hak_ooi_t cip; + + cip = ip; /* use the given ip for the active context instead of the value from the ip field */ + do { - static hak_ooch_t none[1] = { '\0' }; - static hak_ooch_t colon[2] = { ':', '\0' }; + f = c->base; + if (f->dbgi != hak->_nil) + { + hak_dbgi_t* dbgi; + hak_loc_t loc; - hak_dbgi_t* dbgi; - hak_loc_t loc; - hak_ooi_t cip; + dbgi = (hak_dbgi_t*)HAK_OBJ_GET_BYTE_SLOT(f->dbgi); + HAK_MEMSET(&loc, 0, HAK_SIZEOF(loc)); + loc.file = dbgi[cip].fname; + loc.line = dbgi[cip].sline; - /* use the given ip for the active context instead of the value from the ip field */ - cip = (c == hak->active_context)? ip: HAK_OOP_TO_SMOOI(c->ip); - dbgi = (hak_dbgi_t*)HAK_OBJ_GET_BYTE_SLOT(f->dbgi); - HAK_MEMSET(&loc, 0, HAK_SIZEOF(loc)); - loc.file = dbgi[cip].fname; - loc.line = dbgi[cip].sline; - - HAK_LOG7(hak, HAK_LOG_IC | HAK_LOG_INFO, " %.*js%js%.*js(%js:%zu)\n", - (c->owner == hak->_nil? 0: HAK_OBJ_GET_SIZE(((hak_oop_class_t)c->owner)->name)), - (c->owner == hak->_nil? none: ((hak_oop_char_t)((hak_oop_class_t)c->owner)->name)->slot), - (c->owner == hak->_nil? none: colon), - (c->owner == hak->_nil? 0: HAK_OBJ_GET_SIZE(((hak_oop_char_t)c->name))), - (c->name == hak->_nil? none: ((hak_oop_char_t)c->name)->slot), - (dbgi[cip].fname? dbgi[ip].fname: oocstr_dash), dbgi[cip].sline); - } - c = c->sender; + /* TODO: include arguments? */ + HAK_LOG7(hak, HAK_LOG_IC | HAK_LOG_INFO, " %.*js%js%.*js(%js:%zu)\n", + (c->owner == hak->_nil? 0: HAK_OBJ_GET_SIZE(((hak_oop_class_t)c->owner)->name)), + (c->owner == hak->_nil? oocstr_none: ((hak_oop_char_t)((hak_oop_class_t)c->owner)->name)->slot), + (c->owner == hak->_nil? oocstr_none: oocstr_colon), + (c->name == hak->_nil? 0: HAK_OBJ_GET_SIZE(((hak_oop_char_t)c->name))), + (c->name == hak->_nil? oocstr_none: ((hak_oop_char_t)c->name)->slot), + (dbgi[cip].fname? dbgi[ip].fname: oocstr_dash), dbgi[cip].sline); + } + c = c->sender; + if ((hak_oop_t)c == hak->_nil) break; + cip = HAK_OOP_TO_SMOOI(c->ip); + } while (1); } /* exception not handled. terminate the active process */ diff --git a/lib/std.c b/lib/std.c index cd36cc0..ce11627 100644 --- a/lib/std.c +++ b/lib/std.c @@ -4150,7 +4150,6 @@ hak_t* hak_openstd (hak_oow_t xtnsize, hak_errnum_t* errnum) return hak_openstdwithmmgr(&sys_mmgr, xtnsize, errnum); } - /* --------------------------------------------------------------------- */ diff --git a/src/kernel.hak b/src/kernel.hak index 9cf17f0..8fbad55 100644 --- a/src/kernel.hak +++ b/src/kernel.hak @@ -166,9 +166,16 @@ printf "%O\n" (k:basicAt 20) } } +fun c() { + (Q:k) +} ##try { printf ">>>>>>>>>>>>>>>\n" - (Q:k) + + fun j(){ + (c) + } + (j) ##} catch (e) { printf "EXCEPTION: %O\n" e