I'm writing some simple code, and I've hit the point where having a
debugger would be helpful. Once I convinced clojure-swank to launch
java with the right arguments, I was able to attach JSwat, to open my
.clj files, and to set breakpoints. But my breakpoints never trigger.
I've googled a bit, but haven't come across the (probably obvious)
answer to my problem. What am I missing?
I'm on Windows 2008, running clojure under clojure-swank from emacs.
[Later]
I wonder if this doesn't have something to do with the fact that I'm
doing everything via the REPL. Is it possible to break on code you've
evaluated via M-x slime-eval-buffer? I'm able to set breakpoints in
(e.g.) boot.clj.
No love with slime-load-file. When I get some time I'll try sticking
my code into a .jar and see if that gets me anywhere.
Or has anyone ever gotten this to work?
I was able to get JSwat to work with Clojure (see my blog post from
yesterday: http://bc.tech.coop/blog/081023.html)
Are you doing all of the following:
1. Specify the appropriate debug options when you start Clojure (see
step #4 in my blog post)
2. Load the Clojure source file you want to debug (you can't debug
definitions created in the repl)
3. Start JSwat and use the "Session/Attach..." menu option to attach
to the correct host/port (in my case, "localhost" and "8888" since I'm
debugging a local Java instance and I specified port "8888" when I
started Java)
4. In JSwat, open the same Clojure source file you loaded in step #2
and add a breakpoint (you can just click on the source line#) - note
that you can only add breakpoints to lines in a defn, not lines in a
defmacro definition
5. In the Clojure repl evaluate a form that will call the function
that has your breakpoint.
6. In JSwat, you should see that the breakpoint has been hit and
program execution is paused
--
Bill Clementson
Yep. Here's the full command line:
c:\WINDOWS\system32\java.exe -Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n -cp
"C:/bin/clojure/clojure/svn/clojure.jar;c:/data/.clojure/*"
clojure.lang.Repl
> 2. Load the Clojure source file you want to debug (you can't debug
> definitions created in the repl)
Did so from the SLIME REPL via (load-file "/path/to/my/source.clj")
> 3. Start JSwat and use the "Session/Attach..." menu option to attach
> to the correct host/port (in my case, "localhost" and "8888" since I'm
> debugging a local Java instance and I specified port "8888" when I
> started Java)
Yep. Localhost and 50525 for me this time (got port from the message
spewed into *inferior-lisp*).
> 4. In JSwat, open the same Clojure source file you loaded in step #2
> and add a breakpoint (you can just click on the source line#) - note
> that you can only add breakpoints to lines in a defn, not lines in a
> defmacro definition
Yep.
> 5. In the Clojure repl evaluate a form that will call the function
> that has your breakpoint.
Yep.
> 6. In JSwat, you should see that the breakpoint has been hit and
> program execution is paused
Nope. :p
Fortunately I've since solved the problem I originally wanted the
debugger for (yay REPL), but it still would be nice to get this to
work...
I'm puzzled by my ability to successfully hit breakpoints in boot.clj.
That seems to imply I'm doing something partially right.
On Fri, Oct 24, 2008 at 7:55 AM, Craig Andera <craig....@gmail.com> wrote:
>
>> Are you doing all of the following:
>>
>> 1. Specify the appropriate debug options when you start Clojure (see
>> step #4 in my blog post)
>
> Yep. Here's the full command line:
>
> c:\WINDOWS\system32\java.exe -Xdebug
> -Xrunjdwp:transport=dt_socket,server=y,suspend=n -cp
> "C:/bin/clojure/clojure/svn/clojure.jar;c:/data/.clojure/*"
> clojure.lang.Repl
No, that's not enough. You didn't specify the port that you want to
connect to JSwat on. add "address=8888" (or something similar) to this
to specify which port you want to use. In my blog example, I'm using
"8888":
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8888
>> 2. Load the Clojure source file you want to debug (you can't debug
>> definitions created in the repl)
>
> Did so from the SLIME REPL via (load-file "/path/to/my/source.clj")
>
>> 3. Start JSwat and use the "Session/Attach..." menu option to attach
>> to the correct host/port (in my case, "localhost" and "8888" since I'm
>> debugging a local Java instance and I specified port "8888" when I
>> started Java)
>
> Yep. Localhost and 50525 for me this time (got port from the message
> spewed into *inferior-lisp*).
Port "50525" is the port that SLIME/SWANK is using to establish the
communications between your running Clojure instance and the emacs
lisp code. You can't use this same port for JSwat.
>> 4. In JSwat, open the same Clojure source file you loaded in step #2
>> and add a breakpoint (you can just click on the source line#) - note
>> that you can only add breakpoints to lines in a defn, not lines in a
>> defmacro definition
>
> Yep.
>
>> 5. In the Clojure repl evaluate a form that will call the function
>> that has your breakpoint.
>
> Yep.
>
>> 6. In JSwat, you should see that the breakpoint has been hit and
>> program execution is paused
>
> Nope. :p
>
> Fortunately I've since solved the problem I originally wanted the
> debugger for (yay REPL), but it still would be nice to get this to
> work...
If you do the above, it should work for you.
> I'm puzzled by my ability to successfully hit breakpoints in boot.clj.
> That seems to imply I'm doing something partially right.
--
Bill Clementson
> Port "50525" is the port that SLIME/SWANK is using to establish the
> communications between your running Clojure instance and the emacs
> lisp code. You can't use this same port for JSwat.
Actually, there are two port-related messages in *inferior-lisp*: one
talks about the port that SLIME is using to talk to SWANK, and I used
the other one. So it appears that a port is chosen for you if you
don't specify one. And as I said, I'm able to attach JSwat and set
(and, more importantly, trigger) breakpoints in boot.clj. So I don't
think anything was wrong with how I was connecting JSwat.
That said, I went head and did as you suggested (it's a PITA to look
up the port every time as I had been doing), but still no luck.
> If you do the above, it should work for you.
If only that were true. :)
It's very likely/nearly certain I'm still doing something wrong - I
appreciate the help.
I'm grasping at straws here, but:
1. Presumably, you're running a compatible version of JSwat (the
latest version doesn't work with Java 1.5)
2. Presumably, you've tried setting breakpoints on multiple lines in
your source file (for some reason, you can't always set a breakpoint
on a clojure line - I haven't figured out why, maybe something to do
with whether the statement is defined with defn or not).
3. Presumably, you've tried debugging different source files (in case
there's some peculiar problem with the specific source file you're
attempting to debug)
It might help if you create a small clojure program, and note down all
the steps that you go through. Then, I can replicate what you're doing
and see if I get a different result.
- Bill
Indeed it was me: everything started working as soon as I made sure my
.clj files were in CLASSPATH the way require describes they should be.
I'm sure it doesn't help that I'm a Java n00b in addition to being a
Clojure neophyte.
As a bonus, require works now, too. Lesson learned: putting your files
anywhere else is asking for trouble.
Thanks, Bill - it's always inspiring when someone else makes an effort
- keeps me from ignoring the problem for too long! (Been a fan of your
blog for quite a while now, BTW.) Hat tip to Allen as well.
Great - glad to hear that you got it working!
- Bill
On Fri, Oct 24, 2008 at 1:27 PM, Craig Andera <can...@wangdera.com> wrote:
>>> It's very likely/nearly certain I'm still doing something wrong - I
>>> appreciate the help.
>