Skip to content
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

Merged
merged 8 commits into from
Aug 10, 2017

Conversation

vspinu
Copy link
Contributor

@vspinu vspinu commented Aug 8, 2017

@@ -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)
Copy link
Member

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 :)

Copy link
Member

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. ;-)

Copy link
Contributor Author

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?

Copy link
Member

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.

@expez
Copy link
Member

expez commented Aug 8, 2017

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! 👍

@@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

evaled -> evaluated

Copy link
Contributor Author

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.

:forms @*tmp-forms*}]
`(let [~'META__ {:msg ~(let [{:keys [code id file line column ns]} *msg*]
(-> {:code code,
;; Passing namespace as :original-ns stalls. Bug?
Copy link
Member

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))
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.

(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")))
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let bindings as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

(binding [*tmp-locals* locals]
(binding [*tmp-locals* (:locals extras)
;; evaluate in the instrumentation ns
*ns* (find-ns (symbol (:original-ns extras)))]
Copy link
Member

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?

Copy link
Contributor Author

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.

[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]
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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?

(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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@bbatsov
Copy link
Member

bbatsov commented Aug 8, 2017

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.

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.

vspinu added 6 commits August 8, 2017 23:12
  ... 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
@vspinu
Copy link
Contributor Author

vspinu commented Aug 8, 2017

Good to go AFAIC. Addressed comments, fixed tests and added some extras:

  • improved and disentangled error handling during debug eval commands (eval, inspect, inject, locals),
  • refactored naming conventions here and there

{:status :eval-error
:causes [(let [causes# (stacktrace/analyze-causes e# (:pprint-fn *msg*))]
(when (coll? causes#) (last causes#)))]})))
::error))]
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Changed.

@Malabarba
Copy link
Member

LGTM

@bbatsov bbatsov merged commit b1f85bd into clojure-emacs:master Aug 10, 2017
@bbatsov
Copy link
Member

bbatsov commented Aug 10, 2017

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants