-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing the debugger "wrong namespace" issues. #433
Conversation
src/cider/nrepl/middleware/debug.clj
Outdated
@@ -189,7 +190,7 @@ this map (identified by a key), and will `dissoc` it afterwards."} | |||
"Like `read`, but reply is sent through `debugger-message`. | |||
type is sent in the message as :input-type." | |||
[extras type prompt] | |||
(let [key (u/random-uuid-str) | |||
(let [key (u/random-uuid-str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think you forgot to turn off your alignment minor mode :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not really a minor mode - just a toggle in clojure-mode
. ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's wrong with this? You don't want aligned key-val pairs in cider projects?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I'm not fond of this style and avoid it everywhere.
Think a note in the changelog for the next cider release would be nice too. I know a lot of people have been tripped up by this one. Great stuff as usual, @vspinu! 👍 |
src/cider/nrepl/middleware/debug.clj
Outdated
@@ -227,18 +237,19 @@ this map (identified by a key), and will `dissoc` it afterwards."} | |||
nil) | |||
(finally | |||
(try | |||
(in-ns ns) | |||
;; Restore original ns in case it was changed by the evaled code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
evaled -> evaluated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was saving few chars not to get into fill.
src/cider/nrepl/middleware/debug.clj
Outdated
:forms @*tmp-forms*}] | ||
`(let [~'META__ {:msg ~(let [{:keys [code id file line column ns]} *msg*] | ||
(-> {:code code, | ||
;; Passing namespace as :original-ns stalls. Bug? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stalls what?
@@ -583,12 +602,7 @@ this map (identified by a key), and will `dissoc` it afterwards."} | |||
(h (maybe-debug msg))) | |||
"debug-instrumented-defs" (instrumented-defs-reply msg) | |||
"debug-input" (when-let [pro (@promises (:key msg))] | |||
(swap! promises dissoc (:key msg)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do those changes fit with the rest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no rest, the only consumer of that promise is the read-debug
itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
src/cider/nrepl/middleware/debug.clj
Outdated
(let [has-debug? (atom false) | ||
;; Don't return nil in reader (https://dev.clojure.org/jira/browse/CLJ-1138) | ||
fake-reader (fn [x] (reset! has-debug? true) x)] | ||
(binding [*ns* (find-ns (symbol (or ns "user"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't really use alignment in bindings in cider-nrepl
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let bindings as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
src/cider/nrepl/middleware/debug.clj
Outdated
(binding [*tmp-locals* locals] | ||
(binding [*tmp-locals* (:locals extras) | ||
;; evaluate in the instrumentation ns | ||
*ns* (find-ns (symbol (:original-ns extras)))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. What will happen if :original-ns
is nil here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:original-ns
can never be nil, it's always assigned in with-initial-debug-bindings
.
src/cider/nrepl/middleware/debug.clj
Outdated
[form locals] | ||
If an exception is thrown, it is caught and sent to the client, and this | ||
function returns nil. `extras` is a metadata map received from `break'." | ||
[form extras] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd name extras
something else - without reading its docstring it was hard for me to figure out what it is. break-state
perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good sugestion. That map contains both current breakpoint state and current debug session state, but I think break-state
is informative of both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe debugger-state
then with two maps inside of it?
src/cider/nrepl/middleware/debug.clj
Outdated
(catch IllegalStateException _)))))) | ||
|
||
(defn- read-debug-eval-expression | ||
"Read and eval an expression from the client. | ||
extras is a map to be added to the message, and prompt is added into | ||
`extras` is a map received from `break`, and `prompt` is added into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
Yeah, once this is merged it should have a changelog entry for sure. Probably it will be the final bug-fix for 0.15.1. Seems no other major problems with 0.15 have been discovered in the weeks after its release. |
... and eval during debugger session within that ns Fixes clojure-emacs/cider#2004
Untangle `inspect-then-read-command`, `stack-then-read-command`
- META__ --> STATE__ - extras --> dbg-state - read-debug --> read-debug-input - read-debug-eval-expression --> read-eval-expression
Good to go AFAIC. Addressed comments, fixed tests and added some extras:
|
src/cider/nrepl/middleware/debug.clj
Outdated
{:status :eval-error | ||
:causes [(let [causes# (stacktrace/analyze-causes e# (:pprint-fn *msg*))] | ||
(when (coll? causes#) (last causes#)))]}))) | ||
::error))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be more robust (and just as easy) to use a generated symbol here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Changed.
LGTM |
👍 |
Fixing #420, clojure-emacs/cider#2039 and clojure-emacs/cider#2004