mirror of
https://github.com/janet-lang/janet
synced 2024-12-26 08:20:27 +00:00
Update sample debugger.
Add .break and .step.
This commit is contained in:
parent
6988fd3cab
commit
a0a980e0ef
@ -52,7 +52,6 @@
|
|||||||
(def func (frame :function))
|
(def func (frame :function))
|
||||||
(disasm func))
|
(disasm func))
|
||||||
|
|
||||||
|
|
||||||
(defn .bytecode
|
(defn .bytecode
|
||||||
"Get the bytecode for the current function."
|
"Get the bytecode for the current function."
|
||||||
[&opt n]
|
[&opt n]
|
||||||
@ -113,10 +112,19 @@
|
|||||||
(debug/unfbreak fun i))
|
(debug/unfbreak fun i))
|
||||||
(print "Cleared " (length bytecode) " breakpoints in " fun))
|
(print "Cleared " (length bytecode) " breakpoints in " fun))
|
||||||
|
|
||||||
|
(defn .break
|
||||||
|
"Set breakpoint at the current pc."
|
||||||
|
[]
|
||||||
|
(def frame (.frame))
|
||||||
|
(def fun (frame :function))
|
||||||
|
(def pc (frame :pc))
|
||||||
|
(debug/fbreak fun pc)
|
||||||
|
(print "Set breakpoint in " fun " at pc=" pc))
|
||||||
|
|
||||||
(defn .clear
|
(defn .clear
|
||||||
"Clear the current breakpoint"
|
"Clear the current breakpoint"
|
||||||
[]
|
[]
|
||||||
(def frame (-> (.fiber) debug/stack first))
|
(def frame (.frame))
|
||||||
(def fun (frame :function))
|
(def fun (frame :function))
|
||||||
(def pc (frame :pc))
|
(def pc (frame :pc))
|
||||||
(debug/unfbreak fun pc)
|
(debug/unfbreak fun pc)
|
||||||
@ -135,3 +143,11 @@
|
|||||||
[&opt n]
|
[&opt n]
|
||||||
(.clear)
|
(.clear)
|
||||||
(.next n))
|
(.next n))
|
||||||
|
|
||||||
|
(defn .step
|
||||||
|
"Execute the next n instructions."
|
||||||
|
[&opt n]
|
||||||
|
(var res nil)
|
||||||
|
(for i 0 (or n 1)
|
||||||
|
(set res (debug/step (.fiber))))
|
||||||
|
res)
|
||||||
|
Loading…
Reference in New Issue
Block a user