take a look at sq_stackinfos() and sq_getlocal().
for an example look in sqstdaux.cpp/sqstd_printcallstack()
ciao
Alberto