3

I have lein 1.7 with swank 1.4 plugin. Then, I start with no emacs configuration and install clojure-mode from marmalade, create a new project with lein, open up project.clj and then do M-x clojure-jack-in. Slime start just fine. Then I am entering this

; SLIME 20100404
user> (defn x[x]
          (let [y (* x 2)]
               (when (= y 2)
                 (throw (Exception. "hey")))
               y))
#'user/x
user> (x 2)
4
user> (x 1)

It throws me into a debugger, but it looks like it is not complete:

hey
  [Thrown class java.lang.Exception]

Restarts:
 0: [QUIT] Quit to the SLIME top level

Backtrace:
  0:       NO_SOURCE_FILE:1 user/x
      [No Locals]
  1:       NO_SOURCE_FILE:1 user/eval1854
      [No Locals]
  2:     Compiler.java:6465 clojure.lang.Compiler.eval
  3:     Compiler.java:6431 clojure.lang.Compiler.eval
  4:          core.clj:2795 clojure.core/eval
  5:           core.clj:532 swank.core/eval690[fn]
  6:       MultiFn.java:163 clojure.lang.MultiFn.invoke
  7:           basic.clj:54 swank.commands.basic/eval-region
  8:           basic.clj:44 swank.commands.basic/eval-region
  9:           basic.clj:78 swank.commands.basic/eval880[fn]
 --more--

Locals are not shown. No option to continue. I looked at the video: http://vimeo.com/23932914 How do I get to the same configuration of slime/emacs/clojure.

2 Answers 2

3

If I understand correctly, you want to see the locals at the point of the exception, however, I believe that your problem is that where the exception gets caught (after the exit of the x function) you've already moved out of the stackframe where the locals were defined.

For example, if you set a breakpoint....

user> (defn x [x]
        (let [y (* x 2)]
           (when (= 2 y)
             (swank.core/break) 
               (throw (Exception. "hey")))))
user> (x 1)

Then when you hit the break point and get the stack trace, the locals are available.

BREAK:
  [Thrown class java.lang.Exception]

Restarts:
 0: [QUIT] Quit to the SLIME top level
 1: [CONTINUE] Continue from breakpoint

Backtrace:
 0:       NO_SOURCE_FILE:1 user/x
      Locals:
        x = 1
        y = 2
 1:       NO_SOURCE_FILE:1 user/eval6821
 2:     Compiler.java:6465 clojure.lang.Compiler.eval
 3:     Compiler.java:6431 clojure.lang.Compiler.eval
 4:          core.clj:2795 clojure.core/eval
 5:           core.clj:532 swank.core/eval819[fn]
 6:       MultiFn.java:163 clojure.lang.MultiFn.invoke
 7:           basic.clj:54 swank.commands.basic/eval-region
 8:           basic.clj:44 swank.commands.basic/eval-region
 9:           basic.clj:78 swank.commands.basic/eval1009[fn]
 --more--

digging into the source for (swank.core/break), You can actually capture these local bindings yourself....

(defn x [x]
  (let [y (* x 2)]
    (when (= 2 y)
      (swank.core/local-bindings)
        (throw (Exception. "hey")))))

and you'll get the same stacktrace as above from the "hey" exception...

More details here

Sign up to request clarification or add additional context in comments.

Comments

2

This video shows swank-clj, that was renamed to ritz. See instructions in repository on how to install and use it...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.