Implement Debugger Locals (_raised_ and _returned_)
#397
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I want to introduce a new concept called
Debugger locals. The 2 I introduced in this PR are:_raised_- stores the last raised exception (after a catch breakpoint being triggered)_returned_- stores the last returned value (after a normal breakpoint being triggered on method return)They're designed to help pass values between breakpoint and commands. For example:
catch Exception do: trace object _raised_- pass caught exception to object tracer (super handy)b FILE:line do: p _returned_- evaluate a method's return value without stopping the programThey only exist in debugger's REPL and commands. And they won't affect user program's binding and are not accessible from user program.
Because it could be hard to correctly anticipate when those values are stored (especially
_returned_), I think they should always exist with a default valuenilinstead of causingNameErrorwhen called unexpectedly.Regarding the names, I think they can still be changed. But I don't want to use longer names like
raised_exception, as it'll be too lengthy to type in the REPL. Also, since the variables have underscore for both prefix and postfix, I think the chance of this to happen is extremely low.