debugging jruby-rack application with intellij

Answered

I am trying to get remote debugging set up with an app running on jruby-rack in tomcat.  I have succeeded in getting ruby-debug-ide to fire up a listener port on 1234 and connecting to that port from intellij.  The app will pause on breakpoints I set up intellij as well.  However, step over does not work, and any time I try to inspect variables in scope (expand an object), the debugger will simply jump to my next breakpoint.  I suspect that I need to somehow pass the --debug flag to jruby, but not sure how to do this with jruby-rack.  I have tried to set JRUBY_OPTS="--debug" but this does not work.

Any thoughts on how I can get this working?  I am _so_ close.

8 comments
Comment actions Permalink

Hi Bill,

here are the arguments that we use internally when launching Ruby in debug mode:

-J-Djruby.objectspace.enabled=true -J-Djruby.compile.mode=OFF -J-Djruby.debug.fullTrace=true

I think you can pass them via JRUBY_OPTS

0
Comment actions Permalink

Thanks for the quick response Dennis.  Unfortunately, those settings (set as JRUBY_OPTS in the env) do not work for me.  I did discover that jruby-rack supports a param in web.xml to pass command line arguments:

<context-param>

  <param-name>jruby.runtime.arguments</param-name>

  <param-value>---debug</param-value>

</context-param>

But this does not have any effect either.  Still experimenting.  Some people have reported success with --debug.

0
Comment actions Permalink

I see triple dash before debug, is it intended? You probably need to add -X+O to that line, it enables ObjectSpace that's used for evaluation

0
Comment actions Permalink

Dennis:

So -X+O definitely fixed the object inspection issue, but I still cannot get step over to work.  That's not a huge deal, since I can just add a bunch of breakpoints.  (The triple dash was a typo, still does not work with two dashes).

0
Comment actions Permalink

Have you tried adding 

-J-Djruby.compile.mode=OFF -J-Djruby.debug.fullTrace=true

into that xml instead of --debug?

 

0
Comment actions Permalink

Yup, sure have.  Still the same result: step over does a step into.

0
Comment actions Permalink

So we just upgraded to JRuby 9.0.4.0, and step over works now, with the following:

<context-param>

  <param-name>jruby.runtime.arguments</param-name>

  <param-value>--debug -X+O</param-value>

</context-param>

I have an initializer that starts a debugger port and I connect to that via Intellij and away I debug.

Sweet!

 

 

0
Comment actions Permalink

Thank you for letting us know! It may be helpful for other users

0

Please sign in to leave a comment.