NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

remote debugging jruby and rails trunk

 
Post new topic   Reply to topic    NetBeans Forums -> Ruby Users
View previous topic :: View next topic  
Author Message
Stephen Bannasch
Posted via mailing list.





PostPosted: Sun Dec 28, 2008 7:15 am    Post subject: remote debugging jruby and rails trunk Reply with quote

Martin, regarding:

http://blogs.sun.com/martink/entry/remote_debugging_debug_whatever_ruby

great work!

Can I put a debugger statement deep inside my code somewhere and have
the debugger stop there?

This is what I'm doing now:

I'm looking for a regression in trunk jruby that happened in svn r8398.

The result is that some of the rails active record tests crash the
jruby interpreter.

In order to make a simple test I am using the technique described on
your page to run the netbeans debugger on the jruby rake task.

I'm using this release of the ruby ide:

netbeans-hudson-trunk-4693-ruby.zip

Which only has jruby 1.1.4 installed.

I also added the Java cluster but that doesn't come into play here.

I'm running these tests on a patched version of activerecord in rails
trunk which allows me to run the tests using jruby and jdbc:

More details here:


http://kenai.com/projects/activerecord-jdbc/lists/dev/archive/2008-12/message/0

Here's the command I am using to start the debugger:

jruby --debug -S rdebug-ide -p 7000 --stop --
/Users/stephen/dev/ruby/src/jruby.git/bin/rake test_jdbcmysql
TEST=test/cases/serialization_test.rb

I'd like to be able to insert a debugger statement into
serialization_test.rb because while stepping through rake is
interesting (and NB seems to do this very nicely) -- it takes a while.

My real goal here is to step through the rails code for the to_xml
method on an ActiveRecord instance far enough to find out where the
crash is happening.
Back to top
Stephen Bannasch
Posted via mailing list.





PostPosted: Mon Dec 29, 2008 7:52 am    Post subject: remote debugging jruby and rails trunk Reply with quote

Quote:
Here's the command I am using to start the debugger:

jruby --debug -S rdebug-ide -p 7000 --stop --
/Users/stephen/dev/ruby/src/jruby.git/bin/rake test_jdbcmysql
TEST=test/cases/serialization_test.rb

I'd like to be able to insert a debugger statement into
serialization_test.rb because while stepping through rake is
interesting (and NB seems to do this very nicely) -- it takes a
while.

My real goal here is to step through the rails code for the to_xml
method on an ActiveRecord instance far enough to find out where the
crash is happening.

It turns out that It's not as simple as I thought to start tracing a
rake invocation and continue through into the test code it is
executing

This is the method in rake.rb that runs the testing task (line: 1002):

def ruby(*args,&block)
options = (Hash === args.last) ? args.pop : {}
if args.length > 1 then
sh(*([RUBY] + args + [options]), &block)
else
sh("#{RUBY} #{args.first}", options, &block)
end
end

It's using 'sh' to run the task ...

But I can run the test like this instead an get the NetBeans debugger working:

jruby -Ilib:test:test/connections/jdbc_jdbcmysql --debug -S
rdebug-ide -p 7000 --stop -- test/cases/serialization_test.rb

This gets me closer but it appears the way the TestUnit classes work
a breakpoint put in the middle of a test method does not get tripped
-- test/unit/testcase.rb seems to do the actual calling of the method
right after it is defined when the class is evaluated -- but NetBeans
doesn't break on any breakpoints within the test methods themselves.

When the test method in the class is being defined -- when I step
into the statement:

def test_serialize_should_be_reversible

The next code executed is the method: method_added in blankslate.rb:

def method_added(name)
result = blank_slate_method_added(name)
return result if self != Object
BlankSlate.hide(name)
result
end

Stepping into the line:

result = blank_slate_method_added(name)

Just results in the debugger pointing at the subsequent line.

return result if self != Object

Which when stepped into runs the test method outside of the debugger.
Back to top
Martin Krauskopf
Posted via mailing list.





PostPosted: Mon Dec 29, 2008 11:19 am    Post subject: remote debugging jruby and rails trunk Reply with quote

Stephen Bannasch wrote:
[...]
Quote:
This is the method in rake.rb that runs the testing task (line: 1002):

def ruby(*args,&block)
options = (Hash === args.last) ? args.pop : {}
if args.length > 1 then
sh(*([RUBY] + args + [options]), &block)
else
sh("#{RUBY} #{args.first}", options, &block)
end
end

It's using 'sh' to run the task ...

Hi Stephen,

yes, this is known issue, that Rake is forking test execution. Is is
better to debug test in NetBeans directly without using the Rake task
for debugging.

Quote:
But I can run the test like this instead an get the NetBeans debugger
working:

jruby -Ilib:test:test/connections/jdbc_jdbcmysql --debug -S rdebug-ide
-p 7000 --stop -- test/cases/serialization_test.rb

This gets me closer but it appears the way the TestUnit classes work a
breakpoint put in the middle of a test method does not get tripped --

I see. Seems to be bug in the backend, since it does not work even with
rdebug (not only with rdebug-ide). But it works with MRI, so I guess
there is a bug in the ruby-debug-base-java implementation. There is a
code handling JRuby core libraries in a special manner, so there might
be problem. I've filed:

https://rubyforge.org/tracker/index.php?func=detail&aid=23372&group_id=3085&atid=11903

Will try to get to it soon.

m.
Back to top
Martin Krauskopf
Posted via mailing list.





PostPosted: Mon Dec 29, 2008 11:35 am    Post subject: remote debugging jruby and rails trunk Reply with quote

Martin Krauskopf wrote:
Quote:
Stephen Bannasch wrote:
[...]
Quote:
This is the method in rake.rb that runs the testing task (line: 1002):

def ruby(*args,&block)
options = (Hash === args.last) ? args.pop : {}
if args.length > 1 then
sh(*([RUBY] + args + [options]), &block)
else
sh("#{RUBY} #{args.first}", options, &block)
end
end

It's using 'sh' to run the task ...

Hi Stephen,

yes, this is known issue

PS: which I would like to address someday, likely with some
monkey-patching somewhere ... do not know how yet.

m.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Ruby Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo