This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Re: Dropping into Interpreter for Interactive Debugging

1 reply
Jason Zaugg
Joined: 2009-05-18,
User offline. Last seen 38 weeks 5 days ago.
What did you try? Which version of Scala are you using? What error did you encounter?
-jason
On Wed, Jan 18, 2012 at 11:22 PM, Daniel Duckworth <duckworthd@gmail.com> wrote:
Thanks Jason.  I already encountered that, but admittedly did not understand it.  Could you perhaps give me an example in code?
Daniel Duckworth
Electrical Engineering and Computer Science
University of California, Berkeley


On Wed, Jan 18, 2012 at 2:17 PM, Jason Zaugg <jzaugg@gmail.com> wrote:
On Wed, Jan 18, 2012 at 9:52 PM, Daniel Duckworth <duckworthd@gmail.com> wrote:
Hi all,

I've been trying to find a way to drop into the interpreter
programmatically to interactively debug my code.  My code will be
running through SBT, and so far I have been unable to find a working
solution.

Hi Daniel,
See "embeddedDefaults" in the FAQ: https://github.com/harrah/xsbt/wiki/FAQ
-jason


duckworthd
Joined: 2011-09-04,
User offline. Last seen 1 year 7 weeks ago.
Re: Dropping into Interpreter for Interactive Debugging
On Wed, Jan 18, 2012 at 4:46 PM, Daniel Duckworth <duckworthd@gmail.com> wrote:
I tried the following,
1) Executing "sbt run" directly.  This results in starting the REPL but not being able to find the "scala" package as scala-compiler.jar isn't in the class path.  The resulting output is,
chickadee:interpreter-insertion duckworthd$ ./sbt run[info] Set current project to default-fb1f46 (in build file:/......../)[info] Compiling 1 Scala source to /......../target/scala-2.9.1/classes... [info] Running Main i = 0i = 1i = 2i = 3i = 4i = 5Debug repl starting.
Failed to initialize compiler: object scala not found. ** Note that as of 2.8 scala does not assume use of the java classpath.** For the old behavior pass -usejavacp to scala, or if using a Settings** object programatically, settings.usejavacp.value = true.
debug>
2) Adding "-usejavacp" to "scalacOptions" in "build.sbt".  This fails to compile with the error,
[error] {file:/....../project/path/}default-fb1f46/compile:compile: scala.tools.nsc.FatalError: object List does not have a member apply
This is because the order in which sbt places scalac compiler arguments, and even if it did put the arguments in the right order, java.class.path only includes the sbt-launcher.jar instead of scala-compiler.jar as required.  This is documented in the link you suggested earlier: https://github.com/harrah/xsbt/wiki/FAQ .
3) Directly compiling my code with "scalac" and executing it with "scala".  This results in a successful compilation and the debugger being brought up without error, but all statements issued from the debugger immediately hang the application.  For example,
chickadee:scala duckworthd$ scalac-2.9 Main.scala chickadee:scala duckworthd$ scala Maini = 0i = 1i = 2i = 3i = 4i = 5 Debug repl starting.
debug> val i = 1
I am using Scala 2.9.1 final.
Daniel Duckworth


On Wed, Jan 18, 2012 at 2:27 PM, Jason Zaugg <jzaugg@gmail.com> wrote:
What did you try? Which version of Scala are you using? What error did you encounter?
-jason
On Wed, Jan 18, 2012 at 11:22 PM, Daniel Duckworth <duckworthd@gmail.com> wrote:
Thanks Jason.  I already encountered that, but admittedly did not understand it.  Could you perhaps give me an example in code?
Daniel Duckworth
Electrical Engineering and Computer Science
University of California, Berkeley


On Wed, Jan 18, 2012 at 2:17 PM, Jason Zaugg <jzaugg@gmail.com> wrote:
On Wed, Jan 18, 2012 at 9:52 PM, Daniel Duckworth <duckworthd@gmail.com> wrote:
Hi all,

I've been trying to find a way to drop into the interpreter
programmatically to interactively debug my code.  My code will be
running through SBT, and so far I have been unable to find a working
solution.

Hi Daniel,
See "embeddedDefaults" in the FAQ: https://github.com/harrah/xsbt/wiki/FAQ
-jason




Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland