# New Release of the Clojure Debugging Toolkit

258 views

Sep 28, 2010, 3:40:22 AM9/28/10
to Clojure
As some of you know, I suffer from a seemingly interminable obsession
with improving the Clojure debugging story. It just seems so clear to
me that Clojure deserves a world class debugger, one befitting it's
power, beauty and elegance. Maybe one day, we'll get there. Till
then, here are my latest improvements to the CDT:

1. Stepping
2. Line number breakpoints
3. An Emacs based front end which allows you to: step, set
breakpoints, catch exceptions, eval remote clojure expressions, and go
up and down the stack, in a much more natural way than with just the
command line.

When you want to eval the s-expr under the cursor, hit ^x^a^p!

CDT will then serialize the s-expr, send it to the remote vm, evaluate
it there in the context of the current stack frame, and display the
result on the mode line.

Ridiculously long instructions on how to use it are here:

I should emphasize that there is nothing Emacs specific about the
CDT. In fact, I've been so spoiled by Clojure, I don't even enjoy
writing Elisp any more. This front end was written in Emacs because
that's the IDE I'm most familiar with. The CDT command line is IDE
agnostic; it should be easy, (dare I say fun?), to port it to other
IDE's. If there's interest, I'll detail how in a future post.

Many thanks to Fogus for the kind words, and to the Runa gang for
their continuing encouragement!

### Laurent PETIT

Sep 28, 2010, 4:08:33 AM9/28/10
Oooh yes !

Many thanks to Fogus for the kind words, and to the Runa gang for
their continuing encouragement!

--
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
For more options, visit this group at

### Sam Aaron

Sep 28, 2010, 5:17:49 AM9/28/10
Wow, looks very useful. Quickly perusing the 'ridiculously long instructions' it seems that it isn't compatible with slime.

Is this the case? Does slime fit into your workflow, and if so, how?

Sam

Sep 28, 2010, 6:20:48 AM9/28/10
to Clojure
I regularly use both simultaneously.

While Slime and the CDT don't currently leverage each other, they
don't interfere with each other either as far as I know, unless you
happen to suspend the swank server thread. Not sure what all the
implications of that are. I'm still learning.

Why do you ask? Is there some particular functionality you are
interested in?

When I want to use both simultaneously, I eval this in my .emacs:

(setq swank-clojure-extra-vm-args '("-

hth,
g

On Sep 28, 2:17 am, Sam Aaron <samaa...@gmail.com> wrote:
> Wow, looks very useful. Quickly perusing the 'ridiculously long instructions' it seems that it isn't compatible with slime.
>
> Is this the case? Does slime fit into your workflow, and if so, how?
>
> Sam
>
> ---http://sam.aaron.name
>
> On 28 Sep 2010, at 9.08 am, Laurent PETIT wrote:
>
> > 2010/9/28 George Jahad <cloj...@blackbirdsystems.net>

### Sam Aaron

Sep 28, 2010, 7:08:26 AM9/28/10
On 28 Sep 2010, at 11.20 am, George Jahad wrote:

> Why do you ask? Is there some particular functionality you are
> interested in?

Well, I'm just learning too. Currently I rely on lein swank to start up my JVM so that slime can connect to it. CDT seems to want you to manually start up the JVM with a particular set of flags. So, do you therefore use two JVM instances?

I guess I could do with sitting and pairing for 10 mins to see how things work ;-)

Is there any chance you could record a short screencast of this stuff in action?

Sam

### Baishampayan Ghose

Sep 28, 2010, 7:18:43 AM9/28/10
>> Why do you ask?  Is there some particular functionality you are
>> interested in?
>
> Well, I'm just learning too. Currently I rely on lein swank to start up my JVM so that slime can connect to it. CDT seems to want you to manually start up the JVM with a particular set of flags. So, do you therefore use two JVM instances?
>
> I guess I could do with sitting and pairing for 10 mins to see how things work ;-)
>
> Is there any chance you could record a short screencast of this stuff in action?

Leiningen honours the JAVA_OPTS environment variable. If you do this -

$export JAVA_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8021"$ lein swank

Then lein will start the JVM with the required flags. After that,
there is no reason why CDT shouldn't work.

