From Mark.Bravington at csiro.au  Fri Apr  8 01:56:26 2011
From: Mark.Bravington at csiro.au (Mark.Bravington at csiro.au)
Date: Fri, 8 Apr 2011 09:56:26 +1000
Subject: [Rd] How to debug reference classes?
In-Reply-To: <1302202852028-3434269.post@n4.nabble.com>
References: <1302202852028-3434269.post@n4.nabble.com>
Message-ID: <3D59DF35E7CF3E42BA70C23BD5CBE6A85F42B80C69@exvic-mbx04.nexus.csiro.au>

'mtrace' will work with reference classes, at least after an object is instantiated. I'm not familiar with the guts of reference classes, but the following quick experiment was successful.. If you run the example in '?ReferenceClasses' up to & including this line :

xx <- mEditor$new(data = xMat)

and then do this:

mtrace( edit, from=attr( xx, '.xData'))

and then run the next line of the example, which is

xx$edit(2, 2, 0)

then the debug window will come up as normal.

Now, what about if you want to mtrace 'edit' before objects are instantiated? Here the S4 structure defeated me temporarily, but I probably would have been able to beat it if I'd had more time... There are some notes on debugging S4 methods in 'package?debug' (note that '?mtrace' itself is out-of-date on S4-- I have gotten S4 debugging to work, but it's only described in 'package?debug') and that might be enough to get you going.

HTH

Mark ('debug' package author)

Mark Bravington
CSIRO CMIS
Marine Lab
Hobart
Australia
________________________________________
From: r-devel-bounces at r-project.org [r-devel-bounces at r-project.org] On Behalf Of A Zege [andre.zege at gmail.com]
Sent: 08 April 2011 05:00
To: r-devel at r-project.org
Subject: [Rd] How to debug reference classes?

How do you debug methods of a reference class? I've been using mtrace, which
is excellent, but i cannot figure out how to mtrace a reference class
method. Maybe there is some other way to debug these, for example with
ordinary trace? for now i am only able to use options(error=recover), which
is not giving me idea where exactly in the code i am once i am stopped on an
error.

--
View this message in context: http://r.789695.n4.nabble.com/How-to-debug-reference-classes-tp3434269p3434269.html
Sent from the R devel mailing list archive at Nabble.com.

______________________________________________
R-devel at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] How to debug reference classes?
Mark.Bravington at csiro.au