debugger(utils)
debugger()所属R语言包:utils
Post-Mortem Debugging
事后调试
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Functions to dump the evaluation environments (frames) and to examine dumped frames.
职能倾倒评估环境(帧)和检查倾倒帧。
用法----------Usage----------
dump.frames(dumpto = "last.dump", to.file = FALSE)
debugger(dump = last.dump)
参数----------Arguments----------
参数:dumpto
a character string. The name of the object or file to dump to.
一个字符串。对象或文件转储到的名称。
参数:to.file
logical. Should the dump be to an R object or to a file?
逻辑。转储应该是一个R对象或文件?
参数:dump
An R dump object created by dump.frames.
dump.frames创建一个R转储对象。
Details
详情----------Details----------
To use post-mortem debugging, set the option error to be a call to dump.frames. By default this dumps to an R object last.dump in the workspace, but it can be set to dump to a file (a dump of the object produced by a call to save). The dumped object contain the call stack, the active environments and the last error message as returned by geterrmessage.
使用验尸调试,设置的选项error是dump.frames呼叫。默认情况下,这个转储到一个R对象last.dump在工作区中,但它可以设置为转储到一个文件(转储对象调用save由生产)。倾销的对象包含调用堆栈,积极的环境,最后由geterrmessage返回的错误消息。
When dumping to file, dumpto gives the name of the dumped object and the file name has ".rda" appended.
当反倾销文件,dumpto给人倾销的对象,并有.rda附加文件名的名称。
A dump object of class "dump.frames" can be examined by calling debugger. This will give the error message and a list of environments from which to select repeatedly. When an environment is selected, it is copied and the browser called from within the copy. Note that not all the information in the original frame will be available, e.g. promises which have not yet been evaluated and the contents of any ... argument.
一类"dump.frames"转储对象可以审议通过调用debugger。这将给出错误信息和环境列表,从中选择反复。当环境被选中,它被复制和browser的呼吁从副本内。请注意,并非所有的原始帧信息将可用,例如承诺尚未被评估和任何...参数的内容。
If dump.frames is installed as the error handler, execution will continue even in non-interactive sessions. See the examples for how to dump and then quit.
如果dump.frames安装错误处理,将继续执行,即使在非交互式会话。如何转储,然后退出的例子。
值----------Value----------
Invisible NULL.
无形的NULL。
注意----------Note----------
Functions such as sys.parent and environment applied to closures will not work correctly inside debugger.
内sys.parent如environment和debugger适用于封功能将无法正常工作。
If the error occurred when computing the default value of a formal argument the debugger will report “recursive default argument reference” when trying to examine that environment.
如果发生错误时,计算了一个正式的参数,调试器将报告“递归默认参数参考”时,试图检查环境的默认值。
Of course post-mortem debugging will not work if R is too damaged to produce and save the dump, for example if it has run out of workspace.
当然事后调试将无法正常工作,如果R是太损坏产生和保存转储,例如,如果它运行的工作区。
参考文献----------References----------
The New S Language. Wadsworth & Brooks/Cole.
参见----------See Also----------
options for setting error options; recover is an interactive debugger working similarly to debugger but directly after the error occurs.
options设置error选项;recover是一个交互式的调试工作,同样debugger但后直接发生错误。
举例----------Examples----------
## Not run: [#无法运行:]
options(error=quote(dump.frames("testdump", TRUE)))
f <- function() {
g <- function() stop("test dump.frames")
g()
}
f() # will generate a dump on file "testdump.rda"[将产生一个转储文件“testdump.rda”]
options(error=NULL)
## possibly in another R session[#可能在另一个R会话]
load("testdump.rda")
debugger(testdump)
Available environments had calls:
1: f()
2: g()
3: stop("test dump.frames")
Enter an environment number, or 0 to exit
Selection: 1
Browsing in the environment with call:
f()
Called from: debugger.look(ind)
Browse[1]> ls()
[1] "g"
Browse[1]> g
function() stop("test dump.frames")
<environment: 759818>
Browse[1]>
Available environments had calls:
1: f()
2: g()
3: stop("test dump.frames")
Enter an environment number, or 0 to exit
Selection: 0
## A possible setting for non-interactive sessions[#可能设置一个非交互式会话]
options(error=quote({dump.frames(to.file=TRUE); q()}))
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|