[R] how do you know which functions are being debugged?

Duncan Murdoch murdoch at stats.uwo.ca
Fri Oct 23 20:34:54 CEST 2009


On 10/23/2009 2:27 PM, Gabor Grothendieck wrote:
> I have often wanted to get such a list as well without having to write
> code myself.  If  a function which automatically iterated over all
> possible objects and listed out the ones that being debugged were
> available in the core it would be useful.  Even if its slow this would
> be used at debug time and not a production time so it would not be too
> bad.  Even a heuristic that checked likely locations, e.g. just the
> global environment, but not all locations might be useful.

If you look at the code in setBreakpoint, it does a search for functions 
in lots of places (but not everywhere).  You could start from that.

Generally speaking, it's quite hard to think of a way to express what 
the answer would look like to a perfectly general function like you're 
asking for.  Suppose a function lives in the parent environment of the 
environment of an expression that was returned in the result of a call 
to lm that is a local variable in the function that called the function 
where you are asking the question:  how would you return that as an 
answer???  In a language with pointers, you'd just return a pointer to 
it, but R doesn't have those.

Duncan Murdoch

> 
> On Fri, Oct 23, 2009 at 2:02 PM, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
>> On 10/23/2009 1:28 PM, Andrew Yee wrote:
>>>
>>> This is kind of a dumb question:  I know you can use isdebugged() to find
>>> out if a specific function is flagged for debugging, but is there a way to
>>> list all the functions that are flagged for debugging?
>>
>> No, R doesn't keep any master list, it sets a flag in each one.  So you
>> could iterate over all visible objects to find the ones that have the flag
>> set (and this is quite slow, there are a lot of places to look), but there
>> would always be the chance that one was hiding somewhere you didn't look.
>>
>> Duncan Murdoch
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>




More information about the R-help mailing list