feat(debugger): evaluate snippets like a REPL entry #400
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/39-evaluate-snippet"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #39
What
In the debug console (
evaluatewithcontext: repl), a text the restricted evaluator (parseWatch) refuses is now compiled as a snippet and run in the stopped program:names.length(),point.distance(origin),double(count). Hover, watch, clipboard, logpoints and conditions keep the read-only evaluator.compiler/src/debugger/snippet.trb(new): the frame's file with its statements blanked, plus one hosted function whose parameters are the frame's locals that the expression names (written with the type textvariablesshows, except a list, map or set the frame holds as storage, which is written as its implementationArrayList,TrieMap,TrieSet- the trait would be a boxed payload and crashed the debuggee) and whose body is the expression; the value leaves through avarparameter. A local whose type the file cannot write answers<name> is not available in the snippet. Compile errors are rendered relative to the snippet.growProgram,emitBytecodewithafter) and called above every frame of the stop (callSandboxedwith the newaboveparameter, same forreleaseSandboxed), in an unrestricted sandbox with a budget of 100M steps / 10 s. A panic,Process.exitor a limit answerssuccess: false; the program stays stopped and intact.torbscript/snippetBegin/torbscript/snippetEnd, which the adapter consumes.variablesshows a value (result,type,variablesReference); references into it read through the snippet's own inspector (Referenced.Childrennow carries one). Result registers are released when the program goes on.Refactors shared with the REPL / VM
repl/session.trb:importsOfandaddImportsare public (the snippet writes the result type the way an entry does).vm/interpret.trb:callSandboxed/releaseSandboxedtakeabove; newgrowProgramandrunningProgram.vm/run.trb:PreparedRuncarries the program'sSourceTree.Tests
Session
tests/debug/evaluate-snippet.dap(+ program dir): method call, function call, call on a shared object (state kept across two calls), output of the snippet, panic, compile errors, unavailable name, a list result, and a hover that stays on the restricted path;variablesbefore and after. Sessiontests/debug/evaluate-snippet-collections.dapcovers a snippet naming a list, a map and a set local (the crash class of the first version). Both.expectedfiles are the output of complete sessions. DEBUGGER.md sections 12, 15, 20 updated. Sessions and gates run in CI.32a37c9eb3a86daa868cReview of
a86daa8. CI is final and red (ci / tier A (linux-x64)->gates); the log shows a real defect, not only a missing fixture.tests/debugforevaluate-snippetends after request 9 (the hovernames.length(), correctly refused by the restricted evaluator) with{"event":"exited","body":{"exitCode":139}}(SIGSEGV), thenterminated. Request 10 (names.length(),context: repl) never gets a response, and nothing after it (point.distance, double, counter, shout, explode, compile error, unavailable name, list result) was exercised. The claim "the program stays stopped and intact" does not hold for the happy path. Likely area: the newgrowProgram/callSandboxed(above)path invm/interpret.trbor the continuation indebugger/snippet.trbon the real debuggee. Please reproduce withtorb debugontests/debug/evaluate-snippet, fix the crash, and make sure every request of the session gets its response.tests/debug/evaluate-snippet.expectedis still# placeholder: filled from the CI output. Fill it from a run in which the full session completes, and review that content for the intended results (e.g.double(count)= 42, the counter keeping its state across the twobump()calls, the panic/compile-error/unavailable-name messages, the snippet output as console output). Do not paste the current crashed output.format --checkfails:./compiler/src/ir/lower/lower.trb(1 of 1340 files would change). Runtorb formaton it.Checked and fine: scope matches #39 (one expression, innermost frame, no protocol additions, seed untouched, hover/watch/logpoints/conditions stay on the restricted evaluator); DEBUGGER.md updated; pdisc green; no secrets, no new permissions or external services. Once the session passes, the only thing left to look at in the next round is items 1-3.
d46ae94005d57665b22f06566d9c18b78ba7becaReview of
b78ba7b(re-review: checked my earlier blockers froma86daa8and the lines changed since). CI is green on exactly this head, includingtier A,tier B,gates,bootstrap, pdisc.Earlier findings:
continue-> program output ->exited0. The collection crash class is covered by its own session (evaluate-snippet-collections) andfinishLowering(lowering, closed: !debugging)keeps the witness-table slots a snippet calls through..expectedplaceholder: resolved. I checked the content by hand:point.distance(origin)= 25,double(count)= 42,counter.bump()1 then 2 andcounter.hits= 2 (state kept,variablesafter showshits: 2),origin.distance(point) + double(count)= 67,names.map(...)= [3, 5, 5], snippet output arrives as a console event, panic / compile error / unavailable-name messages are relative to<snippet>, hover stays on the restricted path. Collections session: 3, 5, 40, 9 match 3/2/4 elements.format --check: resolved (gates green).Checklist: tests match the change (two complete sessions); correctness ok; scope = #39 (one expression, innermost frame, no protocol additions, seed untouched); no secrets/permissions/external services; no stored-data change; DEBUGGER.md sections 12/15/20 updated; no workflow changes; no new boundary beyond the internal
aboveparameter andgrowProgram, documented in the design doc.Non-blocking: none.