debugging jruby-rack application with intellij
已回答
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.
请先登录再写评论。
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
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.
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
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).
Have you tried adding
-J-Djruby.compile.mode=OFF -J-Djruby.debug.fullTrace=true
into that xml instead of --debug?
Yup, sure have. Still the same result: step over does a step into.
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!
Thank you for letting us know! It may be helpful for other users