Regards,
BG

--
Baishampayan Ghose
b.ghose at gmail.com

### David Nolen

Sep 28, 2010, 8:13:13 AM9/28/10
On Tue, Sep 28, 2010 at 3:40 AM, George Jahad wrote:
As some of you know, I suffer from a seemingly interminable obsession
with improving the Clojure debugging story.  It just seems so clear to
me that Clojure deserves a world class debugger, one befitting it's
power, beauty and elegance.  Maybe one day, we'll get there.  Till
then, here are my latest improvements to the CDT:

Great stuff! Would it be possible to write a version of the tutorial that shows how to accomplish the same things purely from the command line? While I love Emacs as much as the next guy, I think a tutorial that shows how to debug using only the CDT REPL would be useful to many people.

David

### Baishampayan Ghose

Sep 28, 2010, 8:23:17 AM9/28/10
George,

> As some of you know, I suffer from a seemingly interminable obsession
> with improving the Clojure debugging story.  It just seems so clear to
> me that Clojure deserves a world class debugger, one befitting it's
> power, beauty and elegance.  Maybe one day, we'll get there.  Till
> then, here are my latest improvements to the CDT:

Tried it out just now. Works as advertised. Will dive deeper in a
while. Clojure deserves a great debugging infrastructure. I believe
CDT is a big step in the right direction.
Thanks a lot, George!

### Eric Schulte

Sep 28, 2010, 10:40:29 PM9/28/10
Baishampayan Ghose <b.g...@gmail.com> writes:

>>> Why do you ask? Is there some particular functionality you are
>>> interested in?
>>
>> Well, I'm just learning too. Currently I rely on lein swank to start
>> up my JVM so that slime can connect to it. CDT seems to want you to
>> manually start up the JVM with a particular set of flags. So, do you
>> therefore use two JVM instances?
>>
>> I guess I could do with sitting and pairing for 10 mins to see how
>> things work ;-)
>>

If you find a good solution to this please do share.

>>
>> Is there any chance you could record a short screencast of this stuff
>> in action?
>
> Leiningen honours the JAVA_OPTS environment variable. If you do this -
>
> $export JAVA_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8021" >$ lein swank
>
> Then lein will start the JVM with the required flags. After that,
> there is no reason why CDT shouldn't work.
>

Is there any way to pass java_opts arguments to lein on the command
line?

Currently I use the :jvm-opts keyword in project.clj, however it would
be nice to be able to specify different argument when using different
tools as mentioned in the thread above, or to be able to set different
values (e.g. maximum heap sizes) depending on resources of the current
computer.

Is there an accepted way to handle these situations? If not would this
make a good item for future lein development?

Thanks -- Eric

### Phil Hagelberg

Sep 28, 2010, 11:17:42 PM9/28/10
On Tue, Sep 28, 2010 at 7:40 PM, Eric Schulte <schult...@gmail.com> wrote:
> Currently I use the :jvm-opts keyword in project.clj, however it would
> be nice to be able to specify different argument when using different
> tools as mentioned in the thread above, or to be able to set different
> values (e.g. maximum heap sizes) depending on resources of the current
> computer.
>
> Is there an accepted way to handle these situations?  If not would this
> make a good item for future lein development?

You can use unquote to embed arbitrary evaluations in your project.clj:

(defproject foo "1.0.0"
:dependencies [[clojure "1.2.0"]]
:jvm-opts [~(str "-Xmx" (if (= "64" (System/getProperty
"sun.arch.data.model")) "2g" "1g"))])

Untested, but you get the idea.

-Phil

Sep 29, 2010, 12:00:30 AM9/29/10
to Clojure
hmmm, you must be as big a debugger geek as I am, but I'm not sure
anyone else would be interested.

In any case the commands are almost trivial, which is why I don't
think it will be too hard to port this to other IDE's:

These are the CDT commands that were generated by the Emacs front end
in the first example:

(set-bp clojure.set/difference)
(reval s1)
(reval s2)
(reval count)
(reval (count s2))
(step-over)
(reval (reduce disj s1 s2))
(up)
(down)
(cont)
set.clj" 56)

