Rev 8123 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
dump.frames <- function(dumpto = "last.dump", to.file = FALSE){calls <- sys.calls()last.dump <- sys.frames()names(last.dump) <- callslast.dump <- last.dump[-length(last.dump)] # remove this functionattr(last.dump, "error.message") <- geterrmessage()class(last.dump) <- "dump.frames"if(dumpto != "last.dump") assign(dumpto, last.dump)if (to.file) save(list=dumpto, file = paste(dumpto, "rda", sep="."))else assign(dumpto, last.dump, envir=.GlobalEnv)invisible()}debugger <- function(dump = last.dump){debugger.look <- function(.selection){for(.obj in ls(envir=dump[[.selection]], all.names=TRUE))assign(.obj, get(.obj, envir=dump[[.selection]]))cat("Browsing in the environment with call:\n ",calls[.selection], "\n", sep="")rm(.obj, .selection)browser()}if (class(dump) != "dump.frames") {cat("`dump' is not an object of class `dump.frames'\n")return(invisible())}err.action <- getOption("error")on.exit(options(error=err.action))if (length(msg <- attr(dump, "error.message")))cat("Message: ", msg)n <- length(dump)calls <- names(dump)repeat {cat("Available environments had calls:\n")cat(paste(1:n, ": ", calls, sep=""), sep="\n")cat("\nEnter an environment number, or 0 to exit ")repeat {ind <- .Internal(menu(as.character(calls)))if(ind <= n) break}if(ind == 0) return(invisible())debugger.look(ind)}}