2009-10-23 10 views

risposta

7

Questo è contorto, ma funziona:

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) 
} 

è possibile eseguirlo in tutti gli ambienti in questo modo:

find.debugged.functions() 

O semplicemente nel vostro ".GlobalEnv" con questo:

> find.debugged.functions(1) 
      function.name debugged 
1 find.debugged.functions FALSE 
2     test  TRUE 

Qui ho creato una funzione di test che sto eseguendo il debug.

2

A meno che non voleste entrare in qualcosa come scrivere una funzione per sparare tutto attraverso isdebugged(), non credo che possiate farlo.

In debug.c, la funzione do_debug è la verifica per il flag DEBUG impostato su un oggetto. Esistono solo tre funzioni R che chiamano la chiamata do_debug C: debug, undebug e isdebugged.

Problemi correlati