enhanced the backtrace output loop
This commit is contained in:
29
lib/exec.c
29
lib/exec.c
@ -45,7 +45,9 @@ static HAK_INLINE const char* proc_state_to_string (int state)
|
|||||||
return str[state + 1];
|
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
|
#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 */
|
/* output backtrace */
|
||||||
HAK_LOG0(hak, HAK_LOG_IC | HAK_LOG_INFO, "[BACKTRACE]\n");
|
HAK_LOG0(hak, HAK_LOG_IC | HAK_LOG_INFO, "[BACKTRACE]\n");
|
||||||
c = hak->active_context;
|
c = hak->active_context;
|
||||||
while ((hak_oop_t)c != hak->_nil)
|
if ((hak_oop_t)c != 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
|
||||||
{
|
{
|
||||||
f = c->base;
|
f = c->base;
|
||||||
if (f->dbgi != hak->_nil)
|
if (f->dbgi != hak->_nil)
|
||||||
{
|
{
|
||||||
static hak_ooch_t none[1] = { '\0' };
|
|
||||||
static hak_ooch_t colon[2] = { ':', '\0' };
|
|
||||||
|
|
||||||
hak_dbgi_t* dbgi;
|
hak_dbgi_t* dbgi;
|
||||||
hak_loc_t loc;
|
hak_loc_t loc;
|
||||||
hak_ooi_t cip;
|
|
||||||
|
|
||||||
/* 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);
|
dbgi = (hak_dbgi_t*)HAK_OBJ_GET_BYTE_SLOT(f->dbgi);
|
||||||
HAK_MEMSET(&loc, 0, HAK_SIZEOF(loc));
|
HAK_MEMSET(&loc, 0, HAK_SIZEOF(loc));
|
||||||
loc.file = dbgi[cip].fname;
|
loc.file = dbgi[cip].fname;
|
||||||
loc.line = dbgi[cip].sline;
|
loc.line = dbgi[cip].sline;
|
||||||
|
|
||||||
|
/* TODO: include arguments? */
|
||||||
HAK_LOG7(hak, HAK_LOG_IC | HAK_LOG_INFO, " %.*js%js%.*js(%js:%zu)\n",
|
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? 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? oocstr_none: ((hak_oop_char_t)((hak_oop_class_t)c->owner)->name)->slot),
|
||||||
(c->owner == hak->_nil? none: colon),
|
(c->owner == hak->_nil? oocstr_none: oocstr_colon),
|
||||||
(c->owner == hak->_nil? 0: HAK_OBJ_GET_SIZE(((hak_oop_char_t)c->name))),
|
(c->name == 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),
|
(c->name == hak->_nil? oocstr_none: ((hak_oop_char_t)c->name)->slot),
|
||||||
(dbgi[cip].fname? dbgi[ip].fname: oocstr_dash), dbgi[cip].sline);
|
(dbgi[cip].fname? dbgi[ip].fname: oocstr_dash), dbgi[cip].sline);
|
||||||
}
|
}
|
||||||
c = c->sender;
|
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 */
|
/* exception not handled. terminate the active process */
|
||||||
|
@ -4150,7 +4150,6 @@ hak_t* hak_openstd (hak_oow_t xtnsize, hak_errnum_t* errnum)
|
|||||||
return hak_openstdwithmmgr(&sys_mmgr, xtnsize, errnum);
|
return hak_openstdwithmmgr(&sys_mmgr, xtnsize, errnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
@ -166,9 +166,16 @@ printf "%O\n" (k:basicAt 20)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun c() {
|
||||||
|
(Q:k)
|
||||||
|
}
|
||||||
##try {
|
##try {
|
||||||
printf ">>>>>>>>>>>>>>>\n"
|
printf ">>>>>>>>>>>>>>>\n"
|
||||||
(Q:k)
|
|
||||||
|
fun j(){
|
||||||
|
(c)
|
||||||
|
}
|
||||||
|
(j)
|
||||||
##} catch (e) {
|
##} catch (e) {
|
||||||
printf "EXCEPTION: %O\n" e
|
printf "EXCEPTION: %O\n" e
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user