1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-08 19:43:41 +00:00

Add support for debugging upvalues.

Upvalues are stored in the symbol slots structure as well, but
since they are always live, we repurpose the death_pc field to
refer to the environment index that we want to look at at runtime.
This commit is contained in:
Calvin Rose
2023-02-05 15:27:39 -06:00
parent c7fb7b4451
commit 7a1c9c7798
5 changed files with 63 additions and 14 deletions

View File

@@ -2767,12 +2767,6 @@
(put nextenv :debug-level level)
(put nextenv :signal (fiber/last-value fiber))
# define variables available at breakpoint
(def frame ((debug/stack fiber) 0))
(def pc (frame :pc))
(eachp [local value] (get frame :locals)
(put nextenv local @{:value value}))
(merge-into nextenv debugger-env)
(defn debugger-chunks [buf p]
(def status (:state p :delimiters))
@@ -3381,11 +3375,16 @@
(print))
(defn .frame
"Show a stack frame."
"Show a stack frame"
[&opt n]
(def stack (debug/stack (.fiber)))
(in stack (or n 0)))
(defn .locals
"Show local bindings"
[&opt n]
(get (.frame n) :locals))
(defn .fn
"Get the current function."
[&opt n]