[Ironruby-core] Range#=== operator

Peter Bacon Darwin bacondarwin at googlemail.com
Thu Nov 8 16:33:29 EST 2007

Thanks Dino,

I did use the SaveAssemblies and StaticMethods options – cribbed from one of
John’s blog postings, I think.  From the look of it (the exception is pretty
comprehensive) there is no filtered language exception going on in IronRuby
at this stage.  Or is this just when in debug?  I haven’t tried release.

The trouble with the generated code was that it appeared that the exception
had already been flagged for execution at generation time; One of the
snippets was an action to create and throw the ArgumentException [See

The way I debugged it, as you mention toward the bottom of your mail, was to
search the code that creates the specific ArgumentException dynamic action
(searching for the error string) and then find which bits of code use it.  I
also experimented with placing break points at various places around the DLR
in the AST generation and action binding code.

I guess it just requires a bit of getting used to and knowing where to look.
Trawling through the RubyOnRails code generation (e.g. ActiveRecord) is also
really hard work too.


One other question though:  How do you decide whether to use dynamic sites
to trigger code rather than calling code directly when in coding in C#.  For
instance, why does Protocols.Compare invoke _CompareSharedSite rather than
call a C# function directly?  Sorry if I am being dumb.


By the way, a simple way to get the desired results for the case equality
issue mentioned before is to put a try/catch around the Compare and return
false if an ArgumentException is thrown.  See the attached patch.  Is this
too much of a hack or acceptable?



-----Original Message-----
From: ironruby-core-bounces at rubyforge.org
[mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Dino Viehland
Sent: 08 November 2007 16:51
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Range#=== operator


Here’s a couple of debugging tips:

                -X:SaveAssemblies –X:StaticMethods command line options, use
these when you need to see into a DynamicMethod.  Instead of DynamicMethod’s
we’ll create methods via Reflection.Emit and we’ll save them to disk at
process exit as snippets???.dll (where ??? is a number, usually 1).  You can
then open the assembly w/ reflector or ildasm to see what’s going on in the
generated code.  This is especially useful if you have a small repro snippet
like the one here as snippets will be pretty easy to dig through and find
the particular piece of generated code you want.


                When debugging rules in general the best place to put a
break point is either the language’s RubyActionBinder.MakeRule – where
you’ll see all language specific binding kick in (and boy does Ruby have a
lot of language specific bindings currently :-)!) or you can look at
ActionBinder.GetRule to see the whole process take place.  Unfortunately I
don’t know the ruby code base well enough to give you better hints than that
(but if you want know how to debug IronPython comparisons…)  


                A final useful one is –X:ExceptionDetail – this will cause
the CLR exception to get printed instead of a more filtered language
exception.  Also if the exception comes from a DynamicSite I’ll usually try
and find the exceptions message somewhere in the source code which usually
is in some rule generation code.


Hopefully that’s helpful on the debugging side of things – and maybe some of
this you’ve figured out but it might be useful for other people as well.


No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.24/1117 - Release Date: 07/11/2007

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.15.24/1117 - Release Date: 07/11/2007
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071108/8077bc4f/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: RangeOpsCaseEquality.patch
Type: application/octet-stream
Size: 1251 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/ironruby-core/attachments/20071108/8077bc4f/attachment.obj 

More information about the Ironruby-core mailing list