Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use right -sourcepath when jruby is invoked via jdb #5346

Merged
merged 1 commit into from
Oct 11, 2018

Conversation

nomadium
Copy link
Contributor

@nomadium nomadium commented Oct 3, 2018

When --jdb flag is passed to jruby, it's using an incorrect value for -sourcepath flag. This makes the debugger unable to show the source code of the class being debugged.

Before:

shirley:jruby miguel$ ./bin/jruby --jdb -e '[0][1..50] = 2'
Initializing jdb ...
> stop in org.jruby.RubyRange.begLen0
Deferring breakpoint org.jruby.RubyRange.begLen0.
It will be set after the class is loaded.
> run
run org.jruby.Main -e "[0][1..50] = 2"
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
>
VM Started: Set deferred breakpoint org.jruby.RubyRange.begLen0

Breakpoint hit: "thread=main", org.jruby.RubyRange.begLen0(), line=188 bci=0

main[1] list
Source file not found: RubyRange.java
main[1] exit
shirley:jruby miguel$ 

After:

shirley:jruby miguel$ ./bin/jruby --jdb -e '[0][1..50] = 2'
Initializing jdb ...
> stop in org.jruby.RubyRange.begLen0
Deferring breakpoint org.jruby.RubyRange.begLen0.
It will be set after the class is loaded.
> run
run org.jruby.Main -e "[0][1..50] = 2"
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
> 
VM Started: Set deferred breakpoint org.jruby.RubyRange.begLen0

Breakpoint hit: "thread=main", org.jruby.RubyRange.begLen0(), line=188 bci=0
188            long beg = RubyNumeric.num2long(this.begin);

main[1] list
184            return new long[]{beg, len};
185        }
186    
187        final long begLen0(long len) {
188 =>         long beg = RubyNumeric.num2long(this.begin);
189    
190            if (beg < 0) {
191                beg += len;
192                if (beg < 0) {
193                    throw getRuntime().newRangeError(beg + ".." + (isExclusive ? "." : "") + end + " out of range");
main[1] exit
shirley:jruby miguel$ 

@nomadium
Copy link
Contributor Author

nomadium commented Oct 3, 2018

btw, I removed the path $JRUBY_HOME/lib/ruby/1.9 for the source path because it doesn't exist and I was also unsure if that value was ever useful when used with jdb but I could be wrong, of course.

@kares
Copy link
Member

kares commented Oct 4, 2018

hard-coding paths that make sense during development shouldn't be the resolution here.
pbly you want to $JRUBY_HOME/lib/ruby/stdlib:. here so that its usable with a dist build?

@nomadium
Copy link
Contributor Author

nomadium commented Oct 4, 2018

I took a look at a recent dist build, e.g.:

shirley:jruby miguel$ unzip -l jruby-dist-9.2.0.0-src.zip | grep RubyHash.java
    90078  05-24-2018 15:12   jruby-9.2.0.0/core/src/main/java/org/jruby/RubyHash.java
     8639  05-24-2018 15:12   jruby-9.2.0.0/core/src/test/java/org/jruby/test/TestRubyHash.java
shirley:jruby miguel$ 

shirley:jruby miguel$ unzip -l jruby-dist-9.2.0.0-src.zip | grep lib/ruby/stdlib | grep \.java$ | wc -l
       0
shirley:jruby miguel$ 

@kares OK, I'll remove the path including the generated-sources dir since it doesn't make sense for a dist build as you mentioned. However, I wonder if it makes sense to include the ruby stdlib path in the source path of the java debugger, since there are not .java files in that path.

To clarify, which option is preferable?

JDB_SOURCEPATH="${JRUBY_HOME}/core/src/main/java:${JRUBY_HOME}/lib/ruby/stdlib:."

Or just:

JDB_SOURCEPATH="${JRUBY_HOME}/core/src/main/java:."

@nomadium
Copy link
Contributor Author

nomadium commented Oct 9, 2018

@kares I updated the commit as you recommended a few days ago. My remaining question is if it makes sense to include the ruby stdlib path in the source path of the java debugger, since there are not .java files in that path.

@headius
Copy link
Member

headius commented Oct 11, 2018

@nomadium Probably not currently, since even when compiled (via JIT) the file paths will not be rooted in the stdlib dir (they are canonicalized to system-level paths).

I approve, will merge.

@headius headius merged commit 289990d into jruby:master Oct 11, 2018
@headius
Copy link
Member

headius commented Oct 11, 2018

@nomadium I should have been more clear...it's fine for stdlib to be in there even if it doesn't work.

I believe we want the same change in the native JRuby launcher, https://github.com/jruby/jruby-launcher.

@enebo enebo added this to the JRuby 9.2.1.0 milestone Nov 1, 2018
@nomadium nomadium deleted the fix-jdb-sourcepath branch November 25, 2018 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants