Remote debugger doesn't stop at breakpoints in our own code - works for everyone else's
There is some issue which only occurs when the full test suite is run, so I thought I had to resort to remote debugging. It turns out that I might be able to hack together a run config to run rspec directly though, so I will be going down that path now. But I think I would still like to know what I'm doing wrong here, or whether remote debugging is just flaky, or whatever.
IDEA run config:
- Remote
- Transport: Socket (only choice)
- Debugger mode: Listen
- Host: localhost (not editable) Port: 5005
- Search sources using module's classpath: <whole project>
Java command-line:
java -Xmx3g -classpath build/long_classpath_helper.jar \
-agentlib:jdwp=transport=dt_socket,server=n,address=localhost:5005,suspend=y \
org.jruby.Main \
./run-rspec.rb \
src/test/rspec/lib/my_spec.rb
In our code, breakpoints show up as red but without the tick. In the code of other libraries we're using, the tick appears and the debugger stops at the breakpoints like you would expect.
The code we're running against is not obfuscated. I can verify this by stopping at a breakpoint in JRuby and doing a Class.forName on one of our own classes - it resolves with the unmodified name.
The classes are compiled with debug information. Or at least, I hope they are. The Gradle build does not override the setting, and the Gradle docs say that debug defaults to true, but Gradle is also shit, so take any information they claim in the docs with a grain of salt. In any case, it appears that we haven't done anything wrong there, and I have no way to verify whether they have been compiled with debug in or not, as javap does not appear to say.
The code is packaged into jars, so I wonder whether this is the issue - maybe IDEA's debugger expects the exact same class file to be in use. This would significantly diminish the usefulness of a remote debugger though.
In any case, I'm out of ideas. I already spent about a day and a half digging into the issue to find problems we created for ourselves, but I have fixed all of those which I can find and now I hit this one, which is a bit of a roadblock.
How does IDEA map the debugger's classes onto source files? If I had a slight idea about how it worked, maybe it would be possible to figure out why it doesn't.
请先登录再写评论。
Hello,
could you please check that the following is done and how it goes in this case:
- add JRuby facets to the required modules;
- add -Dforce.jruby.jit=true option to the Run configuration.
I can't add the JRuby facet, because IDEA won't let me add the Ruby plugin. So I'm using IDEA as a Java development environment. The debugger shouldn't even need to know that the Java code it's breakpointing in happens to be called from JRuby stuff.
I can't add -Dforce.jruby.jit to the run configuration, because like I said, I'm using remote debugging, and you can't add flags to that.
I did try adding -Dforce.jruby.jit=true to the build script which launches JRuby, but it appears to have had no effect.
This is all happening on IDEA 2016.3, so I've managed to reproduce it on yet another version. At this point it's pretty baffling. What else would make the debugger not stop at the breakpoints? Is there some way to independently verify whether a jar contains class files with debugging enabled?
And I'll re-ask the question that you didn't actually answer:
How does IDEA map the debugger's classes onto source files?
Could you please specify why it's not possible to install Ruby plugin? Is there any error?
As far as I know, it requires the Enterprise version of IDEA. If this has changed recently, though, that would make things easier.
In case you need to work with JRuby then yes, Ruby plugin is needed (and thus Ultimate Edition)
Right, but my breakpoint is in Java code, and the fact that it's being called from JRuby shouldn't be any different to it being called from any other launcher, so I don't get why it wouldn't work.
Hello,
it's quite difficult to say without actually seeing the project itself. Moreover, as far as I understood you have tests written in Ruby as well so it doesn't look like only Java code.
The tests are written in Ruby, but I don't really care about breakpointing in the tests, and my issue is not about breakpointing in the tests.
1) What does red without the tick mean while debugging?
2) Does the remote debugger even work at all? I'm not sure I have ever seen it work, as I have never really had a project going where I was able to use it. Maybe it just doesn't work?
1. When you are setting a breakpoint in IDE, you are getting a red circle. After class is loaded and jvm set the breakpoint - you are getting tick inside it. In general, that means that the breakpoint is really set in the running process.
2. I've just created kinda 'hello world' example with simple jruby code instantiating my java class and calling a method, set a breakpoint into the java method and started remote debugging on local host in the listen mode.
Then, I started my ruby code with the following command line:
java -agentlib:jdwp=transport=dt_socket,server=n,address=localhost:5005,suspend=y -cp "C:\jruby-9.1.7.0\lib\jruby.jar;C:\Repository\Jruby-test\out\production\Jruby-test" org.jruby.Main test.rb
The breakpoint worked like a charm.
My guess, judging by your command line, is that you are starting run_rspec.rb script which is starting my_spec.rb and it seems that your runner (run_rspec) is started in debug mode, but my_spec is started as a separate process and not in debug mode. That's why your java code breakpoint isn't working.