Santiago Molina
2010-Apr-29 22:32 UTC
[Ironruby-core] Debugging ironruby code hosted by a c# app
I''m experimenting a little with ironruby and I just want to know if there''s any way to debug ironruby code that is hosted by a c# windows app. Any ideas? thanks, Santiago -- Posted via http://www.ruby-forum.com/.
Jimmy Schementi
2010-Apr-29 23:51 UTC
[Ironruby-core] Debugging ironruby code hosted by a c# app
You can attach the VS debugger to your process, and as long as you''ve
told the IronRuby engine to generate debug-able code, you can place breakpoints
in Ruby code. The stack trace and watch windows are very verbose, as they show
you the IronRuby internals, but with some extra digging around you can find the
values of your variables and such.
You can initialize the IronRuby engine to generate debug-able code like this:
// Program.cs:
using IronRuby;
using Microsoft.Scripting.Hosting;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args) {
// There might be a more concise way of doing it with
Ruby.CreateEngine((ls) => {}), but I''m not sure
var setup = new ScriptRuntimeSetup() { DebugMode = true };
setup.LanguageSetups.Add(Ruby.CreateRubySetup());
var engine = Ruby.CreateRuntime(setup).GetRubyEngine();
// place a breakpoint in foo.rb, and it''ll break there
engine.ExecuteFile("foo.rb");
}
}
}
# Foo.rb:
puts ''hi''
Note: don''t create foo.rb in VS, as it''ll a Unicode file, and
IronRuby will give you a wonky exception like " undefined method
`???puts'' for main:Object"
> -----Original Message-----
> From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-
> bounces at rubyforge.org] On Behalf Of Santiago Molina
> Sent: Thursday, April 29, 2010 3:33 PM
> To: ironruby-core at rubyforge.org
> Subject: [Ironruby-core] Debugging ironruby code hosted by a c# app
>
> I''m experimenting a little with ironruby and I just want to know
if there''s any
> way to debug ironruby code that is hosted by a c# windows app. Any ideas?
>
> thanks,
> Santiago
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
Tomas Matousek
2010-Apr-29 23:56 UTC
[Ironruby-core] Debugging ironruby code hosted by a c# app
If your app is executing simple Ruby files it is possible to debug them in VS.
You need to turn on debugging when you create a ScriptRuntime:
var setup = new ScriptRuntimeSetup();
setup.DebugMode = true;
setup.AddRubySetup();
var runtime = Ruby.ScriptRuntime(setup);
runtime.ExecuteFile("foo.rb");
Run your app with attached VS debugger and place breakpoint to foo.rb.
Note that DebugMode slows down execution significantly and is therefore not
quite usable for larger app frameworks (gems, rails, etc.). We don''t
have any better debugging experience right now. We are working towards one but
it will take some time.
Tomas
-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at
rubyforge.org] On Behalf Of Santiago Molina
Sent: Thursday, April 29, 2010 3:33 PM
To: ironruby-core at rubyforge.org
Subject: [Ironruby-core] Debugging ironruby code hosted by a c# app
I''m experimenting a little with ironruby and I just want to know if
there''s any way to debug ironruby code that is hosted by a c# windows
app. Any ideas?
thanks,
Santiago
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ironruby-core mailing list
Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org>
http://rubyforge.org/mailman/listinfo/ironruby-core
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/ironruby-core/attachments/20100429/814ecd18/attachment.html>