On Sep 28, 5:13 am, David Nolen <dnolen.li...@gmail.com> wrote:
> On Tue, Sep 28, 2010 at 3:40 AM, George Jahad
> <cloj...@blackbirdsystems.net>wrote:

Sep 29, 2010, 12:19:24 AM9/29/10
to Clojure
I forgot to make clear in my post that port 8021 is just an example,
you should use another if that one is in use, and you get this error:

[null] ERROR: JDWP Transport dt_socket failed to initialize,
TRANSPORT_INIT(510)

Adie mentioned that you don't need to specify a port at all:

"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n"

java will pick one for you and display it on stdout, and you can use
that as the parameter to cdt.

Also, Sam, my previous post seems to have gotten eaten, but I'll work
on that screencast.

### Sam Aaron

Sep 29, 2010, 4:54:22 AM9/29/10

On 29 Sep 2010, at 5.19 am, George Jahad wrote:
>
>
> Also, Sam, my previous post seems to have gotten eaten, but I'll work
> on that screencast.

Actually, you seem to have sent it directly to me :-)

A screencast would be wonderful!

Sam

### limux

Oct 7, 2010, 11:15:55 PM10/7/10
to Clojure
where is the sa-jdi.jar, there isn't the sa-jdi.jar under my java's
lib directory.

Oct 8, 2010, 7:32:32 AM10/8/10
to Clojure
sa-jdi.jar is supposed to come with the jdk. The code I use for
finding it should work for sun's 1.6 jdk on linux and osx.

Which java are you using? What os are you running it on?

Also, what problem are you running into without it? (I think I only
use it for some advanced features which you may not need.)

### limux

Oct 8, 2010, 11:12:29 AM10/8/10
to Clojure
I do a full source install of clojure follow by the article "Emacs
Front End to the Clojure Debugging Toolkit", I started the java vm
with all the necesory arguments, and M-x cdt, then there will be some
error messages as below:

Current directory is H:\heoxsoft\emacs\emacs-23.2\bin/
java.lang.NoClassDefFoundError: clojure/main
Caused by: java.lang.ClassNotFoundException: clojure.main
at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
Could not find the main class: clojure.main. Program will exit.
Debugger exited abnormally with code 1

I am a newbie of clojure and java, thanks for you help!

My java is sun jdk 1.6.18, os is windows 7 x64. I will try it after
October 10 because I will install the Ubuntu 10.10.
On 10月8日, 下午7时32分, George Jahad <cloj...@blackbirdsystems.net> wrote:
> sa-jdi.jar is supposed to come with the jdk. The code I use for
> finding it should work for sun's 1.6 jdk on linux and osx.
>
> Which java are you using? What os are you running it on?
>
> Also, what problem are you running into without it? (I think I only
> use it for some advanced features which you may not need.)
>
> On Oct 7, 8:15 pm, limux <liumengji...@gmail.com> wrote:
>
>
>
>
>
>
>
> > where is the sa-jdi.jar, there isn't the sa-jdi.jar under my java's
> > lib directory.
>
> > On 9月29日, 下午12时00分, George Jahad <cloj...@blackbirdsystems.net> wrote:
>
> > > hmmm, you must be as big a debugger geek as I am, but I'm not sure
> > > anyone else would be interested.
>
> > > In any case the commands are almost trivial, which is why I don't
> > > think it will be too hard to port this to other IDE's:
>
> > > These are theCDTcommands that were generated by the Emacs front end
> > > in the first example:
>
> > > (set-bpclojure.set/difference)
> > > (reval s1)
> > > (reval s2)
> > > (reval count)
> > > (reval (count s2))
> > > (step-over)
> > > (reval (reduce disj s1 s2))
> > > (up)
> > > (down)
> > > (cont)
> > > set.clj" 56)
>
> > > On Sep 28, 5:13 am, David Nolen <dnolen.li...@gmail.com> wrote:
>
> > > > On Tue, Sep 28, 2010 at 3:40 AM, George Jahad
> > > > <cloj...@blackbirdsystems.net>wrote:
>
> > > > > As some of you know, I suffer from a seemingly interminable obsession
> > > > > with improving theClojuredebugging story. It just seems so clear to
> > > > > me thatClojuredeserves a world class debugger, one befitting it's
> > > > > power, beauty and elegance. Maybe one day, we'll get there. Till
> > > > > then, here are my latest improvements to theCDT:
>
> > > > Great stuff! Would it be possible to write a version of the tutorial that
> > > > shows how to accomplish the same things purely from the command line? While
> > > > I love Emacs as much as the next guy, I think a tutorial that shows how to
> > > > debug using only theCDTREPL would be useful to many people.
>
> > > > David

