problem step-in debug through instance_eval

A

Alexandre Mutel

I'm trying to debug an external dsl and i have found some problems to
step in the code (at least under windows)

I have a main.rb file (file are attached in test_debug.7z) :
puts "In Main before eval"
instance_eval(File.read("dyn.dsl"),"dyn.dsl")
puts "In Main after eval"

and a dyn.dsl file :
puts "In dyn line 1"
x = 1 + 1
puts "x = #{x}"

Using Rubymine2.0 with ruby-debug-ide 0.4.9 correctly compiled (it was
quite hard to get there by the way...), the debugger is able to set a
breakpoint correctly on file "dyn.dsl". I'm able to step in this file.
Everything is ok.

Now, if i try to debug it from the comman line : [ruby -r debug
main.rb], i'm not able to see the source file of dyn.dsl code :
E:\Code\RubyTest>ruby -r debug main.rb
Debug.rb
Emacs support available.

main.rb:1:puts "In Main before eval"
(rdb:1) break dyn.dsl:1
Set breakpoint 1 at dyn.dsl:1
(rdb:1) cont
In Main before eval
Breakpoint 1, toplevel at dyn.dsl:1
dyn.dsl:1:
(rdb:1) list
[-4, 5] in dyn.dsl
No sourcefile available for dyn.dsl

Ruby version is : ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]

Worst is that with ruby 1.9.1, I'm no longer able to debug through
instance_eval on an IDE, at least tested Rubymine2.0 or Netbeans.

Do you have any explanations?

Attachments:
http://www.ruby-forum.com/attachment/4271/test_debug.7z
 
B

Brian Candler

instance_eval(File.read("dyn.dsl"),"dyn.dsl")

Could you not just do this instead?

load "dyn.dsl"

The 'self' object context would be lost. But at worst you could pass
that through a constant or a global or thread-local variable, e.g.
dyn.dsl contains

$SELF.instance_eval { ... original content ...
}
Do you have any explanations?

A debugger is probably not going to be able to find the source file if
the source is not in a file but is in a String.
 
A

Alexandre Mutel

Brian said:
Could you not just do this instead?

load "dyn.dsl"

The 'self' object context would be lost. But at worst you could pass
that through a constant or a global or thread-local variable, e.g.
dyn.dsl contains

$SELF.instance_eval { ... original content ...
}

I would prefer another option... I would like to keep the dsl code
clean, and yes, I need the self...
A debugger is probably not going to be able to find the source file if
the source is not in a file but is in a String.

Well, with the 2nd argument of the instance_eval, even if it's more used
to report a correct error, could be used for that (and I believe that
this is used probably by some of those debuggers). Seems that there is
an inconsistency between the different debuggers : JRuby 1.4.0 seems to
be able to step in the code without no problem. The ruby-debug-ide 0.4.9
is working well. The ruby-debug-ide19 is not working on this, the -r
debug command line is not working... weird...

Anyway, i can still live with that. It's working at least from an ide on
1.8.6 and in jruby 1.4.0. I'm also curious if it's a bug (not being able
to step in the code) or a feature that is undocumented...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top