public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* Kawa debugging with Eclipse
@ 2014-04-23 13:48 Andrea Bernardini
  2014-04-23 15:26 ` Charles Turner
  0 siblings, 1 reply; 5+ messages in thread
From: Andrea Bernardini @ 2014-04-23 13:48 UTC (permalink / raw)
  To: kawa

Is it possible to use Eclipse to build and run Kawa?

Now I'm using Eclipse as editor, but I can't build the project nor use
the debugger. 

I created a Java project in Eclipse, configured the classpath and
removed some errors, but when I try to run the project I get this
exception:

>Exception in thread "main" java.lang.Error: internal error - primitive
>type not found
>	at gnu.bytecode.Type.make(Type.java:199)
>	at gnu.bytecode.Type.make(Type.java:141)
>	at gnu.bytecode.Type.make(Type.java:131)
>	at gnu.bytecode.ClassType.addMethod(ClassType.java:710)
>	at gnu.bytecode.ClassType.addMethods(ClassType.java:1036)
>	at
>	gnu.bytecode.ClassType.getDeclaredMethods(ClassType.java:749)
>	at
>	gnu.bytecode.ClassType.getDeclaredMethod(ClassType.java:938)
>	at
>	gnu.bytecode.ClassType.getDeclaredMethod(ClassType.java:958)
>	at gnu.bytecode.Type.<clinit>(Type.java:652) at
>	gnu.expr.Compilation.<clinit>(Compilation.java:290) at
>	kawa.repl.processArgs(repl.java:716) at
>	kawa.repl.main(repl.java:863)

Anyway, what other tools do you use to debug kawa?

-- 
Andrea Bernardini
Engineering Of Computing Systems student
Politecnico di Milano, Italy

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Kawa debugging with Eclipse
  2014-04-23 13:48 Kawa debugging with Eclipse Andrea Bernardini
@ 2014-04-23 15:26 ` Charles Turner
       [not found]   ` <CAOTvmomYQ+z=_OO70Fp7zJkKWgXPCU4+m242N4drbKyFxFKVXQ@mail.gmail.com>
  2014-04-23 18:19   ` Per Bothner
  0 siblings, 2 replies; 5+ messages in thread
From: Charles Turner @ 2014-04-23 15:26 UTC (permalink / raw)
  To: Andrea Bernardini; +Cc: Kawa mailing list

Hi Andrea,

(reposting to list, sorry Andrea)

On 23 April 2014 14:48, Andrea Bernardini <andrebask@gmail.com> wrote:
> Is it possible to use Eclipse to build and run Kawa?

It is surely possible, but no one to my knowledge has done that. I
used the Netbeans IDE when working on Kawa. Netbeans is "officially"
supported by Kawa, and the debugger works very well. An invaluable tip
I learned was the remote debugging feature, where you can start a REPL
on the command line and debug Kawa from the Netbeans IDE whilst
interacting at the REPL, very handy!
>
> Now I'm using Eclipse as editor, but I can't build the project nor use
> the debugger.

Yeah, that makes sense. If it's palatable for you, I suggest Netbeans.
If you have some Eclipse skills, you could look into what exactly
needs to be done for Eclipse and submit a patch, I know you're not the
only one who has wanted to use Eclipse in the past.

I know others edit in something like Emacs, and then only use Netbeans
for code navigation / refactorings / graphical debugging.

> Anyway, what other tools do you use to debug kawa?

Aside from the graphics debugging facilities in Netbeans, I use:

  * The debugging procedures in the Kawa Scheme language when
appropriate (http://www.gnu.org/software/kawa/Debugging.html). The
`disassemble' procedure is particularly useful.

  * For internal compiler debugging, there are some command line
options (http://www.gnu.org/software/kawa/Options.html see section
"Options for debugging"). In particular, -print-debug-expr is very
useful to see if your transformations are actually doing what you
expect.

  * There are various bits of invariant checking code sprinkled in
comments in the particularly hairy parts of Kawa that obviously Per
has found useful in the past. Uncommenting these can reveal the
Dragons of Bit Rot, but in general they're useful to figure out what
some of the core invariants are in a particular module.

  * Print statements! Sadly, this is one of my most effective tools
when I'm lost with what's going on.

  * Per is also a very useful debugging aid :-D

Hope there's something there that helps you.

Cheers,
Charles.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Kawa debugging with Eclipse
  2014-04-23 15:26 ` Charles Turner
       [not found]   ` <CAOTvmomYQ+z=_OO70Fp7zJkKWgXPCU4+m242N4drbKyFxFKVXQ@mail.gmail.com>
@ 2014-04-23 18:19   ` Per Bothner
  1 sibling, 0 replies; 5+ messages in thread
From: Per Bothner @ 2014-04-23 18:19 UTC (permalink / raw)
  To: kawa



On 04/23/2014 08:26 AM, Charles Turner wrote:
> On 23 April 2014 14:48, Andrea Bernardini <andrebask@gmail.com> wrote:
>> Is it possible to use Eclipse to build and run Kawa?
>
> It is surely possible, but no one to my knowledge has done that. I
> used the Netbeans IDE when working on Kawa. Netbeans is "officially"
> supported by Kawa, and the debugger works very well.

NetBeans is supported to the extend of building Kawa, and this is
because NB's build model leverages Ant, which Kawa supports.
Since Kawa requires a multi-stage build (compile .jave files, then
use those to compile .scm files) a straight-forward "Java project"
doesn't work.

Another advantage of NB is that it uses the standard javac, rather
then their own barely-supported compiler.  (Java8 support was
scrambled by volunteers at the last minute, from what I hear.)

However, NetBeans+Kawa doesn't support "incremental compilation"
of Scheme files (i.e. on-the-fly while editing), or lots of other
nice-to-have features.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Fwd: Kawa debugging with Eclipse
       [not found]   ` <CAOTvmomYQ+z=_OO70Fp7zJkKWgXPCU4+m242N4drbKyFxFKVXQ@mail.gmail.com>
@ 2014-04-23 18:19     ` Matthieu Vachon
  2014-04-24 16:47       ` Andrea Bernardini
  0 siblings, 1 reply; 5+ messages in thread
From: Matthieu Vachon @ 2014-04-23 18:19 UTC (permalink / raw)
  To: kawa

Hi,

I tried to compile Kawa with Eclipse and the only errors still
remaining are unimplemented methods when Kawa classes extends
AbstractWeakHashTable<Class,Type>. For an unknown reason yet to be
discovered, Eclipse does not like that some methods are implemented in
the base class using a more specialized type.

For example, `AbstractHashTable` defines `protected abstract int
getEntryHashCode (Entry entry);` which is implemented in
`AbstractWeakHashTable` by `protected int getEntryHashCode
(WEntry<K,V> entry) { return entry.hash; }`. Eclipse internal compiler
does not like this whereas it compiles fine using Sun/Oracle compiler.

I tried a bit to understand and fix the error but did not come with a
good solution.

You can take at look at my fork branch on github
(https://github.com/maoueh/kawa-fork/tree/fork). It's a branch I used
to work more easily with git and Eclipse together. I disabled some
warnings in my project.

As for the debugging parts, here two tricks you can use to debug a
Java program without having the project built with Eclipse directly.

1. Remote debugging

In this trick, you add some parameters to java when compiling (or
executing, but from you past mail, I guess you are doing compilation
debugging). You pass the flags `-Xdebug
-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y` to the
JVM. This will tell the JVM to suspend (because of suspend=y) and it
will wait for a remote debugger to connect to it.

Compilations will look like:

java -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y
-cp 'kawa-1.14.1.jar' kawa.repl -C file.scm

Then, in Eclipse, you create a new launch configuration for remote
java debugging. Debug -> Debug Configurations... -> Remote Java
Application. Follow this tutorial for more details:
http://javarevisited.blogspot.ca/2011/02/how-to-setup-remote-debugging-in.html.
The options to put should be straigthforward when looking at the JVM
options you need to pass.

After launching the compilation (it waits for the remote debugger),
sets your breakpoint in Eclipse and launch your newly debug
configuration. The two should be connected together and you then have
all nice Eclipse debugging facility.

2. Compile using ant

You compile using ant and generates the kawa-1.14.1.jar. Then, you
manually create a debug configuration in Eclipse (Debug -> Debug
Configurations... -> Java Application). You put the following
settings:

(Tab Main)
Project: choose your project name, probably you named it kawa
Main: kawa.repl

(Tab Arguments)
Program arguments: -C <path/to/file.scm) # Can be absolute, can be
relative to working directory, which can be changed at the end of this
tab.

(Tab Classpath) # This is the important part
In the list, select User Entries, then Add Jars and then select the
kawa jar that was compiled with ant.

Simply launch this new configuration in debug mode and you should be good to go.

If you need further instruction or help, don't hesitate to reply to the list.

Regards,
Matt

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Kawa debugging with Eclipse
  2014-04-23 18:19     ` Fwd: " Matthieu Vachon
@ 2014-04-24 16:47       ` Andrea Bernardini
  0 siblings, 0 replies; 5+ messages in thread
From: Andrea Bernardini @ 2014-04-24 16:47 UTC (permalink / raw)
  To: kawa

On Wed, 23 Apr 2014 14:19:54 -0400
Matthieu Vachon <matthieu.o.vachon@gmail.com> wrote:

> As for the debugging parts, here two tricks you can use to debug a
> Java program without having the project built with Eclipse directly.
> 
> 1. Remote debugging
> ...
> 2. Compile using ant
> ... 
>
> Regards,
> Matt

Thanks for this little guide, It is very useful. Especially the
"Compile using ant" part, it is very easy and allows to use the debugger
also with the internal kawa code.

Moreover I found a way to edit and automatically build kawa code from
eclipse on save:

You need to download the kawa source tree and build it the first time
with configure + make, then:

1. Create a new project, select Java Project from an existing Ant Build
file, than select build.xml in the code folder. This import the code in
Eclipse without coping it in the workspace, so you can edit files
directly and the build.  

2. Create an External tools configuration. Run -> External tools ->
External tools configuration... As command, use /usr/bin/make, as
working directory the root of the kawa source tree.

3. Create a builder. Project -> Properties.... then  select the
Builders tab, select import..., then select configuration created at
step 2. Select the newly added builder end click edit... In Build
Options tab, check the During auto builds box.

At this point, when you edit a file in kawa and save, eclipse calls
make, and kawa.jar is built.

So you can configure a new project with the step 2 in Matthieu's guide
(Compile using ant) and put that kawa.jar in the classpath.

Thank you all for the tips.

-- 
Andrea Bernardini
Engineering Of Computing Systems student
Politecnico di Milano, Italy

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-04-24 16:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-23 13:48 Kawa debugging with Eclipse Andrea Bernardini
2014-04-23 15:26 ` Charles Turner
     [not found]   ` <CAOTvmomYQ+z=_OO70Fp7zJkKWgXPCU4+m242N4drbKyFxFKVXQ@mail.gmail.com>
2014-04-23 18:19     ` Fwd: " Matthieu Vachon
2014-04-24 16:47       ` Andrea Bernardini
2014-04-23 18:19   ` Per Bothner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).