### Robert McIntyre

Oct 8, 2010, 7:45:12 PM10/8/10
I believe this is not caused by any problems with the debugging environment.

Instead you appear to not have the clojure jar on your classpath.

I would recommend you explicitly launch java with

java -cp "H:\path\to\clojure.jar"

plus any additional arguments of course.

if this is still not working for you, please post the exact command
you are using to invoke java,
as well as a listing of all jars on your classpath, and I'll try to
help some more.

Good luck,

--Robert McIntyre

2010/10/8 limux <liumen...@gmail.com>:

### limux

Oct 8, 2010, 8:35:11 PM10/8/10
to Clojure
I use "java -
client -cp h:/clojure/libs/clojure-contrib-1.2.0.jar;h:/clojure/libs/
clojure-1.2.0.jar clojure.main --repl" to invoke java, and there is
not any jars in the classpath.
The user namespace is there after I invoke java with that command.

On 10月9日, 上午7时45分, Robert McIntyre <r...@mit.edu> wrote:
> I believe this is not caused by any problems with the debugging environment.
>
> Instead you appear to not have the clojure jar on your classpath.
>
> I would recommend you explicitly launch java with
>
> java -cp "H:\path\to\clojure.jar"
>
> plus any additional arguments of course.
>
> if this is still not working for you, please post the exact command
> you are using to invoke java,
> as well as a listing of all jars on your classpath, and I'll try to
> help some more.
>
> Good luck,
>
> --Robert McIntyre
>
> 2010/10/8 limux <liumengji...@gmail.com>:

### Gregg Williams

Oct 10, 2010, 2:31:42 AM10/10/10
to Clojure
Thanks for your "ridiculously long instructions" on using cdt; I

I'm working on the %$#%$#@^@! Windows platform (Windows XP, to be
precise), and I'm unable to set cdt-source-path in my .emacs file.

I can get my Clojure REPL to start just fine:

----
C:\tech>java -
-client -cp c:\tech\clojure-contrib-1.2.0\target\clojure-
contrib-1.2.0.jar;c:\te
ch\clojure-1.2.0\clojure.jar clojure.main --repl
Listening for transport dt_socket at address: 8021
Clojure 1.2.0
user=>
----

Here's what I have in my .emacs file:

