From cd808a5e6dc0dfd90454a35cbff70f93843b2816 Mon Sep 17 00:00:00 2001 From: ValKmjolnir Date: Thu, 3 Mar 2022 19:00:23 +0800 Subject: [PATCH] update detailed-info --- makefile | 61 +++++++++++++++++++++++++++-------------------------- nasal_dbg.h | 6 +----- nasal_vm.h | 30 ++++++++++++-------------- 3 files changed, 46 insertions(+), 51 deletions(-) diff --git a/makefile b/makefile index ec37858..408b68c 100644 --- a/makefile +++ b/makefile @@ -2,34 +2,35 @@ nasal:main.cpp nasal_ast.h nasal_err.h nasal_builtin.h nasal_opt.h nasal_codegen.h nasal_gc.h nasal_import.h nasal_lexer.h nasal_parse.h nasal_vm.h nasal_dbg.h nasal.h clang++ -std=c++11 -O3 main.cpp -o nasal -fno-exceptions -ldl -Wshadow -Wall test:nasal - ./nasal -op -e test/ascii-art.nas - ./nasal -op -c test/bf.nas - ./nasal -op -c test/bfcolored.nas - ./nasal -op -c test/bfconvertor.nas - ./nasal -op -e -d test/bfs.nas - ./nasal -op -t test/bigloop.nas - ./nasal -op -e test/bp.nas - ./nasal -op -e -d test/calc.nas - ./nasal -op -e test/choice.nas - ./nasal -op -e test/class.nas - ./nasal -op -c test/exception.nas - ./nasal -op -t -d test/fib.nas - ./nasal -op -e test/filesystem.nas - ./nasal -op -e -d test/hexdump.nas - ./nasal -op -e test/json.nas - ./nasal -op -e test/leetcode1319.nas - ./nasal -op -e -d test/lexer.nas - ./nasal -op -e -d test/life.nas - ./nasal -op -t test/loop.nas - ./nasal -op -t -d test/mandel.nas - ./nasal -op -t -d test/mandelbrot.nas - ./nasal -op -c test/module_test.nas - ./nasal -op -e test/nasal_test.nas - ./nasal -op -t -d test/pi.nas - ./nasal -op -t -d test/prime.nas - ./nasal -op -t -d test/quick_sort.nas - ./nasal -op -e test/scalar.nas - ./nasal -op -e test/trait.nas - ./nasal -op -t -d test/turingmachine.nas - ./nasal -op -t -d -o test/ycombinator.nas + @ ./nasal -op -e test/ascii-art.nas + @ ./nasal -op -c test/bf.nas + @ ./nasal -op -c test/bfcolored.nas + @ ./nasal -op -c test/bfconvertor.nas + @ ./nasal -op -e -d test/bfs.nas + @ ./nasal -op -t test/bigloop.nas + @ ./nasal -op -e test/bp.nas + @ ./nasal -op -e -d test/calc.nas + @ ./nasal -op -e test/choice.nas + @ ./nasal -op -e test/class.nas + -@ ./nasal -op -d test/exception.nas + @ ./nasal -op -t -d test/fib.nas + @ ./nasal -op -e test/filesystem.nas + @ ./nasal -op -e -d test/hexdump.nas + @ ./nasal -op -e test/json.nas + @ ./nasal -op -e test/leetcode1319.nas + @ ./nasal -op -e -d test/lexer.nas + @ ./nasal -op -e -d test/life.nas + @ ./nasal -op -t test/loop.nas + @ ./nasal -op -t -d test/mandel.nas + @ ./nasal -op -t -d test/mandelbrot.nas + -@ ./nasal -op -d test/module_test.nas + @ ./nasal -op -e test/nasal_test.nas + @ ./nasal -op -t -d test/pi.nas + @ ./nasal -op -t -d test/prime.nas + @ ./nasal -op -t -d test/quick_sort.nas + @ ./nasal -op -e test/scalar.nas + @ ./nasal -op -e test/trait.nas + -@ ./nasal -op -t test/tetris.nas + @ ./nasal -op -t -d test/turingmachine.nas + @ ./nasal -op -t -d -o test/ycombinator.nas \ No newline at end of file diff --git a/nasal_dbg.h b/nasal_dbg.h index 7f9f1a9..1542783 100644 --- a/nasal_dbg.h +++ b/nasal_dbg.h @@ -136,11 +136,7 @@ void nasal_dbg::interact() else if(res[0]=="u" || res[0]=="upval") upval_state(); else if(res[0]=="a" || res[0]=="all") - { - global_state(); - local_state(); - upval_state(); - } + detail(); else if(res[0]=="n" || res[0]=="next") { next_step=true; diff --git a/nasal_vm.h b/nasal_vm.h index 1b59faf..d397346 100644 --- a/nasal_vm.h +++ b/nasal_vm.h @@ -137,6 +137,7 @@ void nasal_vm::init( files_size=filenames.size(); /* set canary and program counter */ canary=gc.stack+STACK_MAX_DEPTH-1; + mem_addr=nullptr; pc=0; } void nasal_vm::valinfo(nasal_ref& val) @@ -215,12 +216,13 @@ void nasal_vm::stackinfo(const uint32_t limit=10) uint32_t global_size=bytecode[0].num; // bytecode[0] is op_intg nasal_ref* top=gc.top; nasal_ref* bottom=gc.stack+global_size; + printf("vm stack(0x%lx, limit %d, total ",(uint64_t)bottom,global_size,limit); if(top=bottom;++i,--top) { printf("0x%.8lx",top-gc.stack); @@ -230,11 +232,8 @@ void nasal_vm::stackinfo(const uint32_t limit=10) void nasal_vm::global_state() { if(!bytecode[0].num || gc.stack[0].type==vm_none) // bytecode[0].op is op_intg - { - printf("no global value exists\n"); return; - } - printf("global(base %p):\n",gc.stack); + printf("global(0x%lx):\n",(uint64_t)gc.stack); for(uint32_t i=0;ilsize) - { - printf("no local value exists\n"); return; - } - printf("local(base %p):\n",lstk.top()); + printf("local(0x%lx):\n",(uint64_t)lstk.top(),lstk.top()-gc.stack); for(uint32_t i=0;ilsize;++i) { printf("0x%.8x",i); @@ -258,10 +254,7 @@ void nasal_vm::local_state() void nasal_vm::upval_state() { if(fstk.empty() || fstk.top()->upvalue.empty()) - { - printf("no upvalue exists\n"); return; - } printf("upvalue:\n"); auto& upval=fstk.top()->upvalue; for(uint32_t i=0;i