I've been using debug()
more often now, but sometimes I wonder which functions have been flagged for debugging. I know that you can use isdebugged()
to find out if a particular function is flagged. But is there a way for R to list all the functions that are being debugged?
views:
121answers:
2
+2
A:
Unless you wanted to get into something like writing a function to fire everything through isdebugged(), I don't think you can.
In debug.c, the function do_debug
is what checks for the DEBUG flag being set on an object. There are only three R functions which call the do_debug
C call: debug
, undebug
and isdebugged
.
geoffjentry
2009-10-23 17:45:23
+4
A:
This is convoluted, but it works:
find.debugged.functions <- function(environments=search()) {
r <- do.call("rbind", lapply(environments, function(environment.name) {
return(do.call("rbind", lapply(ls(environment.name), function(x) {
if(is.function(get(x))) {
is.d <- try(isdebugged(get(x)))
if(!(class(is.d)=="try-error")) {
return(data.frame(function.name=x, debugged=is.d))
} else { return(NULL) }
}
})))
}))
return(r)
}
You can run it across all your environments like so:
find.debugged.functions()
Or just in your ".GlobalEnv" with this:
> find.debugged.functions(1)
function.name debugged
1 find.debugged.functions FALSE
2 test TRUE
Here I created a test function which I am debugging.
Shane
2009-10-31 18:23:59