----
(progn
(setq cdt-dir "/tech/cdt")
(setq cdt-source-path "/tech/clojure-1.2.0/src/jvm;/tech/
clojure-1.2.0/src/clj;/tech/clojure-contrib-1.2.0/src/main/clojure")
----

When I select and execute it from within Emacs, I get a message in the
(source)...done". But when I type M-x cdt and set the port to 8021,
the following error message goes into the buffer named *gud-
clojure.main*:

----
Current directory is C:\Documents and Settings\add-minimum/
java.lang.NoClassDefFoundError: clojure/main
Caused by: java.lang.ClassNotFoundException: clojure.main
at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
Could not find the main class: clojure.main. Program will exit.
Debugger exited abnormally with code 1
----

I don't know how to handle Windows pathnames, especially the drive
letter, in the context of (setq cdt-source-path.... I tried taking off
the "/c/" or "c:\" for cdt-dir, and that seems to work. But trying the
same thing for cdt-source-path doesn't seem to work. I'm wondering,
should path names be delimited by colons (as Unix expects), or by
semicolons (as Windows expects). I've tried various combinations, I've
tried to find the Java conventions for Windows classpaths... nothing
seems to work.

Any suggestions from anybody will be appreciated. Thanks.

On Sep 28, 12:40 am, George Jahad <cloj...@blackbirdsystems.net >
wrote:
> As some of you know, I suffer from a seemingly interminable obsession
> with improving the Clojure debugging story.  It just seems so clear to
> me that Clojure deserves a world class debugger, one befitting it's
> power, beauty and elegance.  Maybe one day, we'll get there.  Till
> then, here are my latest improvements to theCDT:
>
> 1. Stepping
> 2. Line number breakpoints
> 3. An Emacs based front end which allows you to: step, set
> breakpoints, catch exceptions, eval remote clojure expressions, and go
> up and down the stack, in a much more natural way than with just the
> command line.
>
> When you want to eval the s-expr under the cursor, hit ^x^a^p!
>
> CDTwill then serialize the s-expr, send it to the remote vm, evaluate
> it there in the context of the current stack frame, and display the
> result on the mode line.
>
> Ridiculously long instructions on how to use it are here:http://georgejahad.com/clojure/emacs-cdt.html
>
> I should emphasize that there is nothing Emacs specific about theCDT.  In fact, I've been so spoiled by Clojure, I don't even enjoy
> writing Elisp any more.  This front end was written in Emacs because
> that's the IDE I'm most familiar with.  TheCDTcommand line is IDE

Oct 10, 2010, 7:39:02 AM10/10/10
to Clojure
I haven't gotten it working on Windows yet, (as I mention here:

I don't think it will be hard, but I've never run Clojure on Windows,
so I'm not sure of the issues involved. I need someone like you to
help me figure them out. I'm guessing the most important issue is the
one you are running into, the path/file separator differences.

I've just pushed my best guess at a fix for windows to the windows
branch here:

Can you try doing a:
git fetch
git checkout windows

from within your cdt repo, and see if that works any better for you?

Thanks!

Oct 10, 2010, 7:41:58 AM10/10/10
to Clojure
> git fetch

Actually, instead of git fetch, use:
git pull origin windows

### Gregg Williams

Oct 11, 2010, 12:12:43 AM10/11/10
to Clojure
George, I don't know what time zone you live in, but you are one crazy
person! You're doing fantastic work for the Clojure community, and I
thank you very much for that!

The Emacs I was using was Clojure Box, so I disconnected slime (just
in case) and tried what you suggested. The results were better, but
still not success, so I downloaded and installed a fresh version of
W32 Emacs (i.e., Emacs only, no Clojure add-ons), then I started over.

Here's the result of refreshing the cdt directory (from the git-bash
shell):

-----
$git pull origin windows remote: Counting objects: 17, done. remote: Compressing objects: 100% (4/4), done. remote: Total 9 (delta 3), reused 0 (delta 0) Unpacking objects: 100% (9/9), done. From git://github.com/GeorgeJahad/cdt * branch windows -> FETCH_HEAD Merge made by recursive. ide/emacs/cdt.el | 4 ++-- src/com/georgejahad/cdt.clj | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) add-minimum@USER-F38F1EBC55 /c/tech/cdt (master)$ git checkout windows
error: pathspec 'windows' did not match any file(s) known to git.

$----- I don't know what went wrong with the last command, but some files were changed in the directory. From a Windows cmd shell window, I got the target REPL working with the following command: ---- java - agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8021 - client -cp \tech\clojure-contrib-1.2.0\target\clojure- contrib-1.2.0.jar;\tech\clojure-1.2.0\clojure.jar clojure.main --repl ---- I did some research on how cmd works, and I found that the cd command has a special syntax for changing the target disk drive--in other words, it's as if, normally, the cd command is "blind" to the existence of multiple hard disks. A Microsoft web page described the following behavior: ---- C:\tech\cdt>cd \ C:\> ---- You could say that "\" acts like root on UNIX systems (!). This explains why the backslash classpath separated by semicolons in the above java command (probably) works. Onward. OK, so now I have a fresh, untainted copy of Emacs. I put the following in the .emacs file (which is otherwise empty): ---- (progn (setq cdt-dir "/tech/cdt") (setq cdt-source-path "/tech/clojure-1.2.0/src/jvm:/tech/ clojure-1.2.0/src/clj:/tech/clojure-contrib-1.2.0/src/main/clojure:") (load-file (format "%s/ide/emacs/cdt.el" cdt-dir))) ---- I open Emacs, execute M-x cdt, and get the following result: ---- Current directory is c:/Documents and Settings/add-minimum/Application Data/ Clojure 1.2.0 user=> java.lang.ClassNotFoundException: com.sun.jdi.Bootstrap (cdt.clj:28) user=> java.lang.Exception: Unable to resolve symbol: set-source-path in this context (NO_SOURCE_FILE:2) user=> java.lang.Exception: Unable to resolve symbol: cdt-attach in this context (NO_SOURCE_FILE:3) user=> Hooray! A REPL! I start reenacting your test-drive scenario and get the following result: ---- user=> (set-bp clojure.set/difference) java.lang.Exception: Unable to resolve symbol: set-bp in this context (NO_SOURCE_FILE:4) user=> ---- So that's the state of things. I'll be glad to work with you to get this working on Windows. What so ironic is that I worked for Apple for 10 years, and the *only* reason I'm doing this on a PC is that the Nuance/Dragon speech-recognition system for the PC is vastly superior to its (just purchased by Nuance) MacOS X equivalent (sigh). Best wishes, Gregg ### George Jahad unread, Oct 11, 2010, 2:44:41 AM10/11/10 to Clojure > George, I don't know what time zone you live in, but you are one crazy > person! I'm on vacation in NYC for a couple more days, then back home to Silicon Valley. Still jet lagged which explains my odd hours. (Not to mention that being in New York is such a rush it's pretty hard to sleep!) > You're doing fantastic work for the Clojure community, and I > thank you very much for that! Hey thanks a lot for the kind words! They mean a lot to me. I guess like most people, it really encourages me when I hear that people like my work. Basically, I'm just trying to emulate the behavior of all the studs that came before me, from RH on down. I'm proud to be able to contribute anything at all to this amazing community! It's so exciting how everything is coming together for Clojure right now. Can't wait to see what happens next. OK, enough rhapsodizing. With respect to the Windows port, I just got an email from Leo S. saying he has it working on Windows. As soon as we figure out the best way to distribute his fixes, I'll let you know. > Nuance/Dragon speech-recognition system for the PC is vastly superior > to its (just purchased by Nuance) MacOS X equivalent (sigh). You going to do some speech recognition in Clojure? ### Gregg Williams unread, Oct 11, 2010, 12:47:25 PM10/11/10 to Clojure >> You going to do some speech recognition in Clojure? Unfortunately, no. I just have some hand RSI problems, and I use Dragon NaturallySpeaking for writing e-mails and documenting Clojure code. You can see an example of the notes I've taken while going through the labrepl exercises at http://www.gettingclojure.com/notes:clojure-notes-labrepl-1 and ...labrepl-2. --Gregg ### atreyu unread, Oct 11, 2010, 6:48:55 PM10/11/10 to Clojure Hi folks and congrats to George Jahad for this great work. Hoewer the cdt dont work on my windows vista. After some changes on my own i get the same error of Greg Willams: java.lang.ClassNotFoundException: com.sun.jdi.Bootstrap (cdt.clj:28) i've tried add-classpath of tool.jar (where is the class in my jdk) with various formats, after testing the urls in browser with success but i get the ClassNotFound all the time Current directory is c:/Users/atreyu/AppData/Roaming/.emacs.d/ Clojure 1.2.0 user=> java.lang.ClassNotFoundException: com.sun.jdi.Bootstrap (cdt.clj:28) user=> java.lang.Exception: Unable to resolve symbol: set-source-path in this context (NO_SOURCE_FILE:2) user=> java.lang.Exception: Unable to resolve symbol: cdt-attach in this context (NO_SOURCE_FILE:3) user=> (def file-url (format "file://%s/../lib/tools.jar" (System/getProperty "java.home"))) #'user/file-url user=> file-url "file://c:\\Program Files\\Java\\jdk1.6.0_21\\jre/../lib/tools.jar" user=> (def file-path "c:\\Program Files\\Java\\jdk1.6.0_21\\jre/../ lib/tools.jar") #'user/file-url user=> (.exists (java.io.File. file-path)) true user=> (add-classpath file-url) WARNING: add-classpath is deprecated nil user=> (import com.sun.jdi.Bootstrap) java.lang.ClassNotFoundException: com.sun.jdi.Bootstrap (NO_SOURCE_FILE:15) i hope somebody'll can help this poor win users ;-) Message has been deleted Message has been deleted ### atreyu unread, Oct 11, 2010, 7:38:40 PM10/11/10 to Clojure ok i have made a (ugly) trick to make it work, copying tools.jar in cdt/lib and changing cdt.el: (defun cdt-query-cmdline () (let ((path (strip-trail cdt-dir))) (format "java -classpath%s/lib/clojure-1.2.0.jar;%s/lib/clojure- contrib-1.2.0.jar;%s/lib/debug-repl-0.3.0-20091229.021828-3.jar;%s/ lib/ tools.jar;%s/src clojure.main --repl" path path path path path))) I guess there is a nicer solution :-/ After this step i've tried to test debugger commands and im afraid reval and gud-this throws: Unexpected exception generated: #<InvocationException com.sun.jdi.InvocationException: Exception occurred in target VM> com.sun.jdi.InvocationException: Exception occurred in target VM (NO_SOURCE_FILE:0) ### leo unread, Oct 12, 2010, 8:53:56 AM10/12/10 to Clojure This works for me under Windows 7. I set all forward slashes paths in my .emacs file like this: (progn (setq cdt-dir "c:/msysgit/cdt") (setq cdt-source-path "c:/clj/clojure-1.2.0/src/jvm;c:/clj/ clojure-1.2.0/src/clj;c:/clj/clojure-contrib-1.2.0/src/main/clojure/ clojure/contrib;") (load-file (format "%s/ide/emacs/cdt.el" cdt-dir))) And these are the diffs from George's current windows version (hopefully George will be able to make them available in a more convenient way) - and note the "file:///" with 3 slashes under Windows: --------- diff --git a/.gitignore b/.gitignore diff --git a/README b/README diff --git a/docs/cdt.muse b/docs/cdt.muse diff --git a/docs/emacs-cdt.muse b/docs/emacs-cdt.muse diff --git a/ide/emacs/cdt.el b/ide/emacs/cdt.el index 0560ab2..42e3e1a 100644 --- a/ide/emacs/cdt.el +++ b/ide/emacs/cdt.el @@ -25,13 +25,13 @@ (gud-call (format "(reval-display '%s)" (thing-at-point 'sexp)))) (defun strip-trail (path) - (if (= (elt path (- (length path) 1)) ?\\) + (if (= (elt path (- (length path) 1)) ?/) (substring path 0 (- (length path) 1)) path)) (defun cdt-query-cmdline () (let ((path (strip-trail cdt-dir))) - (format "java -classpath%s\\lib\\clojure-1.2.0.jar;%s\\lib\ \clojure-contrib-1.2.0.jar;%s\\lib\\debug- repl-0.3.0-20091229.021828-3.jar;%s\\src clojure.main --repl" + (format "java -classpath%s/lib/clojure-1.2.0.jar;%s/lib/clojure- contrib-1.2.0.jar;%s/lib/debug-repl-0.3.0-20091229.021828-3.jar;%s/src clojure.main --repl" path path path path))) (defun cdt (port) diff --git a/project.clj b/project.clj diff --git a/src/com/georgejahad/cdt.clj b/src/com/georgejahad/cdt.clj index d479877..d2d570f 100644 --- a/src/com/georgejahad/cdt.clj +++ b/src/com/georgejahad/cdt.clj @@ -21,10 +21,11 @@ ;; add-classpath is ugly, but handles the fact that tools.jar and ;; sa-jdi.jar are platform dependencies that I can't easily put in a ;; repo: -(with-out-str (add-classpath (format "file://%s/../lib/tools.jar" +(with-out-str (add-classpath (format "file:///%s/../lib/tools.jar" (System/getProperty "java.home")))) -(with-out-str (add-classpath (format "file://%s/../lib/sa-jdi.jar" +(with-out-str (add-classpath (format "file:///%s/../lib/sa-jdi.jar" (System/getProperty "java.home")))) + (import com.sun.jdi.Bootstrap com.sun.jdi.request.EventRequest com.sun.jdi.event.BreakpointEvent @@ -90,7 +91,7 @@ (defonce source-path (atom "")) (defn remove-trailing-slashes [s] - (str/replace s "\\;" ";")) + (str/replace s "/:" ":")) (defn set-source-path [path] (reset! source-path (remove-trailing-slashes path))) @@ -98,10 +99,10 @@ (defn get-source [] (let [file (.sourcePath (.location (.frame (ct) (cf)))) paths (.split @source-path ";")] - (if (= (first file) \\) + (if (= (first file) \/) file (first (filter #(.exists (java.io.File. %)) - (for [p paths] (str p "\\" file))))))) + (for [p paths] (str p "/" file))))))) (defmacro check-unexpected-exception [& body] `(try @@ -325,11 +326,11 @@ (re-pattern (str s "\\$"))))

(defn fix-class [c]
- (str/replace c "/" "."))
+ (str/replace c "\\" "."))

(defn get-class* [fname]
(->> (.split @source-path ";")
- (map #(re-find (re-pattern (str % "\\(.*)(.clj|.java)"))
fname))
+ (map #(re-find (re-pattern (str % "/(.*)(.clj|.java)"))
fname))
(remove nil?)
first
second
@@ -426,7 +427,7 @@
(defn get-file-name [frame]
(let [sp (try (.sourcePath (.location frame))
- (last (.split sp "\\"))))
+ (last (.split sp "/"))))

(defn clojure-frame? [frame fields]
(let [names (map #(.name %) fields)]
Message has been deleted

### atreyu

Oct 13, 2010, 12:36:05 PM10/13/10
to Clojure
I suppose it could be a way to unify both versions using (System/
getProperty "path.separator") and (System/getProperty
"file.separator")
I add the leo changes (to master vesion -lesses changes-) and it works
for me
thanks!!

### Jeff Bordogna

Mar 15, 2011, 1:30:15 PM3/15/11
I'm on Ubuntu and getting this same error.  I can load up the repl no problem (tried with java command, and also with lein swank/slime), but after setting my port on M-x cdt, I get the following in gud-clojure.main:

Current directory is ~/
Clojure 1.2.0
user=> java.lang.ClassNotFoundException: com.sun.jdi.Bootstrap (cdt.clj:30)
user=> java.lang.Exception: Unable to resolve symbol: CDT-DISPLAY-MSG in this context (NO_SOURCE_FILE:2)
user=> java.lang.Exception: Unable to resolve symbol: set-source-path in this context (NO_SOURCE_FILE:3)
user=> java.lang.Exception: Unable to resolve symbol: cdt-attach in this context (NO_SOURCE_FILE:4)

I followed these directions: http://georgejahad.com/clojure/emacs-cdt.html.  Any ideas?

Mar 15, 2011, 9:14:50 PM3/15/11
to Clojure

couple of thoughts:
cdt uses the jdk's tools.jar for access to the java debug interface,
(jdi).

it's expecting it here:
(format "file:///%s/../lib/tools.jar" (System/getProperty
"java.home"))

do you have such a file there?

if not, do you have a tools.jar file anywhere else?

which jdk are you using, sun's or openjdk?

i'm pretty sure tools.jar comes with both, but i can't recall if i
ever looked for it in openjdk.

hth,
g

### Jeff Bordogna

Mar 15, 2011, 10:34:07 PM3/15/11
George,
Thanks for the response.  I'm using openjdk and it lives: file:////usr/lib/jvm/java-6-openjdk/jre/../lib/tools.jar (and the format function worked to find that as well).  Anything I need to change wrt that?

Thanks,
Jeff

Mar 16, 2011, 10:57:14 AM3/16/11
to Clojure
try adding that jar to your classpath, and see if that fixes it.

if not, run "jar -tf" on the tools.jar file to dump the table of
contents on it and email it to me and i'll see if i can figure out
what is going on.

Mar 15, 2011, 11:09:07 PM3/15/11
to Clojure
odd.

try adding that jar to your classpath, and see if that fixes it.

that tools.jar file and email it to me and i'll see if i can figure
out what is going on.

On Mar 15, 7:34 pm, Jeff Bordogna <jeff.bordo...@gmail.com> wrote: