#ifndef __NASAL_DBG_H__ #define __NASAL_DBG_H__ #include "nasal_err.h" #include "nasal_vm.h" #include class debugger:public vm { private: bool next; usize fsize; u16 bk_fidx; u32 bk_line; error& src; std::vector parse(const string&); u16 fileindex(const string&); void err(); void help(); void callsort(const u64*); void stepinfo(); void interact(); public: debugger(error& err): next(false),fsize(0), bk_fidx(0),bk_line(0), src(err){} void run( const codegen&, const linker&, const std::vector& ); }; std::vector debugger::parse(const string& cmd) { std::vector res; usize last=0,pos=cmd.find(" ",0); while(pos!=string::npos) { if(pos>last) res.push_back(cmd.substr(last,pos-last)); last=pos+1; pos=cmd.find(" ",last); } if(last\n" <<"\th, help | get help\n" <<"\tbt, backtrace | get function call trace\n" <<"\tc, continue | run program until break point or exit\n" <<"\tf, file | see all the compiled files\n" <<"\tg, global | see global values\n" <<"\tl, local | see local values\n" <<"\tu, upval | see upvalue\n" <<"\tr, register | show vm register detail\n" <<"\ta, all | show global,local and upvalue\n" <<"\tn, next | execute next bytecode\n" <<"\tq, exit | exit debugger\n" <<"