https://adv-r.hadley.nz/debugging.html#non-interactive-debugging
22.5.1 dump.frames()
dump.frames()
is the equivalent to recover()
for non-interactive code; it saves a last.dump.rda
file in the working directory. Later, an interactive session, you can load("last.dump.rda"); debugger()
to enter an interactive debugger with the same interface as recover()
. This lets you “cheat”, interactively debugging code that was run non-interactively.
# In batch R process ----
dump_and_quit <- function() {
# Save debugging info to file last.dump.rda
dump.frames(to.file = TRUE)
# Quit R with error status
q(status = 1)
}
options(error = dump_and_quit)
# In a later interactive session ----
load("last.dump.rda")
debugger()